From 7d46ce9c5199ddcc957bb8eaa0d007b31cdb69ec Mon Sep 17 00:00:00 2001 From: willtome Date: Tue, 28 Jan 2020 08:24:33 -0600 Subject: [PATCH] fix constructed compose Fixes ansible/ansible#59680 and ansible/ansible#48309. add support for strict parameter for constructed. Change-Id: I08cba2d9ee372071f3899c7c9b74d9351dfdb5d4 Signed-off-by: willtome --- plugins/inventory/openstack.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/inventory/openstack.py b/plugins/inventory/openstack.py index 365ae547..e908a10e 100644 --- a/plugins/inventory/openstack.py +++ b/plugins/inventory/openstack.py @@ -256,24 +256,26 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): def _set_variables(self, hostvars, groups): + strict = self.get_option('strict') + # set vars in inventory from hostvars for host in hostvars: - # create composite vars - self._set_composite_vars( - self._config_data.get('compose'), hostvars[host], host) - # actually update inventory for key in hostvars[host]: self.inventory.set_variable(host, key, hostvars[host][key]) + # create composite vars + self._set_composite_vars( + self._config_data.get('compose'), self.inventory.get_host(host).get_vars(), host, strict) + # constructed groups based on conditionals self._add_host_to_composed_groups( - self._config_data.get('groups'), hostvars[host], host) + self._config_data.get('groups'), hostvars[host], host, strict) # constructed groups based on jinja expressions self._add_host_to_keyed_groups( - self._config_data.get('keyed_groups'), hostvars[host], host) + self._config_data.get('keyed_groups'), hostvars[host], host, strict) for group_name, group_hosts in groups.items(): gname = self.inventory.add_group(group_name)