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:
Cédric Jeanneret 2019-02-18 16:19:25 +01:00
parent 0d4e62238f
commit f49319c393

View File

@ -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 }}"