fix teardown (tagging and ansible_user)

This patch fixes two large problems with our teardown logic:

(a) the tags applied to the teardown plays combined with the way we
were calling ansible in quickstart.sh meant that we never executed the
teardown tasks with the default `OPT_TEARDOWN=nodes` behavior.

(b) We were calling all of the teardown tasks at the same point, which
meant that the environment and node teardown tasks were being called
with `ansible_user=root`.  This meant that the node teardown in
particular was a no-op, because the libvirt environment of the stack
user was invisible to the tasks running as root.

With this change in place, I can successfully run quickstart.sh
several times in a row without error (previously this would fail
because the teardown tasks wouldn't execute, causing conflicts)

Change-Id: Ic94241c1d87b2dae335c6cb6627a4fdb5419482e
Closes-bug: 1610677
Closes-bug: 1610537
This commit is contained in:
Lars Kellogg-Stedman 2016-08-07 09:18:52 -04:00
parent f5042eb471
commit 0cec56d80b
7 changed files with 47 additions and 11 deletions

View File

@ -12,13 +12,19 @@
ansible_user: "root"
ansible_host: "{{ virthost }}"
- include: teardown.yml
- include: teardown-provision.yml
# The [provision.yml](provision.yml.html) playbook is responsible for
# The `provision.yml` playbook is responsible for
# creating an inventory entry for our `virthost` and for creating an
# unprivileged user on that host for use by our virtual environment.
- include: provision.yml
# These teardown tasks only make sense after running provision.yml,
# because they assume they are connecting as the `stack` user rather
# than `root`.
- include: teardown-nodes.yml
- include: teardown-environment.yml
# The `environment/setup` role performs any tasks that require `root`
# access on the target host.
- name: Install libvirt packages and configure networks

View File

@ -0,0 +1,8 @@
# This teardown role will destroy libvirt networks
- name: Tear down environment
hosts: virthost
roles:
- environment/teardown
tags:
- teardown-environment
- teardown-all

View File

@ -0,0 +1,10 @@
# This teardown role will destroy all vms defined in the overcloud_nodes
# key, and the undercloud
- name: Tear down undercloud and overcloud vms
hosts: virthost
gather_facts: yes
roles:
- libvirt/teardown
tags:
- teardown-nodes
- teardown-all

View File

@ -0,0 +1,9 @@
# Finally, we conditionally remove basic setup (users,
# groups, directories)to start from scratch
- name: Tear down non-root user on virt host
hosts: virthost
roles:
- provision/teardown
tags:
- teardown-provision
- teardown-all

View File

@ -1,4 +1,3 @@
# This teardown role will destroy all vms defined in the overcloud_nodes
# key, and the undercloud
- name: Teardown undercloud and overcloud vms
@ -8,7 +7,6 @@
- libvirt/teardown
tags:
- teardown-all
- teardown-virthost
- teardown-nodes
# This teardown role will destroy libvirt networks
@ -18,7 +16,7 @@
- environment/teardown
tags:
- teardown-all
- teardown-virthost
- teardown-environment
# Finally, we conditionally remove basic setup (users,
# groups, directories)to start from scratch
@ -27,5 +25,6 @@
roles:
- provision/teardown
tags:
- teardown-provision
- teardown-all

View File

@ -12,13 +12,19 @@
tags:
- provision
- include: teardown.yml
- include: teardown-provision.yml
# The [provision.yml](provision.yml.html) playbook is responsible for
# creating an inventory entry for our `virthost` and for creating an
# unprivileged user on that host for use by our virtual environment.
- include: provision.yml
# These teardown tasks only make sense after running provision.yml,
# because they assume they are connecting as the `stack` user rather
# than `root`.
- include: teardown-nodes.yml
- include: teardown-environment.yml
# The `environment/setup` role performs any tasks that require `root`
# access on the target host.
- name: Install libvirt packages and configure networks

View File

@ -322,15 +322,13 @@ if [ "$OPT_CLEAN" = 1 ]; then
fi
if [ "$OPT_TEARDOWN" = "all" ]; then
OPT_TAGS="${OPT_TAGS:+$OPT_TAGS,}teardown-all,teardown-virthost,teardown-nodes"
OPT_TAGS="${OPT_TAGS:+$OPT_TAGS,}teardown-all"
elif [ "$OPT_TEARDOWN" = "virthost" ]; then
OPT_TAGS="${OPT_TAGS:+$OPT_TAGS,}teardown-virthost,teardown-nodes"
OPT_SKIP_TAGS="${OPT_SKIP_TAGS:+$OPT_SKIP_TAGS,}teardown-all"
OPT_TAGS="${OPT_TAGS:+$OPT_TAGS,}teardown-nodes,teardown-environment"
elif [ "$OPT_TEARDOWN" = "nodes" ]; then
OPT_TAGS="${OPT_TAGS:+$OPT_TAGS,}teardown-nodes"
OPT_SKIP_TAGS="${OPT_SKIP_TAGS:+$OPT_SKIP_TAGS,}teardown-all,teardown-virthost"
elif [ "$OPT_TEARDOWN" = "none" ]; then
OPT_SKIP_TAGS="${OPT_SKIP_TAGS:+$OPT_SKIP_TAGS,}teardown-all,teardown-virthost,teardown-nodes"
OPT_SKIP_TAGS="${OPT_SKIP_TAGS:+$OPT_SKIP_TAGS,}teardown-all"
fi
# Set this default after option processing, because the default depends