40 lines
1.3 KiB
YAML
40 lines
1.3 KiB
YAML
# https://stackoverflow.com/questions/41667864/can-the-templates-module-handle-multiple-templates-directories
|
|
|
|
- name: Ensure service directory exists
|
|
file:
|
|
path: "{{ current_svc_path }}"
|
|
state: directory
|
|
mode: "700"
|
|
|
|
- name: Ensure directory structure exists
|
|
file:
|
|
path: "{{ current_svc_path }}/{{ item.path }}"
|
|
state: directory
|
|
mode: "700"
|
|
with_community.general.filetree: "{{ templates_source }}"
|
|
when: item.state == "directory"
|
|
|
|
|
|
- name: Include app config variables
|
|
include_vars:
|
|
file: "{{ role_path }}/vars/app_config.yml"
|
|
|
|
- name: Generate {{ current_svc_name }} deployment from templates
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ current_svc_path }}/{{ item.path | regex_replace('\\.j2$', '') }}"
|
|
mode: "600"
|
|
with_community.general.filetree: "{{ templates_source }}"
|
|
when: item.state == "file"
|
|
|
|
- name: Deploy docker-compose for {{ current_svc_name }}
|
|
command: docker compose -f "{{ current_svc_path }}/docker-compose.yml" up -d --pull --remove-orphans
|
|
register: docker_compose_output
|
|
# Not perfect idempotency, but the built-in docker_compose module doesn't support docker-compose v2
|
|
# And of course there's an IPv6 bug in docker-compose v1, smh
|
|
# https://github.com/docker/compose/issues/7670
|
|
changed_when: "'created' in docker_compose_output.stderr.lower()"
|
|
|
|
- debug:
|
|
var: docker_compose_output
|