Fix setting required options for inventory plugins - backport/2.6/42049 (#42120)

* Fix setting required options for inventory plugins (#42049)

* Fix setting required options for inventory plugins

* call set_options for yaml and script plugin

(cherry picked from commit 44e5886385)

* changelog
pull/42223/head
Sloane Hertel 6 years ago committed by Matt Clay
parent 3cbf319ee7
commit 851725d72a

@ -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.

@ -183,7 +183,6 @@ class InventoryManager(object):
for name in C.INVENTORY_ENABLED: for name in C.INVENTORY_ENABLED:
plugin = inventory_loader.get(name) plugin = inventory_loader.get(name)
if plugin: if plugin:
plugin.set_options()
self._inventory_plugins.append(plugin) self._inventory_plugins.append(plugin)
else: else:
display.warning('Failed to load inventory plugin, skipping %s' % name) display.warning('Failed to load inventory plugin, skipping %s' % name)

@ -85,6 +85,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
def parse(self, inventory, loader, path, cache=None): def parse(self, inventory, loader, path, cache=None):
super(InventoryModule, self).parse(inventory, loader, path) super(InventoryModule, self).parse(inventory, loader, path)
self.set_options()
if cache is None: if cache is None:
cache = self.get_option('cache') cache = self.get_option('cache')

@ -90,6 +90,7 @@ class InventoryModule(BaseFileInventoryPlugin):
''' parses the inventory file ''' ''' parses the inventory file '''
super(InventoryModule, self).parse(inventory, loader, path) super(InventoryModule, self).parse(inventory, loader, path)
self.set_options()
try: try:
data = self.loader.load_from_file(path, cache=False) data = self.loader.load_from_file(path, cache=False)

Loading…
Cancel
Save