2018-12-28 11:23:49 +01:00
|
|
|
---
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Fetch rc.local content"
|
2020-10-14 16:32:32 +02:00
|
|
|
command: "grep -v '^#' /etc/rc.local"
|
|
|
|
check_mode: false
|
|
|
|
register: rclocal_content
|
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
|
|
|
tags:
|
2022-06-23 18:35:39 +02:00
|
|
|
- alerting
|
2020-10-14 16:32:32 +02:00
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Configure rc.local"
|
2018-12-28 11:23:49 +01:00
|
|
|
lineinfile:
|
|
|
|
path: /etc/rc.local
|
2020-06-04 18:51:53 +02:00
|
|
|
line:
|
|
|
|
'date | mail -s "boot/reboot of $(hostname -s)" {{ general_alert_email }}'
|
2020-10-08 15:19:52 +02:00
|
|
|
insertbefore: 'echo'
|
2022-04-13 16:57:39 +02:00
|
|
|
mode: "0640"
|
2020-06-01 11:37:15 +02:00
|
|
|
create: true
|
2020-10-14 16:32:32 +02:00
|
|
|
when:
|
2020-10-23 10:15:57 +02:00
|
|
|
- not (rclocal_content.stdout
|
|
|
|
| regex_search('date \| mail -s (\"|\')boot/reboot of \$\(hostname -s\)'))
|
2018-12-28 11:23:49 +01:00
|
|
|
tags:
|
2022-06-23 18:35:39 +02:00
|
|
|
- alerting
|
2018-12-28 11:23:49 +01:00
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Delete rc.local entry of boot/reboot not precising hostname"
|
2020-10-08 15:19:52 +02:00
|
|
|
lineinfile:
|
|
|
|
path: /etc/rc.local
|
|
|
|
regexp:
|
|
|
|
"^.* mail -s (?!.*of.*).+$"
|
|
|
|
state: absent
|
|
|
|
tags:
|
2022-06-23 18:35:39 +02:00
|
|
|
- alerting
|
2020-10-08 15:19:52 +02:00
|
|
|
|
2022-06-23 16:17:42 +02:00
|
|
|
- name: "Set root mail alias"
|
2018-12-28 11:23:49 +01:00
|
|
|
replace:
|
|
|
|
dest: /etc/mail/aliases
|
|
|
|
regexp: "# root:"
|
|
|
|
replace: "root: {{ general_alert_email }}"
|
2020-06-01 11:37:15 +02:00
|
|
|
backup: false
|
2018-12-28 11:23:49 +01:00
|
|
|
notify:
|
|
|
|
- newaliases
|
|
|
|
tags:
|
|
|
|
- mail
|