changed to docker ps format
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user