Want to send notification if no hosts match

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

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

Check this.
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.