# Role Handler Separation

**URL:** <https://forum.ansible.com/t/role-handler-separation/38683>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 8, 2024, 11:41pm UTC](https://forum.ansible.com/t/role-handler-separation/38683 "2024-02-08T23:41:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcpetro](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jcpetro](https://forum.ansible.com/u/jcpetro)\
**Post date:** [February 8, 2024, 11:41pm UTC](https://forum.ansible.com/t/role-handler-separation/38683/1 "2024-02-08T23:41:37Z")

</div>

Good Evening… A coworker of mine is working on finishing up a role, that may be use across multiple operating systems. We were wondering, if there was a way to separate the handler files into files based on OS, that are only parsed when you are running the role against that particular OS.

For example, if you were running the role against a windows server, the handler would be in windows.yml, or if it was debian, then the handler would be in Debian.yml.

I know how to do this for the tasks files, but wasn’t sure if this was possible for handlers files.

–John

---

<div class="post-metadata">

**Author:** ![Vinay\_Mulugund](https://avatars.discourse-cdn.com/v4/letter/v/53a042/32.png) [@Vinay\_Mulugund](https://forum.ansible.com/u/Vinay_Mulugund)\
**Post date:** [February 9, 2024, 8:06am UTC](https://forum.ansible.com/t/role-handler-separation/38683/2 "2024-02-09T08:06:42Z")

</div>

This seems similar to something you are looking for:  
[https://stackoverflow.com/questions/75134796/ansible-handlers-per-operating-system-with-same-name](https://stackoverflow.com/questions/75134796/ansible-handlers-per-operating-system-with-same-name)

---

<div class="post-metadata">

**Author:** ![Daniel\_Barros](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@Daniel\_Barros](https://forum.ansible.com/u/Daniel_Barros)\
**Post date:** [February 9, 2024, 4:59pm UTC](https://forum.ansible.com/t/role-handler-separation/38683/3 "2024-02-09T16:59:08Z")

</div>

Would something like that help?

---

<div class="post-metadata">

**Author:** ![jcpetro](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jcpetro](https://forum.ansible.com/u/jcpetro)\
**Post date:** [February 14, 2024, 8:24pm UTC](https://forum.ansible.com/t/role-handler-separation/38683/4 "2024-02-14T20:24:09Z")

</div>

I did see that… I have to go back and try it again, but I think it was still reading in all of the handlers for some reason. I did think about just putting the handler in that tasks file too… hadn’t yet tried that one, but I am pretty sure that would work too.
