avoid caching invetnory sources in loader (#38242)
* fix inventory plugin source caching
- avoid caching invetnory sources in loader in base
- same fix for yaml plugin
- idem for 'auto' plugin
fixes #37162
* fix mock dataloader func sig
(cherry picked from commit 886c4edfb9
)
This commit is contained in:
parent
a3798d9b62
commit
d31d84cfa3
5 changed files with 7 additions and 6 deletions
|
@ -172,7 +172,9 @@ class BaseInventoryPlugin(AnsiblePlugin):
|
|||
|
||||
config = {}
|
||||
try:
|
||||
config = self.loader.load_from_file(path)
|
||||
# avoid loader cache so meta: refresh_inventory can pick up config changes
|
||||
# if we read more than once, fs cache should be good enough
|
||||
config = self.loader.load_from_file(path, cache=False)
|
||||
except Exception as e:
|
||||
raise AnsibleParserError(to_native(e))
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
return super(InventoryModule, self).verify_file(path)
|
||||
|
||||
def parse(self, inventory, loader, path, cache=True):
|
||||
config_data = loader.load_from_file(path)
|
||||
config_data = loader.load_from_file(path, cache=False)
|
||||
|
||||
plugin_name = config_data.get('plugin')
|
||||
|
||||
|
|
|
@ -104,8 +104,7 @@ class InventoryModule(BaseFileInventoryPlugin):
|
|||
self._filename = path
|
||||
|
||||
try:
|
||||
# Read in the hosts, groups, and variables defined in the
|
||||
# inventory file.
|
||||
# Read in the hosts, groups, and variables defined in the inventory file.
|
||||
if self.loader:
|
||||
(b_data, private) = self.loader._get_file_contents(path)
|
||||
else:
|
||||
|
|
|
@ -91,7 +91,7 @@ class InventoryModule(BaseFileInventoryPlugin):
|
|||
super(InventoryModule, self).parse(inventory, loader, path)
|
||||
|
||||
try:
|
||||
data = self.loader.load_from_file(path)
|
||||
data = self.loader.load_from_file(path, cache=False)
|
||||
except Exception as e:
|
||||
raise AnsibleParserError(e)
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class DictDataLoader(DataLoader):
|
|||
self._build_known_directories()
|
||||
self._vault_secrets = None
|
||||
|
||||
def load_from_file(self, path, unsafe=False):
|
||||
def load_from_file(self, path, cache=True, unsafe=False):
|
||||
if path in self._file_mapping:
|
||||
return self.load(self._file_mapping[path], path)
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue