diff --git a/changelogs/fragments/inventory_manager_fix_required_options_override.yaml b/changelogs/fragments/inventory_manager_fix_required_options_override.yaml new file mode 100644 index 00000000000..30c4565ff7e --- /dev/null +++ b/changelogs/fragments/inventory_manager_fix_required_options_override.yaml @@ -0,0 +1,5 @@ +--- +bugfixes: +- inventory manager - This fixes required options being populated before the + inventory config file is read, so the required options may be set in the + config file. diff --git a/lib/ansible/inventory/manager.py b/lib/ansible/inventory/manager.py index b307d460827..2efc67aa942 100644 --- a/lib/ansible/inventory/manager.py +++ b/lib/ansible/inventory/manager.py @@ -183,7 +183,6 @@ class InventoryManager(object): for name in C.INVENTORY_ENABLED: plugin = inventory_loader.get(name) if plugin: - plugin.set_options() self._inventory_plugins.append(plugin) else: display.warning('Failed to load inventory plugin, skipping %s' % name) diff --git a/lib/ansible/plugins/inventory/script.py b/lib/ansible/plugins/inventory/script.py index 0876649331e..8bc1de73116 100644 --- a/lib/ansible/plugins/inventory/script.py +++ b/lib/ansible/plugins/inventory/script.py @@ -85,6 +85,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable): def parse(self, inventory, loader, path, cache=None): super(InventoryModule, self).parse(inventory, loader, path) + self.set_options() if cache is None: cache = self.get_option('cache') diff --git a/lib/ansible/plugins/inventory/yaml.py b/lib/ansible/plugins/inventory/yaml.py index 5983ce06749..436dbb6bdb4 100644 --- a/lib/ansible/plugins/inventory/yaml.py +++ b/lib/ansible/plugins/inventory/yaml.py @@ -90,6 +90,7 @@ class InventoryModule(BaseFileInventoryPlugin): ''' parses the inventory file ''' super(InventoryModule, self).parse(inventory, loader, path) + self.set_options() try: data = self.loader.load_from_file(path, cache=False)