Running NSSM from copied executables on windows and avoid installing NSSM

184 views
Skip to first unread message

ishan jain

unread,
Feb 11, 2016, 9:47:42 AM2/11/16
to Ansible Project
Hi,

I am trying to create some services on my windows machines with the help of NSSM and would like to automate the process with Ansible. NSSM module for ansible requires NSSM to be installed on the windows machine but i cannot do that as internet is disabled on my windows machine. I want to use the nssm.exe that i have copied on the remote server.

How can i tell ansible to use those copied executables to run NSSM ? I really need to specify the ApplicationDir, so i guess the ansible module is not going to be useful for me.

I think this problem will be solved via the raw module but honestly i do not understand it much. Maybe because there is no proper documentation of raw module for windows.

Joe Levis

unread,
Feb 11, 2016, 10:16:25 AM2/11/16
to Ansible Project
Ishan,

The raw module works pretty much the same on Windows as it does on Linux - anything you can run on the command line can be run using the raw module. So, if you are wanting to use this nssm.exe rather than actually installing nssm, you would simply specify the path to the executable and pass whatever arguments it enables.

I haven't found a way to specify the AppDirectory upon creation of the service, so what I do is run the raw module to set that after the service has been created. For you, this might look something like this:

raw: C:\path\to\nssm.exe set [ServiceName] AppDirectory C:\path\to\appdirectory


Hope this helps.


-Joe

ishan jain

unread,
Feb 12, 2016, 4:04:26 AM2/12/16
to Ansible Project
Thanks Joe,

I tried using the raw module but the problem i am facing is that NSSM requires admin level privileges to start/stop services. How can i enable 'Run as admin' level while passing a command in NSSM ? My windows machine do not have a pre installed NSSM and thus i cannot create a service with raw and then start it with the module later on.

J Hawkesworth

unread,
Feb 12, 2016, 10:12:42 AM2/12/16
to Ansible Project
You will need to connect as a user with admin level privileges.
You can probably use win_copy to push the nssm.exe on to your machine first.
If I recall it is a single standalone executable with no external dependencies (except possibly .net)
Jon

ishan jain

unread,
Feb 16, 2016, 8:24:08 AM2/16/16
to Ansible Project
Hi Jon,

Indeed i am using the admin account to connect to the windows machine via ansible. Even when you are logged into the windows machine directly with the admin account, it would require you to again elevate the privileges to start as admin, so it is obvious we need additional steps to connect via ansible other than using the admin account.

J Hawkesworth

unread,
Feb 16, 2016, 9:06:14 AM2/16/16
to Ansible Project
You will need to (temporarily) turn of UAC prompting for Adminstrator users then.

You can change this using win_regedit

HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System
ConsentPromptBehaviorAdmin

needs to 0 for it to be off, and 2 to be back on again.

Hope this helps,

Jon

ishan jain

unread,
Feb 18, 2016, 7:37:01 AM2/18/16
to Ansible Project
Hi Jon,

Disabling UAC does not seem to be a good idea. We have to deploy our system on a number of hosts and we are trying to minimize the pre-requisites on the host environment. 
Reply all
Reply to author
Forward
0 new messages