Managing Windows Services With Puppet
Puppet may be a Linux-based system but it still boasts many Windows functions. Here is how you can manage Windows services with Puppet.
When managing servers via configuration management, one aspect that users love is the way to manage services. Whether that be starting, stopping or ensuring a service is running, configuration management solutions, such as Puppet make this very simple. One use case for this would be to set the DNS client service to always be running on a server, which is standard practice.
While Puppet is a Linux-based system and is predominately used to manage other Linux systems, it does support many Windows functions. Not only does it support them, but it does a reasonable job at doing so. In this article, I will show a few examples of how Puppet can manage Windows services, and how IT can gain control over their servers to ensure reliability.
Puppet Service Resource
In terms of managing Windows services, there are some limitations to the Puppet service resource. These are a few things Puppet cannot do with a Window service:
- Configuring service dependencies
- Setting “Run as”
- Expects the service to run as “SYSTEM”
With this said, there are ways to get around this limitation, since you can run PowerShell code within a Puppet manifest, it is certainly possible get past these.
The Puppet service resource actually only has three configurable components. These are:
- Service name
- Ensure
- Enable
A simple manifest would look like this:
service { 'netlogon': ensure => 'running', enable => 'true', }
This manifest is saying you want Puppet to ensure the netlogon service is running and enabled when you apply the configuration on a node.
Managing Services
As illustrated prior, starting and stopping services is extremely simple and is only needed with the ensure parameter. Simply changing ensure to stopped will stop the service: