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.
pull/48833/head
Lars Kellogg-Stedman 6 years ago
parent edd90294cf
commit 5a9c767662

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

@ -68,7 +68,7 @@ def inventory():
return inventory return inventory
def test_simpel_groups(inventory): def test_simple_groups(inventory):
inventory._set_variables(hostvars, {}) inventory._set_variables(hostvars, {})
groups = inventory.inventory.get_groups_dict() groups = inventory.inventory.get_groups_dict()
assert 'testgroup' in groups assert 'testgroup' in groups

Loading…
Cancel
Save