mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-07 17:51:29 -07:00
Fix inventory cache interface (#50446)
* Replace InventoryFileCacheModule with a better developer-interface Use new interface for inventory plugins with backwards compatibility Auto-update the backing cache-plugin if the cache has changed after parsing the inventory plugin * Update CacheModules to use the config system and add a deprecation warning if they are being imported directly rather than using cache_loader * Fix foreman inventory caching * Add tests * Add integration test to check that fact caching works normally with cache plugins using ansible.constants and inventory caching provides a helpful error for non-compatible cache plugins * Add some developer documentation for inventory and cache plugins * Add user documentation for inventory caching * Add deprecation docs * Apply suggestions from docs review * Add changelog
This commit is contained in:
parent
831f068f98
commit
9687879840
24 changed files with 831 additions and 86 deletions
|
@ -116,7 +116,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
|||
if not self.use_cache or url not in self._cache.get(self.cache_key, {}):
|
||||
|
||||
if self.cache_key not in self._cache:
|
||||
self._cache[self.cache_key] = {'url': ''}
|
||||
self._cache[self.cache_key] = {url: ''}
|
||||
|
||||
results = []
|
||||
s = self._get_session()
|
||||
|
@ -153,7 +153,9 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
|||
# get next page
|
||||
params['page'] += 1
|
||||
|
||||
self._cache[self.cache_key][url] = results
|
||||
# Set the cache if it is enabled or if the cache was refreshed
|
||||
if self.use_cache or self.get_option('cache'):
|
||||
self._cache[self.cache_key][url] = results
|
||||
|
||||
return self._cache[self.cache_key][url]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue