inventory manager respect --flush-cache (#77083)

pull/77320/head
Brian Coca 2 years ago committed by GitHub
parent c9db73f04e
commit 94b73d66d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- inventory manager now respects --flush-cache

@ -503,7 +503,7 @@ class CLI(ABC):
loader.set_vault_secrets(vault_secrets)
# create the inventory, and filter it based on the subset specified (if any)
inventory = InventoryManager(loader=loader, sources=options['inventory'])
inventory = InventoryManager(loader=loader, sources=options['inventory'], cache=(not options.get('flush_cache')))
# create the variable manager, which will be shared throughout
# the code, ensuring a consistent view of global variables

@ -140,7 +140,7 @@ def split_host_pattern(pattern):
class InventoryManager(object):
''' Creates and manages inventory '''
def __init__(self, loader, sources=None, parse=True):
def __init__(self, loader, sources=None, parse=True, cache=True):
# base objects
self._loader = loader
@ -164,7 +164,7 @@ class InventoryManager(object):
# get to work!
if parse:
self.parse_sources(cache=True)
self.parse_sources(cache=cache)
@property
def localhost(self):
@ -336,7 +336,6 @@ class InventoryManager(object):
''' clear all caches '''
self._hosts_patterns_cache = {}
self._pattern_cache = {}
# FIXME: flush inventory cache
def refresh_inventory(self):
''' recalculate inventory '''

Loading…
Cancel
Save