Ensure docker is running before dropping containers
It might happen we have docker binary installed, while the docker service isn't active/running. This would make the playbook fail, while it's not a valid failure. Change-Id: I3f3011e6855b38828644b94fac3f5e88edfc6d1a
This commit is contained in:
parent
0d4e62238f
commit
f49319c393
@ -4,6 +4,12 @@
|
||||
path: /usr/bin/docker
|
||||
register: docker_path_stat
|
||||
|
||||
- name: Ensure docker service is running
|
||||
when: docker_path_stat.stat.exists
|
||||
systemd:
|
||||
name: docker
|
||||
register: docker_service_state
|
||||
|
||||
- name: remove "{{ containers_to_rm|join(', ') }}" containers
|
||||
docker_container:
|
||||
name: "{{ item }}"
|
||||
@ -11,4 +17,5 @@
|
||||
when:
|
||||
- container_cli == 'podman'
|
||||
- docker_path_stat.stat.exists
|
||||
- docker_service_state.status['SubState'] == 'running'
|
||||
with_items: "{{ containers_to_rm }}"
|
||||
|
Loading…
Reference in New Issue
Block a user