Add playbook to stop and backup services
This commit is contained in:
parent
36c12a330f
commit
82c25edf8e
4 changed files with 62 additions and 15 deletions
playbooks/tasks
17
playbooks/tasks/get-unused.yml
Normal file
17
playbooks/tasks/get-unused.yml
Normal file
|
@ -0,0 +1,17 @@
|
|||
- name: Get running compose projects
|
||||
ansible.builtin.shell:
|
||||
executable: /usr/bin/bash
|
||||
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: Set unused services
|
||||
ansible.builtin.set_fact:
|
||||
unused_services: "{{ docker_compose_projects_result.stdout_lines | difference(host_services) }}"
|
Loading…
Add table
Add a link
Reference in a new issue