-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlers
42 lines (40 loc) · 844 Bytes
/
handlers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
- name: Playbook to check a package
hosts: all
become: yes
tasks:
- name: check for package
apt:
name: apache2
state: present
register: value_1
- name: call handler a
shell:
cmd: echo ""
notify: a
when: value_1 is failed
- name: check for service
service:
name: apache2
state: started
register: value_2
- name: call handler b
shell:
cmd: echo ""
notify: b
when: value_2 is failed
- name: call handler c
shell:
cmd: echo ""
notify: c
when: value_1 is failed and value_2 is failed
handlers:
- name: a
debug:
msg: "Installation failed"
- name: b
debug:
msg: "Service failed"
- name: c
debug:
msg: "Playbook was unsuccessful"