From 56937e8972c34842957dec5f6aa8a30256ec27dd Mon Sep 17 00:00:00 2001 From: Ikuze <37222566+Ikuze@users.noreply.github.com> Date: Fri, 25 May 2018 04:52:14 +0200 Subject: [PATCH] Fix problems with virtualbox inventory and composed vars and groups (#37498) --- lib/ansible/plugins/inventory/virtualbox.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/inventory/virtualbox.py b/lib/ansible/plugins/inventory/virtualbox.py index f9b5cbf0491..9ec1aedfa6d 100644 --- a/lib/ansible/plugins/inventory/virtualbox.py +++ b/lib/ansible/plugins/inventory/virtualbox.py @@ -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', {})