2025-07-16 17:14:16 -06:00

39 lines
1.1 KiB
YAML

---
- name: Create stack directory
ansible.builtin.file:
path: "/docker-shared/stacks/compose/{{ item.name }}"
state: directory
owner: root
group: root
mode: '0755'
loop: "{{ stacks }}"
# when: "'swarm_manager' in hostvars[inventory_hostname]['vm_roles']"
- name: Render docker-compose.yml for each stack
ansible.builtin.template:
src: "{{ item.compose_path }}"
dest: "/docker-shared/stacks/compose/{{ item.name }}/docker-compose.yml"
owner: root
group: root
mode: '0644'
loop: "{{ stacks }}"
# when: "'swarm_manager' in hostvars[inventory_hostname]['vm_roles']"
- name: Ensure Docker bind mount directories exist
ansible.builtin.file:
path: "{{ item_dir }}"
state: directory
owner: root
group: root
mode: '0755'
loop: "{{ stacks | selectattr('mount_dirs', 'defined') | map(attribute='mount_dirs') | list | flatten }}"
loop_control:
loop_var: item_dir
- name: Deploy stackzzz
community.docker.docker_stack:
name: "{{ item.name }}"
compose:
- "/docker-shared/stacks/compose/{{ item.name }}/docker-compose.yml"
state: present
loop: "{{ stacks }}"