Host variables - Add the "all" group if it's not listed

This commit is contained in:
Emmanuel BENOîT 2022-11-05 10:54:53 +01:00
parent 8c0245ed18
commit 31e5e93d37
No known key found for this signature in database
GPG key ID: 2356DC6956CF54EF

View file

@ -1083,7 +1083,10 @@ class InventoryModule(BaseInventoryPlugin):
"""
host_obj = self.inventory.get_host(host)
host_vars = host_obj.get_vars()
group_vars = get_group_vars(host_obj.get_groups())
host_groups = host_obj.get_groups().copy()
if not any(g.name == "all" for g in host_groups):
host_groups.append(self.inventory.groups["all"])
group_vars = get_group_vars(host_groups)
variables = VariableStorage(combine_vars(group_vars, host_vars))
for instruction in instructions:
if not instruction.run_for(host, variables):