Skip to content

Commit

Permalink
Fix using FQCN for flush_handlers (ansible#79057)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrizek authored and kosalaat committed Nov 16, 2022
1 parent eb165e3 commit 180d70d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/79023-fix-flush_handlers-fqcn.yml
Original file line number Diff line number Diff line change
@@ -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)"
2 changes: 1 addition & 1 deletion lib/ansible/plugins/strategy/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _get_next_task_lockstep(self, hosts, iterator):
# 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

Expand Down
4 changes: 4 additions & 0 deletions test/integration/targets/handlers/runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 180d70d

Please sign in to comment.