Runs before setting up any new stacks or pursue other modifications to docker deployments. Brings down any stack which is not currently defined in a role. This makes the whole installation more idempotent since we take care to not only bring _up_ any necessary docker containers, but also bring _down_ those that have become unnecessary.
12 lines
337 B
YAML
12 lines
337 B
YAML
---
|
|
- name: Get running docker stacks
|
|
community.docker.docker_stack_info:
|
|
register: running_stacks
|
|
become: true
|
|
|
|
- name: Remove stacks without matching role
|
|
community.docker.docker_stack:
|
|
name: "{{ item.Name }}"
|
|
state: "absent"
|
|
loop: "{{ running_stacks.results | rejectattr('Name', 'in', role_names) }}"
|
|
become: true
|