# conditional handlers?

**URL:** <https://forum.ansible.com/t/conditional-handlers/20852>\
**Category:** Ansible Project\
**Created:** [March 12, 2016, 10:58pm UTC](https://forum.ansible.com/t/conditional-handlers/20852 "2016-03-12T22:58:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rob](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@rob](https://forum.ansible.com/u/rob)\
**Post date:** [March 12, 2016, 10:58pm UTC](https://forum.ansible.com/t/conditional-handlers/20852/1 "2016-03-12T22:58:49Z")

</div>

A common issue I run into is, depending on group or host vars, I might make a configuration change to say php.ini or add php modules and want to reload relevant php services that arent always the same - this might be restarting httpd for mod\_php on one host or it might be php-fpm or maybe both if we have nginx installed in front of apache.

I decided to write a meta role for handling this, so I can have this meta-role as dependency in another role and notify it to restart the relevant service if it exists and is running. So if I have a role for making a php change and I want it to reload php-fpm if its installed or httpd if its installed how should I go about this?

What I was trying to do is in the meta role have a few tasks that register variables based on shell command with ps and grep. Then use the result of the variable in the handler with a where clause but thats not allowed in a handler.

Any advice for how I should alternatively approach this?
