From 699bbcc1d42ab407157bab52889f301ca2715d40 Mon Sep 17 00:00:00 2001 From: roysav Date: Sun, 19 May 2024 11:59:57 +0300 Subject: [PATCH] load extra vars in generator inventory plugin --- lib/ansible/plugins/inventory/generator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/plugins/inventory/generator.py b/lib/ansible/plugins/inventory/generator.py index ba697dfca62..cfd2d3de3c1 100644 --- a/lib/ansible/plugins/inventory/generator.py +++ b/lib/ansible/plugins/inventory/generator.py @@ -77,6 +77,7 @@ from itertools import product from ansible import constants as C from ansible.errors import AnsibleParserError from ansible.plugins.inventory import BaseInventoryPlugin +from ansible.utils.vars import load_extra_vars class InventoryModule(BaseInventoryPlugin): @@ -124,9 +125,12 @@ class InventoryModule(BaseInventoryPlugin): config = self._read_config_data(path) + extra_vars = load_extra_vars(loader) + template_inputs = product(*config['layers'].values()) for item in template_inputs: template_vars = dict() + template_vars.update(extra_vars) for i, key in enumerate(config['layers'].keys()): template_vars[key] = item[i] host = self.template(config['hosts']['name'], template_vars)