Using service on Windows
On Windows, Puppet can start, stop, enable, disable, list, query, and configure services. It expects that all services run with the built-in Service Control Manager (SCM) system. It does not support configuring service dependencies, the account to run as, or desktop interaction.
When writing service resources for Windows, remember the
following:
Use the short service name (such as
wuauserv) in Puppet, not the display name (such asAutomatic Updates).Set
enable => trueto assign a service the Automatic startup type.Set
enable => manualto assign the Manual startup type.
For example, here is a complete service resource:
service { 'mysql':
ensure => 'running',
enable => true,
}
Puppet 7 adds support for managing the logon user and password to the Windows service
provider. For
example:
service { 'name-of-service':
ensure => 'running',
enable => 'true',
logonaccount => 'domain\\user',
logonpassword => $password,
}
Note that the logonpassword is a sensitive variable.