|
|
|
@ -156,14 +156,19 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|
|
|
|
if 'clouds' in self._config_data:
|
|
|
|
|
self._config_data = {}
|
|
|
|
|
|
|
|
|
|
# update cache if the user has caching enabled and the cache is being refreshed
|
|
|
|
|
# will update variable below in the case of an expired cache
|
|
|
|
|
cache_needs_update = not cache and self.get_option('cache')
|
|
|
|
|
|
|
|
|
|
if cache:
|
|
|
|
|
cache = self.get_option('cache')
|
|
|
|
|
source_data = None
|
|
|
|
|
if cache:
|
|
|
|
|
try:
|
|
|
|
|
source_data = self.cache.get(cache_key)
|
|
|
|
|
source_data = self._cache[cache_key]
|
|
|
|
|
except KeyError:
|
|
|
|
|
pass
|
|
|
|
|
# cache expired or doesn't exist yet
|
|
|
|
|
cache_needs_update = True
|
|
|
|
|
|
|
|
|
|
if not source_data:
|
|
|
|
|
clouds_yaml_path = self._config_data.get('clouds_yaml_path')
|
|
|
|
@ -199,8 +204,8 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|
|
|
|
source_data = cloud_inventory.list_hosts(
|
|
|
|
|
expand=expand_hostvars, fail_on_cloud_config=fail_on_errors)
|
|
|
|
|
|
|
|
|
|
if self.cache is not None:
|
|
|
|
|
self.cache.set(cache_key, source_data)
|
|
|
|
|
if cache_needs_update:
|
|
|
|
|
self._cache[cache_key] = source_data
|
|
|
|
|
|
|
|
|
|
self._populate_from_source(source_data)
|
|
|
|
|
|
|
|
|
|