Puppet service resource in Loop

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
Starting and stopping services is extremely simple and is only needed with the ensure parameter. Simply changing ensure to stopped will stop the service:

service { 'netlogon':
ensure => 'stopped'
}

Another great use of the service resource is to enable or disable a service. If you want complete control over a system, it may be necessary to do this for every service on a system. Here, I change enable to false which means the service is disabled on the target node that runs this manifest.

service { 'netlogon':
ensure => 'stopped'
enable => 'false'
}

Manifest for Multiple Services

In this manifest example, I want to ensure that multiple services are running when I apply them on my nodes. There are a few ways you can do this. First, you can just list the service resource for each service like the examples I have given prior. Alternatively, you could create an array in Puppet that stores all the services you want to manage:

$service_name = ['netlogon','BITS','SNMP trap]
service { $service_name:
ensure => 'running'
}

When this configuration applies on a node using a puppet agent, it will cycle through each service in the $service_name variable to ensure it is running. If it is not running, it starts the service.

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


Recent Comments

No comments

Leave a Comment