Fix problems with virtualbox inventory and composed vars and groups (#37498)
This commit is contained in:
parent
bf50274945
commit
56937e8972
1 changed files with 7 additions and 2 deletions
|
@ -82,15 +82,20 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
for varname in query:
|
for varname in query:
|
||||||
hostvars[host][varname] = self._query_vbox_data(host, query[varname])
|
hostvars[host][varname] = self._query_vbox_data(host, query[varname])
|
||||||
|
|
||||||
|
strict = self._options.get('strict', False)
|
||||||
|
|
||||||
# create composite vars
|
# 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
|
# actually update inventory
|
||||||
for key in hostvars[host]:
|
for key in hostvars[host]:
|
||||||
self.inventory.set_variable(host, key, hostvars[host][key])
|
self.inventory.set_variable(host, key, hostvars[host][key])
|
||||||
|
|
||||||
# constructed groups based on conditionals
|
# 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):
|
def _populate_from_cache(self, source_data):
|
||||||
hostvars = source_data.pop('_meta', {}).get('hostvars', {})
|
hostvars = source_data.pop('_meta', {}).get('hostvars', {})
|
||||||
|
|
Loading…
Reference in a new issue