community.windows.win_nssm – Install a service using NSSM¶
Note
This plugin is part of the community.windows collection (version 1.3.0).
To install it use: ansible-galaxy collection install community.windows
.
To use it in a playbook, specify: community.windows.win_nssm
.
Synopsis¶
Install a Windows service using the NSSM wrapper.
NSSM is a service helper which doesn’t suck. See https://nssm.cc/ for more information.
Requirements¶
The below requirements are needed on the host that executes this module.
nssm >= 2.24.0 # (install via chocolatey.chocolatey.win_chocolatey)
win_chocolatey: name=nssm
Parameters¶
Notes¶
Note
The service will NOT be started after its creation when
state=present
.Once the service is created, you can use the ansible.windowswin_service module to start it or configure some additionals properties, such as its startup type, dependencies, service account, and so on.
See Also¶
See also
- ansible.windows.win_service
The official documentation on the ansible.windows.win_service module.
Examples¶
- name: Install the foo service
community.windows.win_nssm:
name: foo
application: C:\windows\foo.exe
# This will yield the following command: C:\windows\foo.exe bar "true"
- name: Install the Consul service with a list of parameters
community.windows.win_nssm:
name: Consul
application: C:\consul\consul.exe
arguments:
- agent
- -config-dir=C:\consul\config
# This is strictly equivalent to the previous example
- name: Install the Consul service with an arbitrary string of parameters
community.windows.win_nssm:
name: Consul
application: C:\consul\consul.exe
arguments: agent -config-dir=C:\consul\config
# Install the foo service, and then configure and start it with win_service
- name: Install the foo service, redirecting stdout and stderr to the same file
community.windows.win_nssm:
name: foo
application: C:\windows\foo.exe
stdout_file: C:\windows\foo.log
stderr_file: C:\windows\foo.log
- name: Configure and start the foo service using win_service
ansible.windows.win_service:
name: foo
dependencies: [ adf, tcpip ]
username: foouser
password: secret
start_mode: manual
state: started
- name: Install a script based service and define custom environment variables
community.windows.win_nssm:
name: <ServiceName>
application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
arguments:
- <path-to-script>
- <script arg>
app_environment:
AUTH_TOKEN: <token value>
SERVER_URL: https://example.com
PATH: "<path-prepends>;{{ ansible_env.PATH }};<path-appends>"
- name: Remove the foo service
community.windows.win_nssm:
name: foo
state: absent
Authors¶
Adam Keech (@smadam813)
George Frank (@georgefrank)
Hans-Joachim Kliemeck (@h0nIg)
Michael Wild (@themiwi)
Kevin Subileau (@ksubileau)
Shachaf Goldstein (@Shachaf92)