Debian Codegraph @

test/integration/targets/handlers/roles/test_handlers/tasks/main.yml

raw
1 # test code for the async keyword
2 # (c) 2014, James Tanner <[email protected]>
3
4 # This file is part of Ansible
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18
19
20 - name: reset handler_called variable to false for all hosts
21 set_fact:
22 handler_called: False
23 tags: scenario1
24
25 - name: notify the handler for host A only
26 shell: echo
27 notify:
28 - set handler fact
29 when: inventory_hostname == 'A'
30 tags: scenario1
31
32 - name: force handler execution now
33 meta: "flush_handlers"
34 tags: scenario1
35
36 - debug: var=handler_called
37 tags: scenario1
38
39 - name: validate the handler only ran on one host
40 assert:
41 that:
42 - "inventory_hostname == 'A' and handler_called == True or handler_called == False"
43 tags: scenario1
44
45 - name: 'test notify with loop'
46 debug: msg='a task'
47 changed_when: item == 1
48 notify: test handler
49 with_items:
50 - 1
51 - 2
52 tags: scenario2