Files
personal_ansible_pub/playbooks/send_failure_alert.yml
2023-07-10 10:41:17 +03:00

31 lines
1.1 KiB
YAML

- block:
- name: send failure notification via telegram
tags: always
telegram:
token: "{{ telegram_token }}"
chat_id: "{{ telegram_chat_id }}"
msg_format: markdown
msg: "⚠️ Ansible provision failed on *{{ ansible_hostname }}*\n\n
*Task*: {{ ansible_failed_task.name }}\n
*Action*: {{ ansible_failed_task.action }}\n
*Error Message*: \n ```{{ ansible_failed_result | to_nice_json }}```"
changed_when: False
rescue:
- name: send failure notification via telegram
tags: always
telegram:
token: "{{ telegram_token }}"
chat_id: "{{ telegram_chat_id }}"
msg_format: markdown
msg: "⚠️ Ansible provision failed on *{{ ansible_hostname }}*\n\n
The specific error couldn't be shown, check the log."
changed_when: False
- name: ansible job failed, clear cache later on to trigger another provision run
become: yes
at:
command: "if ! pgrep -f ansible-pull >/dev/null; then rm -rf /home/simone/.ansible; fi"
count: 60
units: minutes