Fix problems with virtualbox inventory and composed vars and groups (#37498)

pull/39380/merge
Ikuze 6 years ago committed by ansibot
parent bf50274945
commit 56937e8972

@ -82,15 +82,20 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
for varname in query:
hostvars[host][varname] = self._query_vbox_data(host, query[varname])
strict = self._options.get('strict', False)
# create composite vars
self._set_composite_vars(self.get_option('compose'), hostvars, host)
self._set_composite_vars(self.get_option('compose'), hostvars[host], host, strict=strict)
# actually update inventory
for key in hostvars[host]:
self.inventory.set_variable(host, key, hostvars[host][key])
# constructed groups based on conditionals
self._add_host_to_composed_groups(self.get_option('groups'), hostvars, host)
self._add_host_to_composed_groups(self.get_option('groups'), hostvars[host], host, strict=strict)
# constructed keyed_groups
self._add_host_to_keyed_groups(self.get_option('keyed_groups'), hostvars[host], host, strict=strict)
def _populate_from_cache(self, source_data):
hostvars = source_data.pop('_meta', {}).get('hostvars', {})

Loading…
Cancel
Save