fix constructed functionality in openstack inventory plugin (#48833)

* test for openstack inventory constructed functionality

this adds unit tests for the compose, groups, and keyed_var features
of the openstack inventory plugin

* fix constructed functionality in openstack inventory plugin

The compose, groups, and keyed_groups functionality of the openstack
inventory plugin was broken:

- the plugin was not passing the correct variables to the
  Constructable methods for compose and groups
- the plugin was simply never calling the appropriate method for
  implementing keyed_groups

This commit fixes both issues.
This commit is contained in:
Lars Kellogg-Stedman 2018-11-27 13:01:56 -05:00 committed by ansibot
parent abdf46803b
commit bafc1f8a41
2 changed files with 96 additions and 2 deletions

View file

@ -240,7 +240,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
# create composite vars
self._set_composite_vars(
self._config_data.get('compose'), hostvars, host)
self._config_data.get('compose'), hostvars[host], host)
# actually update inventory
for key in hostvars[host]:
@ -248,7 +248,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
# constructed groups based on conditionals
self._add_host_to_composed_groups(
self._config_data.get('groups'), hostvars, host)
self._config_data.get('groups'), hostvars[host], host)
# constructed groups based on jinja expressions
self._add_host_to_keyed_groups(
self._config_data.get('keyed_groups'), hostvars[host], host)
for group_name, group_hosts in groups.items():
self.inventory.add_group(group_name)