From 0bbeb4d8cfc582c117ed9412b55f5f5c5adecbf9 Mon Sep 17 00:00:00 2001 From: jerick Date: Sat, 28 Feb 2026 13:23:20 -0500 Subject: [PATCH 1/2] Added app validation, ignores errors on prune --- playbooks/dockerPrune.yaml | 1 + playbooks/dockerUpdate.yml | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/playbooks/dockerPrune.yaml b/playbooks/dockerPrune.yaml index 85906a5..7b00bcd 100644 --- a/playbooks/dockerPrune.yaml +++ b/playbooks/dockerPrune.yaml @@ -3,6 +3,7 @@ hosts: docker_hosts become: true gather_facts: no + ignore_errors: true tasks: - name: Prune all unused containers, images, networks, volumes community.docker.docker_prune: diff --git a/playbooks/dockerUpdate.yml b/playbooks/dockerUpdate.yml index d2915ee..58230c4 100644 --- a/playbooks/dockerUpdate.yml +++ b/playbooks/dockerUpdate.yml @@ -41,3 +41,18 @@ networks: true volumes: true builder_cache: true + + - name: Get status of all containers + community.docker.docker_host_info: + containers: true + containers_all: true + register: docker_info + + - name: Identify containers not in running state + ansible.builtin.set_fact: + not_up_containers: "{{ docker_info.containers | selectattr('State', 'ne', 'running') | map(attribute='Names') | flatten | map('regex_replace', '^/', '') | 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 From 01494df81b13ad86532d8d08ba38e75909c4b06e Mon Sep 17 00:00:00 2001 From: jerick Date: Sat, 28 Feb 2026 13:29:37 -0500 Subject: [PATCH 2/2] changed to docker ps format --- playbooks/dockerUpdate.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/playbooks/dockerUpdate.yml b/playbooks/dockerUpdate.yml index 58230c4..f9b3185 100644 --- a/playbooks/dockerUpdate.yml +++ b/playbooks/dockerUpdate.yml @@ -43,14 +43,13 @@ builder_cache: true - name: Get status of all containers - community.docker.docker_host_info: - containers: true - containers_all: true - register: docker_info + 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: "{{ docker_info.containers | selectattr('State', 'ne', 'running') | map(attribute='Names') | flatten | map('regex_replace', '^/', '') | list }}" + 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: