Remove teardown.sh and update related docs

The teardown.sh script attempts to provide a convenience, but is often
left unmaintained. Because it is not maintained, it cannot fully tear
down an environment. In addition, maintaining it has been made much
harder since the introduction of independent role repositories - changes
within those individual repositories would need to either be torn down
in this script, or a tear down process in each role. Such a process
would again face issues with maintenance.

Also the teardown script has created bugs with installs started on a
'dirty' environment. These behaviors have been hard to diagnose and fix,
resulting in a lot of wasted time.

Because of these issues, this patch removes the teardown script
entirely, and alters the docs to recommend that AIOs are deployed to
virtual machines for easier tear down and redeploy, as well as advising
against any kind of production use.

Fixes-Bug: #1540531

Change-Id: Ida59bec0ff961424180940628b006d71e88e199b
This commit is contained in:
Nolan Brubaker 2016-04-27 15:28:32 -04:00
parent 99a190be9b
commit 2a2ad3a296
2 changed files with 6 additions and 290 deletions

View File

@ -29,8 +29,9 @@ Recommended server resources:
`Building an AIO`_ for more details.
* 16GB RAM
It's `possible` to perform AIO builds within a virtual machine but your
virtual machines will perform poorly.
It's `possible` to perform AIO builds within a virtual machine for
demonstration and evaluation, but your virtual machines will perform poorly.
For production workloads, multiple nodes for specific roles are recommended.
.. _hardware-assisted virtualization: https://en.wikipedia.org/wiki/Hardware-assisted_virtualization
@ -210,12 +211,9 @@ isn't always practical. As such the following may be executed instead:
$ # Remove the pip configuration files on the host
$ rm -rf /root/.pip
There is a convenience script (``scripts/teardown.sh``) which will destroy
everything known within an environment. Be aware that this script will destroy
whole environments and should be used WITH CAUTION.
After the teardown is complete, ``run-playbooks.sh`` may be executed again to
rebuild the AIO.
Should an existing AIO environment need to be reinstalled, the most efficient
method is to destroy the host operating system and start over. For this reason,
AIOs are best run inside of some form of virtual machine or cloud guest.
Quick AIO build on Rackspace Cloud
----------------------------------

View File

@ -1,282 +0,0 @@
#!/usr/bin/env bash
# Copyright 2014, 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.
## Shell Opts ----------------------------------------------------------------
set -e -u
## Library Check -------------------------------------------------------------
info_block "Checking for required libraries." 2> /dev/null || source $(dirname ${0})/scripts-library.sh
## Confirmation -------------------------------------------------------------
cat <<EOF
-----------------------------------------------------------------------------
WARNING: This is a destructive action.
All containers will be destroyed as well as the data within the
containers (even if the containers are added by users and not by
AIO). Data will be removed from the host as well (e.g. files, apt
packages and pip packages). Please check this script for information
about the data to be removed in removed_(files/packages/pip-packages).
/etc/openstack_deploy will be preserved and may be manually removed
if needed.
ALL the data stored in the lvm volume group called "lxc" WILL BE
DELETED as well (even if volumes are created by users and not AIO).
Please verify that you have backed up all important data prior to
proceeding with the teardown script.
-----------------------------------------------------------------------------
To REALLY destroy all containers and delete all data mentioned above,
type 'Y' or 'y' and press enter:
EOF
read -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Teardown canceled."
exit 1
fi
## Main ----------------------------------------------------------------------
info_block "Running Teardown"
pushd playbooks
KNOWN_HOSTS=$(ansible hosts --list-hosts) || true
if [ -z "${KNOWN_HOSTS}" ];then
ANSIBLE_DESTROY_HOSTS="localhost"
else
ANSIBLE_DESTROY_HOSTS="hosts"
fi
# Create the destroy play
cat > /tmp/destroy_play.yml <<EOF
- name: Destruction of openstack
hosts: "${ANSIBLE_DESTROY_HOSTS}"
gather_facts: false
user: root
tasks:
- name: Get containers
command: lxc-ls
register: onlinecontainers
failed_when: false
- name: Destroy containers
command: lxc-destroy -fn "{{ item }}"
with_items: onlinecontainers.stdout_lines
when: onlinecontainers.rc == 0 and onlinecontainers.stdout
- name: Shutdown the lxc bridge
shell: |
ifdown {{ item }} || true
with_items: shut_interfaces_down
- name: Lxc system manage shutdown
shell: |
lxc-system-manage system-force-tear-down || true
lxc-system-manage veth-cleanup || true
failed_when: false
- name: Get os service script
shell: |
ls /etc/init | grep -e nova -e swift -e neutron -e haproxy
failed_when: false
register: servicenames
- name: Stop services
service:
name: "{{ item.split('.')[0] }}"
state: "stopped"
enabled: no
failed_when: false
with_items: servicenames.stdout_lines
when: servicenames.stdout
- name: Remove init scripts
shell: |
rm "/etc/init/{{ item }}"
with_items: servicenames.stdout_lines
when: servicenames.stdout
- name: Get pip packages
shell: |
pip freeze | grep -i {% for i in remove_pip_packages %} -e {{ i }}{% endfor %}
register: pippackages
failed_when: false
- name: Remove python packages
pip:
name: "{{ item }}"
state: "absent"
with_items: pippackages.stdout_lines
when: pippackages.stdout
- name: Remove packages
apt:
name: "{{ item }}"
state: "absent"
with_items: remove_packages
failed_when: false
- name: Clean up apt cruft
shell: |
apt-get autoremove --yes || true
failed_when: false
- name: Get all logical volumes
shell: >
lvs | awk '/lxc/ || /cinder/ || /swift/ {print \$1","\$2}'
register: lvstorage
failed_when: false
- name: Remove all logical volumes
lvol:
vg: "{{ item.split(',')[1] }}"
lv: "{{ item.split(',')[0] }}"
state: "absent"
force: "yes"
with_items: lvstorage.stdout_lines
failed_when: false
when: lvstorage.stdout
- name: Get all dm storage devices
shell: >
dmsetup info | awk '/lxc/ || /cinder/ || /swift/ {print \$2}'
register: dmstorage
failed_when: false
- name: Remove dm storage entries
command: dmsetup remove "{{ item }}"
with_items: dmstorage.stdout_lines
when: dmstorage.stdout
- name: Get all loopback storage devices
shell: >
losetup -a | awk -F':' '{print \$1}'
register: lostorage
failed_when: false
- name: Unmount loopback storage
shell: |
umount {{ item }} || true
losetup -d {{ item }} || true
with_items: lostorage.stdout_lines
when: lostorage.stdout
failed_when: false
- name: Remove known AIO mount points (fstab)
lineinfile:
dest: "/etc/fstab"
state: "absent"
regexp: "{{ item }}.*.img"
with_items: aio_mount_points
- name: Remove known AIO mount points (rc.local)
lineinfile:
dest: "/etc/rc.local"
state: "absent"
regexp: "{{ item }}.*.img"
with_items: aio_mount_points
- name: Stop all swap
command: "swapoff -a"
failed_when: false
- name: Remove known files and folders.
shell: |
rm -rf {{ item }}
failed_when: false
with_items: remove_files
vars:
aio_mount_points:
- cinder
- swap
- swift
shut_interfaces_down:
- lxcbr0
remove_files:
- /etc/haproxy
- /etc/nova
- /etc/network/interfaces.d/aio_interfaces.cfg
- /etc/neutron
- /etc/openstack_deploy/ansible_facts
- /etc/swift
- /openstack
- /opt/*.img
- /opt/*lxc*
- /opt/*neutron*
- /opt/*nova*
- /opt/*pip*
- /opt/*repo*
- /root/.pip
- /var/lib/neutron
- /var/lib/nova
- /var/lib/mongodb
- /var/log/mongodb
- /var/log/swift
- /var/log/neutron
- /var/log/nova
remove_packages:
- haproxy
- hatop
- liblxc1
- libvirt0
- libvirt-bin
- lxc
- lxc-dev
- vim-haproxy
- mongodb-server
- mongodb-clients
- python-pymongo
remove_pip_packages:
- cinder
- eventlet
- euca2ools
- glance
- heat
- keystone
- kombu
- lxc
- lxml
- mysql
- neutron
- nova
- oslo
- Paste
- pbr
- pymongo
- repoze
- six
- sql
- swift
- turbolift
- warlock
EOF
# Destroy all of the known stuff.
if [ "${ANSIBLE_DESTROY_HOSTS}" == "localhost" ];then
echo -e '[all]\nlocalhost ansible_connection=local' | tee /tmp/localhost
openstack-ansible -i /tmp/localhost /tmp/destroy_play.yml --forks ${FORKS} || true
# Since this is an AIO, just remove it from the local hosts file
sed -i '/_container-/d' /etc/hosts
else
openstack-ansible lxc-containers-destroy.yml --forks ${FORKS} || true
openstack-ansible /tmp/destroy_play.yml --forks ${FORKS} || true
# Remove containers from /etc/hosts on physical hosts
ansible hosts -m shell -a "sed -i '/_container-/d' /etc/hosts"
fi
popd
# Remove the temp destruction play
rm /tmp/destroy_play.yml &>/dev/null || true
rm /tmp/localhost &>/dev/null || true
# Final message
get_instance_info
info_block "* NOTICE *"
echo -e "The system has been torn down."
echo -e "Make sure you update and/or review the file '/etc/fstab'."
if [ ! -z "${KNOWN_HOSTS}" ];then
echo -e "The following hosts has been touched: \"${KNOWN_HOSTS}\""
fi
echo -e "Entries may need to be updated."