Fix conditionally notified include handlers (#79804)

Fixes #79776

ci_complete
pull/79810/head
Martin Krizek 1 year ago committed by GitHub
parent c9f20aedc0
commit 10eda5801a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix conditionally notifying ``include_tasks` handlers when ``force_handlers`` is used (https://github.com/ansible/ansible/issues/79776)

@ -313,11 +313,7 @@ class StrategyModule(StrategyBase):
included_tasks.extend(final_block.get_tasks())
for host in hosts_left:
# handlers are included regardless of _hosts so noop
# tasks do not have to be created for lockstep,
# not notified handlers are then simply skipped
# in the PlayIterator
if host in included_file._hosts or is_handler:
if host in included_file._hosts:
all_blocks[host].append(final_block)
display.debug("done iterating over new_blocks loaded from include file")

@ -0,0 +1,2 @@
- debug:
msg: "Handler for {{ inventory_hostname }}"

@ -0,0 +1,10 @@
- hosts: A,B
gather_facts: false
force_handlers: true
tasks:
- command: echo
notify: handler1
when: inventory_hostname == "A"
handlers:
- name: handler1
include_tasks: 79776-handlers.yml

@ -170,3 +170,5 @@ ansible-playbook test_flush_handlers_rescue_always.yml -i inventory.handlers "$@
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"
ansible-playbook 79776.yml -i inventory.handlers "$@"

Loading…
Cancel
Save