Is it possible in Ansible to conditionally notify handlers only if they are present in that play?
For example: I have a playbook for multiple host configurations. Some hosts run PHP with Apache and some with PHP-FPM. Depending upon the host, different handlers need running when PHP is modifued.
This is a simple example of the issue:
- name: copy php.ini
copy:
src=roles/php/templates/{{ php_template }}/php.ini
dest=/etc/
notify:
- reload php-fpm
- reload apache
Obviously, what I want to do is notify the correct software to reload when the php.ini file changes. However Ansible gives an error because only one of the handlers is present in the play at any time e.g:
ERROR: change handler (reload php-fpm) is not defined
Is there a way to achieve this without creating errors or duplicating Ansible code?
Thanks in advance