ee81ecb240
If tripleo_container_rm is run in check mode, the task which detect what container cli is used will be skipped and the next task relying on the register will fail to run. Let's force the first tasks to be run so we know which container cli is used; and keep running the rest of the playbooks in check mode. Change-Id: I4c5f92b7f308d655c5c94c62c694ad1cea08d625
93 lines
2.9 KiB
YAML
93 lines
2.9 KiB
YAML
---
|
|
# Copyright 2019 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
|
|
- name: "check if {{ container }} service healthcheck exists in systemd"
|
|
stat:
|
|
path: "/etc/systemd/system/tripleo_{{ container }}_healthcheck.service"
|
|
register: systemd_healthcheck_exists
|
|
|
|
- name: "tear-down {{ container }} healthcheck"
|
|
when:
|
|
- systemd_healthcheck_exists.stat.exists
|
|
block:
|
|
- name: "stop and disable {{ container }} healthcheck"
|
|
systemd:
|
|
name: "tripleo_{{ container }}_healthcheck"
|
|
state: stopped
|
|
enabled: false
|
|
|
|
- name: "remove {{ container }} healthcheck service"
|
|
file:
|
|
path: "/etc/systemd/system/tripleo_{{ container }}_healthcheck.service"
|
|
state: absent
|
|
|
|
- name: "remove {{ container }} healthcheck timer"
|
|
file:
|
|
path: "/etc/systemd/system/tripleo_{{ container }}_healthcheck.timer"
|
|
state: absent
|
|
|
|
- name: "check if {{ container }} service exists in systemd"
|
|
stat:
|
|
path: "/etc/systemd/system/tripleo_{{ container }}.service"
|
|
register: systemd_exists
|
|
|
|
- name: "tear-down {{ container }} container"
|
|
when:
|
|
- systemd_exists.stat.exists
|
|
block:
|
|
- name: "stop and disable {{ container }}"
|
|
systemd:
|
|
name: "tripleo_{{ container }}"
|
|
state: stopped
|
|
enabled: false
|
|
|
|
- name: "remove {{ container }} systemd service"
|
|
file:
|
|
path: "/etc/systemd/system/tripleo_{{ container }}.service"
|
|
state: absent
|
|
|
|
- name: "check if {{ container }} service requires exists in systemd"
|
|
stat:
|
|
path: "/etc/systemd/system/tripleo_{{ container }}.service.requires"
|
|
register: systemd_requires_exists
|
|
|
|
- name: "remove {{ container }} systemd requires"
|
|
file:
|
|
path: "/etc/systemd/system/tripleo_{{ container }}.service.requires"
|
|
state: absent
|
|
when:
|
|
- systemd_requires_exists.stat.exists
|
|
|
|
- name: Reload systemd services if needed
|
|
when:
|
|
- systemd_healthcheck_exists.stat.exists or systemd_exists.stat.exists or systemd_requires_exists.stat.exists
|
|
systemd:
|
|
daemon_reload: true
|
|
|
|
- name: "stat {{ container }} container"
|
|
command: "podman container exists {{ container }}"
|
|
failed_when: false
|
|
changed_when: false
|
|
register: stat_container
|
|
|
|
- name: Stop and remove container
|
|
command: "podman container rm --force {{ container }}"
|
|
changed_when: true
|
|
when:
|
|
- stat_container.rc is defined
|
|
- stat_container.rc == 0
|