premier commit
This commit is contained in:
commit
d3e8f0a153
9 changed files with 128 additions and 0 deletions
41
README.md
Normal file
41
README.md
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# Role : docker_keycloak
|
||||||
|
|
||||||
|
|
||||||
|
## Services fournis
|
||||||
|
|
||||||
|
- main.yml : Installation de keycloak sur un serveur docker_host
|
||||||
|
- configure_reverse_proxy.yml : Configuration d'un reverse proxy préalablement installé par le role reverse_proxy
|
||||||
|
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
Fournir les variables suivantes. Par exemple :
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
docker_keycloak_fqdn: auth.libretic.fr
|
||||||
|
docker_keycloak_data_dir: /data1
|
||||||
|
docker_keycloak_service_id: auth
|
||||||
|
docker_keycloak_rp_cert: LE
|
||||||
|
docker_keycloak_rp_docker_host: machine.domaine.local
|
||||||
|
docker_keycloak_db_name: keycloak
|
||||||
|
docker_keycloak_db_user: keycloakdbuser
|
||||||
|
docker_keycloak_db_password: mdp_de_keycloakdbuser
|
||||||
|
```
|
||||||
|
|
||||||
|
| Option | Valeur par défaut | Description |
|
||||||
|
|--------------------------------|-------------------|-------------------------------------------------------------------------------------------|
|
||||||
|
| docker_keycloak_fqdn | | Le nom de domaine pour lequel le service keycloak répond |
|
||||||
|
| docker_keycloak_data_dir | | L'emplacement dans lequel se trouvent les volumes de donnees docker pour le service |
|
||||||
|
| docker_keycloak_service_id | | Le nom de service souhaité : conditionne le nommage des volumes et le routage par traefik |
|
||||||
|
| docker_keycloak_rp_docker_host | | pour configure_reverse_proxy.yml: fqdn de la machine contenant le conteneur docker |
|
||||||
|
| docker_keycloak_rp_cert | LE | Type de certificat pour le reverse proxy (LE = letsencrypt) |
|
||||||
|
| docker_keycloak_db_name | | Nom de la base de données postgres pour keycloak |
|
||||||
|
| docker_keycloak_db_user | | Nom du user postgres propriétaire de la base de données |
|
||||||
|
| docker_keycloak_db_password | | Mot du passe du user postgres |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Poursuite de l'installation dans keycloak
|
||||||
|
|
||||||
|
Après le premier lancement :
|
||||||
|
- créer le compte administrateur
|
1
defaults/main.yml
Normal file
1
defaults/main.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
docker_keycloak_rp_cert: LE
|
10
handlers/main.yml
Normal file
10
handlers/main.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
- name: docker-compose-up
|
||||||
|
shell: |
|
||||||
|
docker-compose up -d
|
||||||
|
args:
|
||||||
|
chdir: /opt/{{ docker_keycloak_service_id }}/
|
||||||
|
|
||||||
|
- name: reverse-proxy-reload
|
||||||
|
service:
|
||||||
|
name: apache2
|
||||||
|
state: reloaded
|
11
tasks/configure_reverse_proxy.yml
Normal file
11
tasks/configure_reverse_proxy.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
- name: prepare reverse_proxy
|
||||||
|
template:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: /etc/apache2/vhosts.d/{{ docker_keycloak_fqdn }}/
|
||||||
|
with_items:
|
||||||
|
- 0_vhost.conf
|
||||||
|
- 1_vhost_additional.conf
|
||||||
|
- 2_mds_exclusion.conf
|
||||||
|
notify: reverse-proxy-reload
|
||||||
|
|
||||||
|
|
14
tasks/main.yml
Normal file
14
tasks/main.yml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
- name: docker directory
|
||||||
|
file:
|
||||||
|
path: /opt/{{ docker_keycloak_service_id }}/
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: prepare docker-compose.yml
|
||||||
|
template:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: /opt/{{ docker_keycloak_service_id }}/
|
||||||
|
with_items:
|
||||||
|
- docker-compose.yml
|
||||||
|
notify: docker-compose-up
|
||||||
|
|
||||||
|
|
2
templates/0_vhost.conf
Normal file
2
templates/0_vhost.conf
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
Use vhost_HTTPS_Generic {{ docker_keycloak_fqdn }} {{ docker_keycloak_rp_cert }} http {{ docker_keycloak_rp_docker_host }} info OpenAccessPolicy BlockCrawlerIndexing On
|
2
templates/1_vhost_additional.conf
Normal file
2
templates/1_vhost_additional.conf
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
ProxyErrorOverride off
|
2
templates/2_mds_exclusion.conf
Normal file
2
templates/2_mds_exclusion.conf
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
45
templates/docker-compose.yml
Normal file
45
templates/docker-compose.yml
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
version: '3.1'
|
||||||
|
|
||||||
|
services:
|
||||||
|
keycloak:
|
||||||
|
image: docker.io/bitnami/keycloak:16
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
KEYCLOAK_DATABASE_HOST: "db"
|
||||||
|
KEYCLOAK_DATABASE_PORT: "5432"
|
||||||
|
KEYCLOAK_DATABASE_NAME: "{{ docker_keycloak_db_name }}"
|
||||||
|
KEYCLOAK_DATABASE_USER: "{{ docker_keycloak_db_user }}"
|
||||||
|
KEYCLOAK_DATABASE_PASSWORD: "{{ docker_keycloak_db_password }}"
|
||||||
|
KEYCLOAK_DATABASE_SCHEMA: "public"
|
||||||
|
KEYCLOAK_PROXY_ADDRESS_FORWARDING: "true"
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.docker.network=traefik"
|
||||||
|
- "traefik.http.routers.{{ docker_keycloak_service_id }}.entrypoints=web"
|
||||||
|
- "traefik.http.routers.{{ docker_keycloak_service_id }}.rule=Host(`{{ docker_keycloak_fqdn }}`)"
|
||||||
|
- "traefik.http.services.{{ docker_keycloak_service_id }}.loadbalancer.server.port=8080"
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
- traefik
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:13
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: "{{ docker_keycloak_db_name }}"
|
||||||
|
POSTGRES_USER: "{{ docker_keycloak_db_user }}"
|
||||||
|
POSTGRES_PASSWORD: "{{ docker_keycloak_db_password }}"
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
volumes:
|
||||||
|
- /data1/{{ docker_keycloak_service_id }}/postgres:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
|
||||||
|
networks:
|
||||||
|
traefik:
|
||||||
|
external: true
|
||||||
|
default:
|
||||||
|
internal: true
|
Loading…
Reference in a new issue