ansible.builtin.win_nssm (v2.4.3.0-1) — module

NSSM - the Non-Sucking Service Manager

| "added in version" 2.0 of ansible.builtin"

Authors: Adam Keech (@smadam813), George Frank (@georgefrank), Hans-Joachim Kliemeck (@h0nIg)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.4.3.0.post1

Description

nssm is a service helper which doesn't suck. See U(https://nssm.cc/) for more information.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install and start the foo service
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install and start the foo service with a key-value pair argument
# This will yield the following command: C:\windows\foo.exe bar "true"
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
    app_parameters:
      bar: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install and start the foo service with a key-value pair argument, where the argument needs to start with a dash
# This will yield the following command: C:\windows\\foo.exe -bar "true"
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
    app_parameters:
      "-bar": true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install and start the foo service with a single parameter
# This will yield the following command: C:\windows\\foo.exe bar
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
    app_parameters:
      _: bar
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install and start the foo service with a mix of single params, and key value pairs
# This will yield the following command: C:\windows\\foo.exe bar -file output.bat
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
    app_parameters:
      _: bar
      "-file": "output.bat"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Use the single line parameters option to specify an arbitrary string of parameters
# for the service executable
- name: Make sure the Consul service runs
  win_nssm:
    name: consul
    application: C:\consul\consul.exe
    app_parameters_free_form: agent -config-dir=C:\consul\config
    stdout_file: C:\consul\log.txt
    stderr_file: C:\consul\error.txt
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install and start the foo service, redirecting stdout and stderr to the same file
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
    stdout_file: C:\windows\foo.log
    stderr_file: C:\windows\foo.log
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install and start the foo service, but wait for dependencies tcpip and adf
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
    dependencies: 'adf,tcpip'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install and start the foo service with dedicated user
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
    user: foouser
    password: secret
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install the foo service but do not start it automatically
- win_nssm:
    name: foo
    application: C:\windows\foo.exe
    state: present
    start_mode: manual
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Remove the foo service
- win_nssm:
    name: foo
    state: absent

Inputs

    
name:
    description:
    - Name of the service to operate on
    required: true

user:
    description:
    - User to be used for service startup

state:
    choices:
    - present
    - started
    - stopped
    - restarted
    - absent
    default: started
    description:
    - State of the service on the system
    - Note that NSSM actions like "pause", "continue", "rotate" do not fit the declarative
      style of ansible, so these should be implemented via the ansible command module

password:
    description:
    - Password to be used for service startup

start_mode:
    choices:
    - auto
    - manual
    - disabled
    default: auto
    description:
    - If C(auto) is selected, the service will start at bootup. C(manual) means that the
      service will start only when another service needs it. C(disabled) means that the
      service will stay off, regardless if it is needed or not.

application:
    description:
    - The application binary to run as a service
    - 'Specify this whenever the service may need to be installed (state: present, started,
      stopped, restarted)'
    - 'Note that the application name must look like the following, if the directory includes
      spaces:'
    - nssm install service "c:\\Program Files\\app.exe\\" "C:\\Path with spaces\\"
    - 'See commit 0b386fc1984ab74ee59b7bed14b7e8f57212c22b in the nssm.git project for
      more info: U(https://git.nssm.cc/?p=nssm.git;a=commit;h=0b386fc1984ab74ee59b7bed14b7e8f57212c22b)

      '

stderr_file:
    description:
    - Path to receive error output

stdout_file:
    description:
    - Path to receive output

dependencies:
    description:
    - Service dependencies that has to be started to trigger startup, separated by comma.

app_parameters:
    description:
    - Parameters to be passed to the application when it starts.
    - Use either this or C(app_parameters_free_form), not both

app_parameters_free_form:
    description:
    - Single string of parameters to be passed to the service.
    - Use either this or C(app_parameters), not both
    version_added: 2.3.0
    version_added_collection: ansible.builtin