# Ansible playbook for host rebooted and started unexpectedly and send an alert

**URL:** <https://forum.ansible.com/t/ansible-playbook-for-host-rebooted-and-started-unexpectedly-and-send-an-alert/28785>\
**Category:** Ansible Project\
**Created:** [October 14, 2018, 8:56pm UTC](https://forum.ansible.com/t/ansible-playbook-for-host-rebooted-and-started-unexpectedly-and-send-an-alert/28785 "2018-10-14T20:56:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhtar.riaz](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@akhtar.riaz](https://forum.ansible.com/u/akhtar.riaz)\
**Post date:** [October 14, 2018, 8:56pm UTC](https://forum.ansible.com/t/ansible-playbook-for-host-rebooted-and-started-unexpectedly-and-send-an-alert/28785/1 "2018-10-14T20:56:30Z")

</div>

Hi All,

I am looking for ansible play book example to send alert to premetheus after a host has rebooted and re-started unexpeditly. Any help would be greatly appreciate it.

Thanks  
Riaz

---

<div class="post-metadata">

**Author:** ![Brad2](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Brad2](https://forum.ansible.com/u/Brad2)\
**Post date:** [October 15, 2018, 10:24am UTC](https://forum.ansible.com/t/ansible-playbook-for-host-rebooted-and-started-unexpectedly-and-send-an-alert/28785/2 "2018-10-15T10:24:15Z")

</div>

Not sure that is really an ansible task. I’m sure you could use ansible to set it up. I use this on my systems to get notification:  
`

cd /etc/systemd/system  
if [[! rebootsh.service]]; then  
cat \> rebootsh.service \<\< EOF  
[Unit]  
Description=Notify sys admin when the server gets rebooted  
After=network.target  
After=postfix.service

[Service]  
Type=simple  
ExecStart=/root/bin/reboot.sh  
TimeoutStartSec=0  
RemainAfterExit=no

[Install]  
WantedBy=rescue.target  
WantedBy=multi-user.target  
WantedBy=graphical.target  
EOF  
echo “Added the rebootsh service”  
chmod 444 rebootsh.service  
systemctl enable rebootsh.service  
else  
echo “Rebootsh.service already in place”  
fi

cd /root/bin  
if [[! -f reboot.sh]]; then  
cat \> reboot.sh \<\< EOF  
#!/bin/bash
