Bobcares

Steps to install Puppet on CentOS 7

by | Oct 27, 2020

Willing to install puppet on CentOS 7? Here are the steps for it.

Here at Bobcares, we have seen several such CentOS related queries as part of our Server Management Services for web hosts and online service providers.

Today we’ll see how to install puppet on CentOS 7.

 

A few facts about Puppet

Puppet is open-source task-controlling software that manages Linux and Windows server functions from a central master server. It uses a master/client set up to communicate between the master and client servers.

Moreover, it reduces the time spent repeating the basic tasks.

This way, it ensures that the configurations are consistent and accurate across your infrastructure.

 

How to install Puppet on CentOS 7

Now let’s see how our Support Engineers install the Puppet.

 

1. Puppet Pre-Installation

As a first step, we shall make some installation and configuration on both the servers puppet master and puppet agent.

 

Configure hosts

Now connect to the puppet master and agent using your root user via SSH.

Then edit the hosts using vim editor.

# vim /etc/hostsCopy Code

At the end of the line, add the below configuration.

10.0.15.10 master.bob.com
10.0.15.11 agent.bob.com

Save the file and exit.

Then test it by running the ping command.

ping master.bob.com
ping agent.bob.comCopy Code

As a result, of the above command, you must get the server IP address 10.0.15.10 and 10.0.15.11.

 

Configure NTP Server

The time between the master and agent server must be kept in synchronization.

Now install the NTP packages on both servers by running the below command.

# yum -y install ntp ntpdateCopy Code

Once the installation completes, choose the NTP pool as you want by running the command as below.

$ sudo ntpdate 0.centos.pool.ntp.orgCopy Code

Then start the NTP service and enable it to launch every time at system boot.

$ sudo systemctl start ntpd
$ sudo systemctl enable ntpdCopy Code

This completes the NTP installation and configuration.

 

Disable SELinux

Use any editor to edit the SELinux configuration file.

# vim /etc/sysconfig/selinuxCopy Code

Then change the SELINUX value to ‘disabled’.

SELINUX=disabled

Now save the file and exit.

 

Add Puppet Repository

In order to add the puppet repository to the system, run the below rpm command.

# rpm -Uvh https://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpmCopy Code

Once it completes, reboot both the servers.

# rebootCopy Code

 

2. Install and Configure Puppetserver

Now we shall install and configure Puppetserver on the master.bob.com server. Run the below yum command to install it.

$ sudo yum -y install puppetserverCopy Code

Once the installation completes, we need to configure the memory allocation for puppetserver. Now we shall set the max memory allocation for puppetserver to 1GB. For that, edit the ‘puppetserver’ configuration.

# vim /etc/sysconfig/puppetserverCopy Code

Change the line as below.

JAVA_ARGS=”-Xms1g -Xmx1g ….”

Save the file and exit.

After that, go to the puppet configuration directory and edit the ‘puppet.conf’ file.

# cd /etc/puppetlabs/puppet
# vim puppet.confCopy Code

Add the following configuration.

[master]
dns_alt_names=master.bob.com,puppet

[main]
certname = master.bob.com
server = master.bob.com
environment = production
runinterval = 1h

Then save the file and exit.

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

# systemctl start puppetserver
# systemctl enable puppetserverCopy Code

This completes the Puppetserver installation and configuration.

In case, if you are using the 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 –reloadCopy Code

 

3. Install and Configure Puppet Agent

Now we will install the puppet agent on the ‘agent.bob.com’ server. For doing that, run the below command to install the puppet agent.

# yum install -y puppet-agentCopy Code

Once the installation completes, access the puppet configuration directory and edit the puppet.conf file.

# cd /etc/puppetlabs/puppet
# vim puppet.confCopy Code

Then paste the below configuration.

[main]
certname = agent.bob.com
server = master.bob.com
environment = production
runinterval = 1h

Save and exit the file.

Now we shall register the puppet agent to the puppet master. So execute the below command on the puppet agent shell.

# /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=trueCopy Code

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

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

# /opt/puppetlabs/bin/puppet cert listCopy Code

Then you will get the pending Certificate Signing Request (CSR) from the puppet agent server ‘agent.bob.com’.

Next, run the below command to sign the certificate.

# /opt/puppetlabs/bin/puppet cert sign agent.bob.comCopy Code

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

 

4. Verify the Puppet Agent Configuration

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

# /opt/puppetlabs/bin/puppet agent –testCopy Code

You must see a result as below.

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

 

5. Create First Manifest

Now we shall create a simple manifest for testing.

Go to the ‘/etc/puppetlabs/code/’ directory and create the new manifest file ‘site.pp’ on the puppet master server.

# cd /etc/puppetlabs/code/
# cd environments/production/manifestsCopy Code

Then create new manifest file.

# vim site.ppCopy Code

After that, paste the below configuration.

node ‘agent.bob.com’ {
package { ‘httpd’:
ensure => “installed”,
}
service { ‘httpd’:
ensure => running,
enable => true
}
}

Save the file and exit.

Next, run the below command to open the puppet agent server shell.

# /opt/puppetlabs/bin/puppet agent –testCopy Code

This command retrieves a new manifest configuration file from the puppet master and then applies it to the agent server.

Now access the web browser and type the IP address of the puppet agent.

http://10.0.15.11/

You will get a default HTTP page.

Now, the httpd web server has been installed using the puppet manifest.

Finally, the installation and configuration of Puppet Master and Puppet Agent on CentOS 7 has been completed successfully.

[Need any further assistance with CentOS queries? – We are here to help you.]

 

Conclusion

In today’s writeup, we saw how our Support Engineers install Puppet on CentOS 7.

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Speed issues driving customers away?
We’ve got your back!