Win_Service not working in handler?

Hi,

I am running a playbook with a task that calls a handler like so:
`

  • name: “Configure zabbix-agent”
    win_template:
    src: zabbix_agentd.conf.j2
    dest: C:\Program Files\Zabbix Agent\zabbix_agentd.conf
    newline_sequence: ‘\n’
    trim_blocks: no
    notify: restart zabbix-agent
    `

The handler itself is:

`

  • name: restart zabbix-agent
    win_service:
    name: Zabbix Agent
    state: restarted
    start_mode: auto
    `

When I run the playbook there are no errors, but when it reaches the end there is no mention of the handler and it doesn’t run.

The funny thing is, when I use the Linux equivalent and run it on a Linux host, it does work:

`

  • name: restart zabbix-agent
    service: name={{ zabbix_agent_service }}
    state=restarted
    enabled=yes
    become: yes

`

I could just set it as a task, but I don’t want the playbook to restart the service every time it runs, just when something changed.
Any help appreciated

is “Configure zabbix-agent” reporting a change ?

Is zabbix_agentd.conf being updated.

Since you have spaces in the dest, I think you might need to quote the dest like this

dest: 'C:\Program Files\Zabbix Agent\zabbix_agentd.conf'

( Use single quotes - ' ' not double quotes " " - if you use double quotes you have to have double backslashes like this:

dest: "C:\\Program Files\\Zabbix Agent\\zabbix_agentd.conf"

Hope this helps,

Jon