Would something like that help?

---
- name: Playbook Temp
  hosts: localhost
  gather_facts: true
  vars:
    restart_svcs:
      Debian: Restart Debian service
      RedHat: Restart RedHat service

  handlers:
    - name: Restart Debian service
      ansible.builtin.debug:
        msg: "some debian command"

    - name: Restart RedHat service
      ansible.builtin.debug:
        msg: "some red hat command"

  tasks:
    - name: Change File
      ansible.builtin.debug:
        msg: "Simulate file change"
      changed_when: true
      notify: "{{ restart_svcs[ansible_os_family] }}"

On Thursday, February 8, 2024 at 8:42:06 PM UTC-3 John Petro wrote:

> 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
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b5f1aa44-3c9d-461b-9c81-98b77dbc2394n%40googlegroups.com.

Reply via email to