There is a new version of this tutorial available for CentOS 8.

How to Setup Puppet Master and Agent on CentOS 7

Puppet is an open source configuration management tool and server automation framework. Puppet can run on Unix-like operating systems, as well as on the Microsoft Windows systems. It allows you to manage and perform administrative tasks and the configuration of hundreds of systems from one master server.

In this tutorial, I will you how to install Puppet on CentOS 7. I will install and configure a CentOS 7 server as a puppet 'master', and the other one as an 'agent'.


  • 2 CentOS 7 servers
    •    2GB Memory
  • Root privileges

What we will do:

  1. Puppet Pre-Installation
  2. Install and Configure Puppet server
  3. Install and Configure Puppet Agent
  4. Verify Puppet Agent Configuration
  5. Create First Puppet Manifest

Step 1 - Puppet Pre-Installation

In this step, we will perform some tasks including installation and configuration on both servers puppet master and puppet agent. We will configure the host's file, synchronizing time using the NTP server, Disable SELinux, and add the puppet repository to the system.

- Configure hosts

Connect to the puppet master and agent using your root user.

ssh [email protected]
ssh [email protected]

Now edit the hosts using vim editor.

vim /etc/hosts

Add the following configuration to the end of the line.

Save and exit.

Now test using the ping command.


And make sure you get the server IP address and

Configure hosts file

- Configure NTP Server

It's very important to keep in synchronization the time between master and agent server.

Install the NTP packages on both servers using the yum command.

yum -y install ntp ntpdate

After the installation is complete, choose the NTP pool as you want by running the command as below.

sudo ntpdate

Now start the NTP service and enable it to launch everytime at system boot.

sudo systemctl start ntpd
sudo systemctl enable ntpd

NTP installation and configuration has been completed.

Configure NTP

- Disable SELinux

Edit the SELinux configuration using vim.

vim /etc/sysconfig/selinux

Change the SELINUX value to 'disabled'.


Save and exit.

- Add Puppet Repository

Now add the puppet repository to the system using the rpm command below.

rpm -Uvh

Add puppet repository

When it is complete, reboot both servers.


Now we're ready for puppet installation and configuration.

Step 2 - Install and Configure Puppetserver

In this step, we will install the puppetserver on the server. Install puppetserver using the yum command below.

sudo yum -y install puppetserver

After the installation is complete, we need to configure the memory allocation for puppetserver. We will set the max memory allocation for puppetserver to 1GB.

Edit the 'puppetserver' configuration using vim.

vim /etc/sysconfig/puppetserver

Now change the line as below.

JAVA_ARGS="-Xms1g -Xmx1g ...."

Save and exit.

Next, go to the puppet configuration directory and edit the 'puppet.conf' file.

cd /etc/puppetlabs/puppet
vim puppet.conf

Add the following configuration.


certname =
server =
environment = production
runinterval = 1h

Save and exit.

Now start the puppetserver and enable it to launch everytime at startup.

systemctl start puppetserver
systemctl enable puppetserver

The Puppetserver installation and configuration has been completed successfully.

Configure puppetserver

If you're using firewalld on your system, add the puppetserver port to the list using the firewall-cmd command below.

firewall-cmd --add-port=8140/tcp --permanent
firewall-cmd --reload

Configure firewall

Step 3 - Install and Configure Puppet Agent

We will install the puppet agent on the '' server.

Install puppet agent using the yum command below.

yum install -y puppet-agent

After the installation is complete, go to the puppet configuration directory and edit the puppet.conf file.

cd /etc/puppetlabs/puppet
vim puppet.conf

Paste the following configuration.

certname =
server =
environment = production
runinterval = 1h

Save and exit.

Next, we will register the puppet agent to the puppet master.

Run the command below on the puppet agent shell.

/opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true

The puppet agent is now running on the server, and it's attempting to register itself to the puppet master.

Now back to the puppet master shell and run the command below.

/opt/puppetlabs/bin/puppet cert list

And you will get the pending Certificate Signing Request (CSR) from the puppet agent server ''.

Sign the certificate using the command below.

/opt/puppetlabs/bin/puppet cert sign

And the result should be similar to the following:

Configure puppet agent

The puppet agent is now running on the system, and the certificate for the agent has been signed by the puppet master.

Step 4 - Verify the Puppet Agent Configuration

After the puppet master signed the certificate file for the agent, run command below on the puppet agent to verify the configuration.

/opt/puppetlabs/bin/puppet agent --test

And you will get the result as shown below.

Verify puppet agent configuration

The Puppet agent pulled the configuration from the puppet master and applied to the server without any error.

Step 5 - Create First Manifest

The puppet master and agent installation and configuration have been completed. And for this step, we will create a simple manifest for testing.

We will create the manifest for Apache httpd web server installation.

On the puppet master server, go to the '/etc/puppetlabs/code/' directory and create the new manifest file 'site.pp' using vim.

cd /etc/puppetlabs/code/
cd environments/production/manifests

Create new manifest file.

vim site.pp

Paste the following configuration.

node '' {
    package { 'httpd':
        ensure  => "installed",
    service { 'httpd':
        ensure => running,
    enable => true

Save and exit.

Now open the puppet agent server shell and run the command below.

/opt/puppetlabs/bin/puppet agent --test

The command will retrieve new manifest configuration file from the puppet master and then apply it to the agent server.

Following is the result.

Create puppet manifest

Open your web browser and type the IP address of the puppet agent.

And you will get the default HTTP page as below.

Apache test page

The httpd web server has been installed using the puppet manifest.

Installation and configuration of the Puppet Master and Puppet Agent on CentOS 7 has been completed successfully.


Share this page:

Suggested articles

8 Comment(s)

Add comment


By: pida42 at: 2018-06-13 11:43:00

Would be nice to keep SeLinux enabled and create rules instead of disabling it...

By: Essakhi at: 2018-06-28 13:53:22

Thanks. It helps me. Great.

By: cornelis van ginkel at: 2018-12-12 14:19:55

I had a hard time with this and the option "cert" is deprecated at this moment of writing. It still works though, but.

I had to change my conf file to this and then I could sign the certificate because the agent couldn't find/get the certificate from the puppet master.

Hope it helps other people

# cat /etc/puppet/puppet.conf [main] logdir=/var/log/puppet vardir=/var/lib/puppet ssldir=/var/lib/puppet/ssl rundir=/var/run/puppet factpath=/lib/facter pluginsync=true templatedir=/templates [agent]

By: Tom at: 2019-02-11 11:32:40


Great job!

I installed without option Selinux disabled and everything is working with test httpd page :)

Thaks a lot!


By: someone1997 at: 2019-02-15 06:30:39

hey, when I try agent -t the output is like this:

Info: Using configured environment 'production'Info: Retrieving pluginfactsInfo: Retrieving pluginError: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not find node statement with name 'default' or 'server.localhost.localdomain, server.localhost, server' on node server.localhost.localdomainWarning: Not using cache on failed catalogError: Could not retrieve catalog; skipping run


I'm trying it on virtualbox

By: Subrath at: 2019-12-04 21:03:35

Thanks :) this document helped immensely for my Installation

By: Maher Al-Rayyashi at: 2020-02-24 12:57:59

Thanks, Muhammad for such a great article, Keep moving on

By: dreyna at: 2020-05-20 05:42:02

great write up. You have to run firewall-cmd --add-port=80/tcp --permanent on the agent to be able to get the default httpd test page to load