openstack-ansible-ops/leap-upgrades/upgrade-utilities/destroy-old-containers.yml
Kevin Carter 2438ad03ab Added leap upgrade tooling
This change adds upgrade tooling that will take a Juno based
OpenStack-Ansible cloud and upgrade it to Newton. The tooling
will run a deployment through all of the needed steps upgrading
the environment and skipping all of the OpenStack releases in
between.

**This tooling should be considered experimental at this time**

Change-Id: I1880794717b9e47786ae255ea1afa57d805cde8e
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2017-02-01 14:27:07 +00:00

83 lines
2.6 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"
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 Containers
hosts: galera_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 "neutron_agent" | xargs -n 1 lxc-destroy -fn
failed_when: false