diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2022-10-06 16:23:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-06 09:23:49 -0500 |
commit | cd52ae459dd73991607a70956c844c711aae6b86 (patch) | |
tree | 12b82c15e19edbd6052479554f14b75871fd53db | |
parent | b5eba6488223776676c126e1d9239a0b862749a2 (diff) | |
download | ansible-cd52ae459dd73991607a70956c844c711aae6b86.tar.gz |
Fix using FQCN for flush_handlers (#79057) (#79061)
Fixes #79023
(cherry picked from commit e1daaae42af1a4e465edbdad4bb3c6dd7e7110d5)
4 files changed, 21 insertions, 1 deletions
diff --git a/changelogs/fragments/79023-fix-flush_handlers-fqcn.yml b/changelogs/fragments/79023-fix-flush_handlers-fqcn.yml new file mode 100644 index 0000000000..070bc72721 --- /dev/null +++ b/changelogs/fragments/79023-fix-flush_handlers-fqcn.yml @@ -0,0 +1,2 @@ +bugfixes: + - "handlers - fix an issue where the ``flush_handlers`` meta task could not be used with FQCN: ``ansible.builtin.meta`` (https://github.com/ansible/ansible/issues/79023)" diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index a9406a2074..dc34e097bb 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -118,7 +118,7 @@ class StrategyModule(StrategyBase): # once hosts synchronize on 'flush_handlers' lockstep enters # '_in_handlers' phase where handlers are run instead of tasks # until at least one host is in IteratingStates.HANDLERS - if (not self._in_handlers and cur_task.action == 'meta' and + if (not self._in_handlers and cur_task.action in C._ACTION_META and cur_task.args.get('_raw_params') == 'flush_handlers'): self._in_handlers = True diff --git a/test/integration/targets/handlers/runme.sh b/test/integration/targets/handlers/runme.sh index 1c597c6622..e2d521805f 100755 --- a/test/integration/targets/handlers/runme.sh +++ b/test/integration/targets/handlers/runme.sh @@ -166,3 +166,7 @@ ansible-playbook test_flush_handlers_rescue_always.yml -i inventory.handlers "$@ [ "$(grep out.txt -ce 'rescue ran')" = "1" ] [ "$(grep out.txt -ce 'always ran')" = "2" ] [ "$(grep out.txt -ce 'should run for both hosts')" = "2" ] + +ansible-playbook test_fqcn_meta_flush_handlers.yml -i inventory.handlers "$@" 2>&1 | tee out.txt +grep out.txt -e "handler ran" +grep out.txt -e "after flush" diff --git a/test/integration/targets/handlers/test_fqcn_meta_flush_handlers.yml b/test/integration/targets/handlers/test_fqcn_meta_flush_handlers.yml new file mode 100644 index 0000000000..f9c67cf56a --- /dev/null +++ b/test/integration/targets/handlers/test_fqcn_meta_flush_handlers.yml @@ -0,0 +1,14 @@ +- hosts: A + gather_facts: false + tasks: + - command: echo + notify: handler + + - ansible.builtin.meta: flush_handlers + + - debug: + msg: after flush + handlers: + - name: handler + debug: + msg: handler ran |