|
|
|
@ -30,6 +30,41 @@
|
|
|
|
|
- "handler1_called is defined"
|
|
|
|
|
- "handler2_called is not defined"
|
|
|
|
|
|
|
|
|
|
- name: make a tempfile for counting
|
|
|
|
|
shell: mktemp
|
|
|
|
|
register: mktemp_out
|
|
|
|
|
|
|
|
|
|
- name: register tempfile path
|
|
|
|
|
set_fact:
|
|
|
|
|
handler_countpath: "{{ mktemp_out.stdout }}"
|
|
|
|
|
|
|
|
|
|
- name: notify the counting handler
|
|
|
|
|
shell: echo
|
|
|
|
|
notify:
|
|
|
|
|
- count_handler
|
|
|
|
|
|
|
|
|
|
- name: notify the counting handler again
|
|
|
|
|
shell: echo
|
|
|
|
|
notify:
|
|
|
|
|
- count_handler
|
|
|
|
|
|
|
|
|
|
- name: force handler execution now
|
|
|
|
|
meta: flush_handlers
|
|
|
|
|
|
|
|
|
|
- name: get handler execution count
|
|
|
|
|
shell: cat {{ handler_countpath }} | grep -o . | wc -l
|
|
|
|
|
register: exec_count_out
|
|
|
|
|
|
|
|
|
|
- debug: var=exec_count_out.stdout
|
|
|
|
|
|
|
|
|
|
- name: ensure single execution
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- exec_count_out.stdout | int == 1
|
|
|
|
|
|
|
|
|
|
- name: cleanup tempfile
|
|
|
|
|
file: path={{ handler_countpath }} state=absent
|
|
|
|
|
|
|
|
|
|
- name: reset handler1_called
|
|
|
|
|
set_fact:
|
|
|
|
|
handler1_called: False
|
|
|
|
|