2019-06-27 23:29:20 +02:00
|
|
|
- name: test templated values in handlers
|
|
|
|
hosts: localhost
|
|
|
|
gather_facts: no
|
|
|
|
vars:
|
|
|
|
handler1: name1
|
|
|
|
handler2: name2
|
|
|
|
handler3: name3
|
|
|
|
handler4: name4
|
2020-02-08 18:41:06 +01:00
|
|
|
handler_list:
|
|
|
|
- name5
|
|
|
|
- name6
|
2019-06-27 23:29:20 +02:00
|
|
|
|
|
|
|
handlers:
|
|
|
|
- name: name1
|
|
|
|
set_fact:
|
|
|
|
non_templated_name: True
|
|
|
|
- name: "{{ handler2 }}"
|
|
|
|
set_fact:
|
|
|
|
templated_name: True
|
|
|
|
- name: testlistener1
|
|
|
|
set_fact:
|
|
|
|
non_templated_listener: True
|
|
|
|
listen: name3
|
|
|
|
- name: testlistener2
|
|
|
|
set_fact:
|
|
|
|
templated_listener: True
|
|
|
|
listen: "{{ handler4 }}"
|
2020-02-08 18:41:06 +01:00
|
|
|
- name: name5
|
|
|
|
set_fact:
|
|
|
|
handler5: True
|
|
|
|
- set_fact:
|
|
|
|
handler6: True
|
|
|
|
listen: name6
|
2019-06-27 23:29:20 +02:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- command: echo Hello World
|
|
|
|
notify:
|
|
|
|
- "{{ handler1 }}"
|
|
|
|
- "{{ handler2 }}"
|
|
|
|
- "{{ handler3 }}"
|
|
|
|
- "{{ handler4 }}"
|
|
|
|
|
|
|
|
- meta: flush_handlers
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- non_templated_name is defined
|
|
|
|
- templated_name is defined
|
|
|
|
- non_templated_listener is defined
|
|
|
|
- templated_listener is undefined
|
|
|
|
|
2020-02-08 18:41:06 +01:00
|
|
|
- command: echo
|
|
|
|
notify: "{{ handler_list }}"
|
|
|
|
|
|
|
|
- meta: flush_handlers
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- handler5 is defined
|
|
|
|
- handler6 is defined
|
|
|
|
|
2019-06-27 23:29:20 +02:00
|
|
|
- include_role: name=test_templating_in_handlers
|