From 8e0133885a99bbd8c20f541d9eefea9ff2f37737 Mon Sep 17 00:00:00 2001 From: Robin Parker Date: Fri, 22 Nov 2024 00:09:30 +0100 Subject: [PATCH] Inventory plugin: Allow "parent_group" to have host variables in it Allow to build up multi-hierarchy group-structure by arbitary inventory-plugins. e.g. Provider -> Site1 -> Datacenter1 or Provider -> Zone -> DatacenterName where Zone and Site are dynamically given. --- lib/ansible/plugins/inventory/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/plugins/inventory/__init__.py b/lib/ansible/plugins/inventory/__init__.py index 324234cb7ec..292f80dc5ff 100644 --- a/lib/ansible/plugins/inventory/__init__.py +++ b/lib/ansible/plugins/inventory/__init__.py @@ -407,7 +407,7 @@ class Constructable(object): raw_parent_name = keyed.get('parent_group', None) if raw_parent_name: try: - raw_parent_name = self.templar.template(raw_parent_name) + raw_parent_name = self.templar.template(raw_parent_name, variables) except AnsibleError as e: if strict: raise AnsibleParserError("Could not generate parent group %s for group %s: %s" % (raw_parent_name, key, to_native(e)))