Compare commits
3 Commits
466607d477
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8183adff29 | |||
| 01494df81b | |||
| 0bbeb4d8cf |
@@ -3,6 +3,7 @@
|
|||||||
hosts: docker_hosts
|
hosts: docker_hosts
|
||||||
become: true
|
become: true
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
ignore_errors: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: Prune all unused containers, images, networks, volumes
|
- name: Prune all unused containers, images, networks, volumes
|
||||||
community.docker.docker_prune:
|
community.docker.docker_prune:
|
||||||
|
|||||||
@@ -41,3 +41,17 @@
|
|||||||
networks: true
|
networks: true
|
||||||
volumes: true
|
volumes: true
|
||||||
builder_cache: true
|
builder_cache: true
|
||||||
|
|
||||||
|
- name: Get status of all containers
|
||||||
|
ansible.builtin.command: "docker ps -a --format {{ '{{' }}.Names{{ '}}' }}|{{ '{{' }}.State{{ '}}' }}"
|
||||||
|
register: container_statuses
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Identify containers not in running state
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
not_up_containers: "{{ container_statuses.stdout_lines | reject('search', '\\|running$') | map('split', '|') | map('first') | list }}"
|
||||||
|
|
||||||
|
- name: Report containers not in running state
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "WARNING: The following containers are not running on {{ inventory_hostname }}: {{ not_up_containers | join(', ') }}"
|
||||||
|
when: not_up_containers | length > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user