Check if docker enabled before stopping all containers.

The set of tasks in tripleo-podman/tasks/tripleo_docker_stop.yml
are being used during the upgrade to ensure that all
services are stopped when upgrading from Rocky to Stein.
However, in Train docker does not have to be installed in
the system and this task would fail.
Adding a check before to stop the services only if docker
is installed.

Change-Id: I05fa46d3b53ece83867a2ccd5c931b0cac1209d4
This commit is contained in:
Jose Luis Franco Arza 2019-09-10 12:45:51 +02:00
parent 4344c5a7ac
commit 282adce74b
1 changed files with 8 additions and 0 deletions

View File

@ -21,12 +21,20 @@
- system_upgrade_prepare - system_upgrade_prepare
become: true become: true
block: block:
- name: Check if docker is enabled in the system
stat:
path: "/var/run/docker.sock"
register: check_docker
failed_when: false
- name: Stop all services by stopping all Docker containers - name: Stop all services by stopping all Docker containers
command: docker ps -aq command: docker ps -aq
register: running_containers register: running_containers
when: check_docker.stat.exists
- name: Stop a container - name: Stop a container
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: stopped state: stopped
loop: "{{ running_containers.stdout_lines | default([]) }}" loop: "{{ running_containers.stdout_lines | default([]) }}"
when: check_docker.stat.exists