- name: Ensure docker-compose directory exists file: state: directory path: /etc/keycloak-docker - name: Write settings file template: src: docker-compose.yaml.j2 dest: /etc/keycloak-docker/docker-compose.yaml - name: Ensure data directory exists file: state: directory path: /var/keycloak/data owner: "1000" group: "root" mode: "0755" - name: Ensure log directory exists file: state: directory path: /var/log/keycloak owner: "1000" group: "root" mode: "0755" - name: Install apache2 apt: name: - apache2 - apache2-utils state: present - name: Apache modules apache2_module: state: present name: "{{ item }}" loop: - rewrite - proxy - proxy_http - ssl - headers - proxy_wstunnel - name: Copy apache config template: src: keycloak.vhost.j2 dest: /etc/apache2/sites-enabled/000-default.conf owner: root group: root mode: 0644 notify: keycloak Reload apache2 - name: Run docker-compose pull shell: cmd: docker-compose pull chdir: /etc/keycloak-docker/ - name: Run docker-compose up shell: cmd: docker-compose up -d chdir: /etc/keycloak-docker/ - name: Wait for keycloak to start wait_for: port: 8080 timeout: 60 - name: Run docker prune to cleanup unneeded images shell: cmd: docker image prune -f