Documentation

win_nssm - NSSM - the Non-Sucking Service Manager

New in version 2.0.

Synopsis

nssm is a service helper which doesn’t suck. See https://nssm.cc/ for more information.

Requirements (on host that executes module)

  • nssm >= 2.24.0 # (install via win_chocolatey) win_chocolatey: name=nssm

Options

parameter required default choices comments
app_parameters
no
    Parameters to be passed to the application when it starts
    application
    no
      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 (https://git.nssm.cc/?p=nssm.git;a=commit;h=0b386fc1984ab74ee59b7bed14b7e8f57212c22b)
      dependencies
      no
        Service dependencies that has to be started to trigger startup, separated by comma.
        name
        yes
          Name of the service to operate on
          password
          no
            Password to be used for service startup
            start_mode
            yes auto
            • auto
            • manual
            • disabled
            If auto is selected, the service will start at bootup. manual means that the service will start only when another service needs it. disabled means that the service will stay off, regardless if it is needed or not.
            state
            no started
            • present
            • started
            • stopped
            • restarted
            • absent
            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
            stderr_file
            no
              Path to receive error output
              stdout_file
              no
                Path to receive output
                user
                no
                  User to be used for service startup

                  Examples

                  # Install and start the foo service
                  - win_nssm:
                      name: foo
                      application: C:\windows\foo.exe
                  
                  # 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
                  
                  # 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
                  
                  # 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
                  
                  # 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"
                  
                  # 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
                  
                  # 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'
                  
                  # Install and start the foo service with dedicated user
                  - win_nssm:
                      name: foo
                      application: C:\windows\foo.exe
                      user: foouser
                      password: secret
                  
                  # Install the foo service but do not start it automatically
                  - win_nssm:
                      name: foo
                      application: C:\windows\foo.exe
                      state: present
                      start_mode: manual
                  
                  # Remove the foo service
                  - win_nssm:
                      name: foo
                      state: absent
                  

                  This is an Extras Module

                  For more information on what this means please read Extras Modules

                  For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.