18 lines
563 B
YAML
18 lines
563 B
YAML
|
- 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) }}"
|