mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-30 21:09:09 -07:00
Fix errors on 'ansible-playbook --flush-cache' (#18754)
Add a unit test, and split out the flush cache logic to it's own method. Fixes #18708
This commit is contained in:
parent
6c4f554f5a
commit
08a5d506bb
2 changed files with 46 additions and 2 deletions
|
@ -148,8 +148,7 @@ class PlaybookCLI(CLI):
|
|||
|
||||
# flush fact cache if requested
|
||||
if self.options.flush_cache:
|
||||
for host in inventory.list_hosts():
|
||||
variable_manager.clear_facts(host)
|
||||
self._flush_cache(inventory, variable_manager)
|
||||
|
||||
# create the playbook executor, which manages running the plays via a task queue manager
|
||||
pbex = PlaybookExecutor(playbooks=self.args, inventory=inventory, variable_manager=variable_manager, loader=loader, options=self.options, passwords=passwords)
|
||||
|
@ -218,3 +217,8 @@ class PlaybookCLI(CLI):
|
|||
return 0
|
||||
else:
|
||||
return results
|
||||
|
||||
def _flush_cache(self, inventory, variable_manager):
|
||||
for host in inventory.list_hosts():
|
||||
hostname = host.get_name()
|
||||
variable_manager.clear_facts(hostname)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue