feat: add docker teardown playbook

this playbook only removes swarm configurations, not the docker
installation
This commit is contained in:
Alexander Navarro 2024-12-12 13:04:04 -03:00
parent bd00be2a5c
commit 73e4d7fd19

View file

@ -0,0 +1,37 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible/ansible-lint/refs/heads/main/src/ansiblelint/schemas/playbook.json
- name: Remove nodes from swarm
hosts: docker_workers
tasks:
- name: Leave node from swarm
community.docker.docker_swarm:
state: absent
- name: Teardown docker swarm
hosts: docker_managers
tasks:
- name: Disable docker swarm mode
community.docker.docker_swarm:
state: absent
force: true
- name: Delete traefik network
community.docker.docker_network:
name: reverse-proxy
state: absent
- name: Remove docker context for each Swarm manager machine
ignore_errors: true
local_action: >
ansible.builtin.command docker context rm -f {{ ansible_hostname }}
- name: Clean docker resources
hosts: docker
tasks:
- name: Prune docker resources
community.docker.docker_prune:
containers: true
images: true
networks: true
builder_cache: true