-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmd-check.yml
43 lines (41 loc) · 1.19 KB
/
md-check.yml
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
43
- name: Get mdadm status and send an email
hosts: all
tasks:
- name: check if MD devices exist
stat:
path: /dev/md
register: md_exists
- name: MDADM checks
block:
- name: mdadm check
become: yes
command: >
mdadm -D /dev/md0
register: md_status
- name: Send an email if there is a failure registered
mail:
host: 10.0.0.4
port: 25
from: [email protected]
subject: Ansible MDADM Alert!!!
body: |
This is an ansible test email from {{ ansible_hostname }}
Mdadm status:
{{ md_status }}
delegate_to: home-pc
when: '"FAILURE" in md_status.stdout[0]'
- name: Send an email if there is a faulty device registered
mail:
host: 10.0.0.4
port: 25
from: [email protected]
subject: Ansible MDADM Alert!!!
body: |
This is an ansible test email from {{ ansible_hostname }}
Mdadm status:
{{ md_status }}
delegate_to: home-pc
when: '"degraded" in md_status.stdout[0]'
when: md_exists.stat.exists