# Want to send notification if no hosts match

**URL:** <https://forum.ansible.com/t/want-to-send-notification-if-no-hosts-match/31858>\
**Category:** Ansible Project\
**Created:** [December 20, 2019, 4:57pm UTC](https://forum.ansible.com/t/want-to-send-notification-if-no-hosts-match/31858 "2019-12-20T16:57:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bikram](https://avatars.discourse-cdn.com/v4/letter/b/f04885/32.png) [@Bikram](https://forum.ansible.com/u/Bikram)\
**Post date:** [December 20, 2019, 4:57pm UTC](https://forum.ansible.com/t/want-to-send-notification-if-no-hosts-match/31858/1 "2019-12-20T16:57:11Z")

</div>

Hi,

I have a use case where I am automating switch patching where engineers can select a switch name and playbook name from a web portal.  
I would to like to handle an exception if engineers select a wrong switch/playbook.

But the problem is all the tasks are skipped if engineers select a wrong switch or wrong playbook which is expected.

**But I want to make sure to send them a notification if this happens. Is there any way to do that?**

Thank you in advance.

Best wishes,  
Bikram

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 20, 2019, 7:17pm UTC](https://forum.ansible.com/t/want-to-send-notification-if-no-hosts-match/31858/2 "2019-12-20T19:17:13Z")

</div>

This is a very academic question. To avoid having to do hypothetical exercises and lots of guessing - please share your playbooks and the inventory that your “web portal” supplies (or any other relevant data).

In short we need more information.

At first glance this sounds like a problem that is out

---

<div class="post-metadata">

**Author:** ![Ankit2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Ankit2](https://forum.ansible.com/u/Ankit2)\
**Post date:** [December 23, 2019, 6:17am UTC](https://forum.ansible.com/t/want-to-send-notification-if-no-hosts-match/31858/3 "2019-12-23T06:17:22Z")

</div>

Check this.  
[https://docs.ansible.com/ansible/latest/modules/fail\_module.html](https://docs.ansible.com/ansible/latest/modules/fail_module.html)

You can perform custom actions when something fails. I guess there are also ways to control if your job needs to fail or skip to next. I havent tried it though, check out ansible docs.
