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