How to Setup Puppet: A configuration management and automation Tool

How to Setup Puppet

Puppet is among the most frequently used configuration management utilities, and it’s easy to get a sense of how Puppet works by setting up a simple environment.

This Puppet setup includes a Puppet master and agent running on CentOS Linux version 6.9 As it is test setup, In this we run both Puppet master and Puppet agent on same machine. In Real world both will be in different nodes.


To start, install or verify the presence of the Puppet software package; it is included in the repositories of some Linux distributions.

On CentOS, install the extra packages for enterprise Linux (EPEL) repository — which contains convenient but unsupported packages — with or can use RPM package to install it.

RedHat/CentOS 7

# rpm -ivh

RedHat/CentOS 6

# rpm -ivh

For more, Refer Doc


Master Installation:

# yum -y install puppetserver

Agent Installation:

# yum install –y puppet

This installs Puppet and an init script (/etc/init.d/puppetmaster) that runs a test-quality Puppet master server.

Puppet functionality

Puppet is a configuration management tool designed for easy use by non-programmers, such as IT administrators. If you’re new to Puppet, learn how the tool achieves idempotent configurations, and review the main considerations of licensing the supported version of the software.

Once puppet installed, start creating manifest files. Puppet users define the desired state of a machine in a declarative language to create a manifest file. Puppet allows the administrator to manage various items through manifest files. For example, one manifest file creates a user. To run this test, create a file with the name newuser.pp, containing:

user { 'mango':
  ensure => 'present',
  home => '/home/mango',
  shell => '/bin/bash',

After creating this file, use the command puppet apply to create the user. You should see command output that looks as follows:

# puppet apply newuser.pp
Notice: Compiled catalog for foxutech in environment production in 2.80 seconds
Notice: /Stage[main]/Main/User[mango]/ensure: created
Notice: Finished catalog run in 0.28 seconds

type # getent passwd mango and verify that the user was successfully created. Type

# ls -l /home/mango

and you’ll notice the home directory doesn’t exist. The Puppet manifest file has defined that the user should have a property home, which is indeed created in the user specification. However, Puppet is not so smart that it will create the home directory automatically, even if it did create the group mango for the user. To create the home directory, add the following section to the manifest file and run puppet apply user once more:

file { '/home/mango':
  ensure => 'directory',
  owner => 'mango',
  group => 'mango',
  mode => '770',
  require => User['mango'],

You have now successfully created a user via a manifest file on your Puppet setup. For a list of other supported resources, type

# puppet resource --type

A long list of resource types will scroll by on the screen. From the shell the command line interface

# puppet describe file

For the full list of available descriptions try:

# puppet describe --list


The service resource is among Puppet’s most interesting options. It allows the user to manage the state of services on a given computer.

Start with the service resource by running the command puppet resource service sshd. Puppet displays the current status of the resource on the server: ensure indicates whether or not it’s currently running, and enable shows if it is enabled for automatic starting after a reboot.

# puppet resource service sshd
service { 'sshd':
  ensure => 'running',
  enable => 'true',

# puppet resource service httpd
service { 'httpd':
  ensure => 'running',
  enable => 'false',

# puppet resource service httpd
service { 'nginx':
  ensure => 'stopped',
  enable => 'false',

A Puppet user can usually figure out what they’ll need in place to manage resources without additional help. As was the case for the user created earlier, a Puppet setup requires that the administrator install the service before managing it. The following Puppet manifest file shows how to do it:

package { 'nginx':
  ensure => 'present',
service { 'nginx':
  ensure => 'running',
  enable => true,
  require => Package['nginx'],

Try running this manifest file using puppet apply: It will start the service and, if necessary, install the package containing it.

Read more: What are the difference between Ansible & Puppet

Puppet can accomplish complex tasks in an automated manner. For example, in the manifest file above, the require parameter was used to make sure that the required software is installed automatically.

Once an IT administrator or developer has set up Puppet and is familiar with the language used in Puppet files, automation is relatively easy to implement.