Cover the case when the container engine is not available.

In the case the container engine passed in tripleo_container_cli
isn't installed (for example: if we try to remove a docker container
when the instance has podman installed and docker isn't present) then
the role would fail. This patch includes a guard which in the case
the container engine passed in tripleo_container_cli doesn't exist
then nothing is done.
Besides, a check for the container being run in the docker-rm part
was missing, this check is being added too.

Change-Id: Ib5501321fef1a3921fbb17bcfabfb2f5c7c96c41
Related-Bug: #1836531
This commit is contained in:
Jose Luis Franco Arza 2019-07-16 09:45:58 +02:00 committed by Sagi Shnaidman
parent 64b8c75238
commit d2d53ab69c
2 changed files with 12 additions and 0 deletions

View File

@ -15,7 +15,13 @@
# under the License.
- name: Check for {{ tripleo_container_cli }} cli
command: "command -v {{ tripleo_container_cli }}"
register: check_container_cli
failed_when: false
- include_tasks: "tripleo_{{ tripleo_container_cli }}_container_rm.yml"
vars:
container: "{{ item }}"
with_items: "{{ tripleo_containers_to_rm }}"
when: check_container_cli.rc == 0

View File

@ -14,8 +14,14 @@
# License for the specific language governing permissions and limitations
# under the License.
- name: "Check if {{ container }} is running in docker backend"
command: "docker inspect --type container --format exists {{ container }}"
register: stat_docker_container
failed_when: false
- name: remove "{{ container }}" container
docker_container:
name: "{{ container }}"
state: absent
when:
- stat_docker_container.rc == 0