78 lines
2.9 KiB
YAML
78 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.
|
|
|
|
# This playbook is a "best effort" way to remove a container from a host.
|
|
# It'll try to remove the healthcheck, service and then container without
|
|
# much validation in case things failed in the middle.
|
|
|
|
- name: "Disable systemd resources for {{ item }}"
|
|
when:
|
|
- tripleo_container_manage_systemd_teardown | bool
|
|
block:
|
|
- name: "Remove systemd healthcheck for {{ item }}"
|
|
block:
|
|
- name: "Stop and disable systemd timer for {{ item }}"
|
|
systemd:
|
|
state: stopped
|
|
name: "tripleo_{{ item }}_healthcheck.timer"
|
|
enabled: false
|
|
ignore_errors: true
|
|
- name: "Delete systemd timer file for {{ item }}"
|
|
file:
|
|
path: "/etc/systemd/system/tripleo_{{ item }}_healthcheck.timer"
|
|
state: absent
|
|
register: systemd_timer_deleted
|
|
- name: "Stop and disable systemd healthcheck for {{ item }}"
|
|
systemd:
|
|
state: stopped
|
|
name: "tripleo_{{ item }}_healthcheck.service"
|
|
enabled: false
|
|
ignore_errors: true
|
|
- name: "Delete systemd healthcheck file for {{ item }}"
|
|
file:
|
|
path: "/etc/systemd/system/tripleo_{{ item }}_healthcheck.service"
|
|
state: absent
|
|
register: systemd_healthcheck_deleted
|
|
- name: Force systemd to reread configs
|
|
systemd:
|
|
daemon_reload: true
|
|
when: systemd_timer_deleted.changed or systemd_healthcheck_deleted.changed
|
|
- name: "Stop and disable systemd service for {{ item }}"
|
|
systemd:
|
|
state: stopped
|
|
name: "tripleo_{{ item }}.service"
|
|
enabled: false
|
|
ignore_errors: true
|
|
- name: "Delete systemd unit file for {{ item }}"
|
|
file:
|
|
path: "/etc/systemd/system/tripleo_{{ item }}.service"
|
|
state: absent
|
|
register: systemd_file_deleted
|
|
- name: "Remove trailing .requires for {{ item }}"
|
|
file:
|
|
path: "/etc/systemd/system/tripleo_{{ item }}.requires"
|
|
state: absent
|
|
register: systemd_requires_deleted
|
|
- name: Force systemd to reread configs
|
|
systemd:
|
|
daemon_reload: true
|
|
when: systemd_file_deleted.changed or systemd_requires_deleted.changed
|
|
|
|
- name: "Remove container {{ item }}"
|
|
podman_container:
|
|
name: "{{ item }}"
|
|
state: absent
|