win_nssm task shows 'changed' for every run

30 views
Skip to first unread message

Joe Levis

unread,
Feb 3, 2016, 1:11:45 PM2/3/16
to Ansible Project
Ubuntu 14.04, Ansible 2.0.0.2

I'm using win_nssm to install a service. It's successfully installing the service, however all subsequent runs show the win_nssm task as 'changed'.

Why is win_nssm showing 'changed' even though the service has already been installed and nothing has been modified? Is it actually re-installing the service?

Playbook:

  win_nssm:

    name: servicename

    state: present

    application: C:\path\to\exe

    start_mode: manual

    user: ********

    password: ********


Output:

TASK [appservice : Install appservice via NSSM] ****************

changed: [server1.my.domain.com]



Any way to condition around this?

J Hawkesworth

unread,
Feb 8, 2016, 9:47:32 AM2/8/16
to Ansible Project
I've not looked at the code, but perhaps it is a bug.  Since you seem to be able to reproduce, I suggest raising it in ansible modules extra project (using the issue template) https://github.com/ansible/ansible/raw/devel/ISSUE_TEMPLATE.md


To do so, you might need to check if the service exists already, which you can do something like this (untested)

- name: check if service exists
  raw: "Get-Service -Name 'appservice'"
  register: appservice_status
  ignore_errors: True

Then you'd have to check the stdout stored in the registered appservice_status var to see if it exists.

You could perhaps even use a when: clause so the win_nssm only runs when the service doesn't exist, although that wouldn't ever let you reconfigure the service in the same playbook (which may or may not be important to you).

Hope this helps,

Jon

Joe Levis

unread,
Feb 8, 2016, 10:51:31 AM2/8/16
to Ansible Project
Thanks Jon. I'll see what I can do with these options.

-Joe
Reply all
Reply to author
Forward
0 new messages