From d181bb0c8a90f083b00fb4f45e2e48cafc78463d Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Thu, 27 Aug 2020 10:34:22 -0400 Subject: [PATCH] Fix meta tasks used with --flush-cache (#71311) (#71359) * Remove incorrect code (cherry picked from commit 88bfc7977d958518d4efcf924a18f784313288aa) --- changelogs/fragments/fix_meta_tasks_with_flush_cache.yml | 2 ++ lib/ansible/plugins/strategy/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/fix_meta_tasks_with_flush_cache.yml diff --git a/changelogs/fragments/fix_meta_tasks_with_flush_cache.yml b/changelogs/fragments/fix_meta_tasks_with_flush_cache.yml new file mode 100644 index 00000000000..83c05ae8a81 --- /dev/null +++ b/changelogs/fragments/fix_meta_tasks_with_flush_cache.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix execution of the meta tasks 'clear_facts', 'clear_host_errors', 'end_play', 'end_host', and 'reset_connection' when the CLI flag '--flush-cache' is provided. diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 05f6d4f8130..7e4e4fff644 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -182,7 +182,6 @@ class StrategyBase: self._final_q = tqm._final_q self._step = context.CLIARGS.get('step', False) self._diff = context.CLIARGS.get('diff', False) - self.flush_cache = context.CLIARGS.get('flush_cache', False) # the task cache is a dictionary of tuples of (host.name, task._uuid) # used to find the original task object of in-flight tasks and to store @@ -1103,6 +1102,7 @@ class StrategyBase: skipped = False msg = '' + # The top-level conditions should only compare meta_action if meta_action == 'noop': # FIXME: issue a callback for the noop here? if task.when: @@ -1115,7 +1115,7 @@ class StrategyBase: self.run_handlers(iterator, play_context) self._flushed_hosts[target_host] = False msg = "ran handlers" - elif meta_action == 'refresh_inventory' or self.flush_cache: + elif meta_action == 'refresh_inventory': if task.when: self._cond_not_supported_warn(meta_action) self._inventory.refresh_inventory()