Add playbook to stop and backup services

This commit is contained in:
Tobias Reisinger 2024-10-18 16:34:53 +02:00
parent 36c12a330f
commit 82c25edf8e
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
4 changed files with 62 additions and 15 deletions
playbooks/tasks

View file

@ -1,19 +1,7 @@
- name: Get running compose projects
ansible.builtin.shell:
cmd: |
set -o pipefail
docker container ls --format json \
| jq .Labels \
| grep -oe 'com.docker.compose.project=[a-zA-Z0-9_-]*' \
| sed -e 's/com.docker.compose.project=//' \
| sort \
| uniq
changed_when: false
register: docker_compose_projects_result
- name: Get unused services
ansible.builtin.set_fact:
unused_services: "{{ docker_compose_projects_result.stdout_lines | difference(host_services) }}"
ansible.builtin.include_tasks:
file: tasks/get-unused.yml
when: "unused_services is undefined"
- name: Stop unused services
ansible.builtin.command: