ansible_pull(role): add failure notifications
Some checks failed
/ Ansible Lint (push) Failing after 48s
Some checks failed
/ Ansible Lint (push) Failing after 48s
This commit is contained in:
parent
17fd71f079
commit
eadae7a09b
8 changed files with 48 additions and 3 deletions
|
@ -0,0 +1,7 @@
|
|||
[Unit]
|
||||
Description=ansible-pull failure notifier
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/sbin/ansible-pull-failure-notify.sh
|
||||
User=root
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Ideally we would use --invocation instead of --since, but this isn't supported in the systemd version Debian 12 ships.
|
||||
ANSIBLE_PULL_LOG=$(journalctl --unit=ansible-pull --identifier=ansible-pull --since=-6h --output=cat)
|
||||
|
||||
MESSAGE="Subject: [{{ inventory_hostname }}] ansible-pull: execution failure
|
||||
|
||||
An error occured during the ansible-pull execution.
|
||||
|
||||
Logs:
|
||||
""$ANSIBLE_PULL_LOG""
|
||||
|
||||
To view the logs yourself run:
|
||||
journalctl --unit=ansible-pull --identifier=ansible-pull -e
|
||||
"
|
||||
|
||||
printf "$MESSAGE" | msmtp '{{ ansible_pull__failure_notification_address }}'
|
|
@ -2,6 +2,7 @@
|
|||
Description=ansible-pull for configuration and maintenance
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
OnFailure=ansible-pull-failure-notify.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue