Hi Ansible people !
tl;dr : I’m wondering if there’s an elegant way to conditionally notify a handler (for example, only if it’s actually present as a handler in the role)
Here’s what I’m trying to do :
I have 2 kinds of servers using the same Django codebase : web servers running nginx+gunicorn, and offline tasks processors running a Celery task queue.
I made 3 Ansible roles : one for stuff that’s common to the 2 types of server (including updating the git repo), and 2 for the specific bits of each type.
And I’d like Unicorn to be notified/restarted after a git pull just on the web servers.
The obvious solution seems to be moving the git task out of the common role and into 2 slightly different tasks in each specific role, one with a notify and the other without, but that sounds like a lot of code duplication for such a small difference.
Any better way ?
Thanks !