48 lines
1.4 KiB
YAML
48 lines
1.4 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: Copy raw docker-compose.yml for each stack
|
|
ansible.builtin.copy:
|
|
src: "{{ item.compose_path }}"
|
|
dest: "/docker-shared/stacks/compose/{{ item.name }}/docker-compose.yml"
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
loop: "{{ stacks }}"
|
|
|
|
- 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 }}" |