Init
This commit is contained in:
commit
48d940b117
4
handlers/main.yml
Normal file
4
handlers/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- name: reload systemd
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
35
tasks/main.yml
Normal file
35
tasks/main.yml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
---
|
||||||
|
- name: Ensure sendmail is present
|
||||||
|
get_url:
|
||||||
|
url: "https://git.abbiamoundominio.org/blallo/sendmail/releases/download/{{ sendmail.version }}/sendmail"
|
||||||
|
dest: /usr/local/bin/sendmail
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Ensure sendmail template is present
|
||||||
|
template:
|
||||||
|
src: templates/sendmail.toml.j2
|
||||||
|
dest: /etc/sendmail.toml
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
vars:
|
||||||
|
- sections: "{{ sendmail.configuration }}"
|
||||||
|
|
||||||
|
- name: Ensure notify_unit_failure.sh is present
|
||||||
|
template:
|
||||||
|
src: templates/notify_unit_failure.sh
|
||||||
|
dest: /usr/local/bin/notify_unit_failure.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Ensure notify-failure@.service is present
|
||||||
|
template:
|
||||||
|
src: templates/notify-failure@.service.j2
|
||||||
|
dest: /etc/systemd/system/notify-failure@.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: reload systemd
|
9
templates/notify-failure@.service.j2
Normal file
9
templates/notify-failure@.service.j2
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=notify failure of %i unit via mail
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/local/bin/notify_unit_failure.sh %i
|
||||||
|
|
||||||
|
|
||||||
|
# vim: set ft=dosini:
|
16
templates/notify_unit_failure.sh
Executable file
16
templates/notify_unit_failure.sh
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
INVOCATION_ID=$(systemctl show -p InvocationID --value ${1}.service)
|
||||||
|
|
||||||
|
cat << EOM | sendmail \
|
||||||
|
-section unit_failure \
|
||||||
|
-sub "[UNIT-FAILURE|$(hostname)] ${1}"
|
||||||
|
The unit ${1}.service just failed
|
||||||
|
Date: $(date)
|
||||||
|
|
||||||
|
---
|
||||||
|
$(journalctl _SYSTEMD_INVOCATION_ID=${INVOCATION_ID})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EOM
|
17
templates/sendmail.toml.j2
Normal file
17
templates/sendmail.toml.j2
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{% for section in sections %}
|
||||||
|
[{{ section.name }}]
|
||||||
|
{% if section.from is defined %}
|
||||||
|
from = "{{ section.from }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if section.to_list is defined %}
|
||||||
|
to = {{ section.to_list }}
|
||||||
|
{% endif %}
|
||||||
|
[{{ section.name }}.server]
|
||||||
|
address = "{{ section.server.address }}"
|
||||||
|
port = {{ section.server.port }}
|
||||||
|
user = "{{ section.server.user }}"
|
||||||
|
password = "{{ section.server.password }}"
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
# vim: set ft=toml et sw=0 ts=2 sts=0:
|
Loading…
Reference in New Issue
Block a user