Kevin Carter c19a606d58 Save the rsyslog containers
These containers store logs within them and it would be bad to lose
these logs.

Change-Id: I0b3b114dce89c6e55d54efb351788e0cfe85c3b4
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2017-09-06 16:38:31 -05:00

83 lines
2.7 KiB
YAML

---
# Copyright 2016, Rackspace US, Inc.
#
# 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: Destroy lxc containers except galera
hosts: "all_containers:!galera_all:!neutron_agent:!ceph_all:!rsyslog_all"
gather_facts: false
user: root
tasks:
- name: Destroy a container
command: lxc-destroy --force --name "{{ container_name }}"
delegate_to: "{{ physical_host }}"
register: destroy
failed_when: destroy.rc not in [0, 1]
changed_when: destroy.rc == 0
- name: Destroy container data
file:
path: "{{ item }}"
state: "absent"
with_items:
- "/var/lib/lxc/{{ container_name }}"
- "/openstack/{{ container_name }}"
- "/openstack/backup/{{ container_name }}"
- "/openstack/log/{{ container_name }}"
- "/var/log/lxc/lxc-{{ container_name }}.log"
delegate_to: "{{ physical_host }}"
- name: Destroy lxc container cache
hosts: "hosts"
gather_facts: false
user: root
tasks:
- name: Destroy container cache data
file:
path: "{{ item }}"
state: "absent"
with_items:
- "/var/cache/lxc/download"
- "/var/cache/lxc/trusty"
- "/var/lib/lxc/LXC_NAME"
delegate_to: "{{ physical_host }}"
- name: Simple destroy the Galera and Logging Containers
hosts: "galera_all:rsyslog_all"
gather_facts: false
tasks:
- name: Destroy a container
command: lxc-destroy --force --name "{{ container_name }}"
delegate_to: "{{ physical_host }}"
register: destroy
failed_when: destroy.rc not in [0, 1]
changed_when: destroy.rc == 0
- name: Host prep for redeployment
hosts: "hosts"
gather_facts: false
user: root
tasks:
- name: Stop LXC dnsmasq
command: "lxc-system-manage dnsmasq-stop"
failed_when: false
- name: Bring the LXC bridged interface down
command: "ifdown {{ lxc_net_bridge | default('lxcbr0') }}"
failed_when: false
- name: Update apt-cache
command: apt-get update
- name: Search for and destroy reminent RPC grouped containers
shell: >-
lxc-ls -f | awk '/rpc/ {print $1}' | grep -v -e "neutron_agent" -e "ceph" | xargs -n 1 lxc-destroy -fn
failed_when: false