This change introduces a set of functions for dynamically populating the
lxc_hosts function on each inventory run. Any previous membership is
overwritten each time. The output is written to the
openstack_inventory.json still in order to provide parity with the
values provided to the ansible executable on stdout.
Previous code was fairly naive, inserting hosts into lxc_hosts when they
were marked as `is_metal`. This would add hosts, such as Ceph, that
were on metal but had no LXC containers.
A previous attempt at fixing this changed the _build_container_hosts
function to provide more information about the container build process,
then used that data in the _append_host_containers function to populate
the lxc_hosts group. However, this approach failed due to limited
information in each pass of the loop - if a node was an AIO, it might be
erroneously removed from the lxc_hosts group because a container wasn't
built on a given pass, and due to ordering, that pass may be the last
one of the loop.
To get around such problems, this code instead processes the inventory
in whole, after all containers have been made. Population into the group
is determined according to whether or not a given host's `physical_host`
hostvar matches the host name.
This backport was manual due to code organization changes in
master/ocata. Some variable changes and import paths were updated in the
tests, but they should otherwise be identical to the ocata version.
Reviewed: https:/ /review. openstack. org/427885 /git.openstack. org/cgit/ openstack/ openstack- ansible/ commit/ ?id=b6eebd5c7ab dbcb1d9b3fea8e9 b4605ba1de2b28
Committed: https:/
Submitter: Jenkins
Branch: stable/newton
commit b6eebd5c7abdbcb 1d9b3fea8e9b460 5ba1de2b28
Author: Nolan Brubaker <email address hidden>
Date: Wed Feb 1 14:52:53 2017 -0500
Only insert container hosts into lxc_hosts
This change introduces a set of functions for dynamically populating the inventory. json still in order to provide parity with the
lxc_hosts function on each inventory run. Any previous membership is
overwritten each time. The output is written to the
openstack_
values provided to the ansible executable on stdout.
Previous code was fairly naive, inserting hosts into lxc_hosts when they
were marked as `is_metal`. This would add hosts, such as Ceph, that
were on metal but had no LXC containers.
A previous attempt at fixing this changed the _build_ container_ hosts host_containers function to populate
function to provide more information about the container build process,
then used that data in the _append_
the lxc_hosts group. However, this approach failed due to limited
information in each pass of the loop - if a node was an AIO, it might be
erroneously removed from the lxc_hosts group because a container wasn't
built on a given pass, and due to ordering, that pass may be the last
one of the loop.
To get around such problems, this code instead processes the inventory
in whole, after all containers have been made. Population into the group
is determined according to whether or not a given host's `physical_host`
hostvar matches the host name.
This backport was manual due to code organization changes in
master/ocata. Some variable changes and import paths were updated in the
tests, but they should otherwise be identical to the ocata version.
Change-Id: I9f3336f77cd0ef 05fe1c7edeaf7de fc6d93c3111
Closes-Bug: #1660996