Win_Service not working in handler?

42 views
Skip to first unread message

Onallion

unread,
Jun 21, 2017, 10:35:05 AM6/21/17
to Ansible Project
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

David Baumann

unread,
Jun 21, 2017, 12:29:57 PM6/21/17
to Ansible Project
is "Configure zabbix-agent" reporting a change ?

J Hawkesworth

unread,
Jun 26, 2017, 1:24:58 AM6/26/17
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages