How to Setup Puppet Master and Agent on CentOS 8

How to Setup Puppet Master and Agent on CentOS 8

All

Linux Articles / All 51 Views comments

Puppet is an open-source configuration administration software and server automation framework. Puppet can run on Unix-like working methods, in addition to on the Microsoft Home windows techniques. It lets you handle and carry out administrative duties and the configuration of lots of of methods from one grasp server.

On this tutorial, I'll you the best way to set up Puppet on CentOS Eight. I'll set up and configure a CentOS Eight server as a puppet 'grasp', and the opposite one as an 'agent'.

Conditions

  • 2 or extra CentOS Eight Server
  • Root privileges

What we'll do:

  • Puppet Pre-Set up
  • Set up and Configure Puppet server
  • Set up and Configure Puppet Agent
  • Confirm Puppet Agent Configuration
  • Create First Puppet Manifest

Step 1 - Puppet Pre-Set up

On this first step, we will put together each grasp and agent servers for the puppet set up. We will arrange hosts and FQDN of the server, setup the NTP server and add the puppet repository for CentOS Eight server.

Setup Hostnames

Firstly, we will arrange hosts and FQDN for each servers. The puppet grasp could have a hostname 'grasp' with the FQDN 'grasp.hakase-labs.io', and the agent may have the hostname 'agent01' with the FQDN 'agent01.hakase-labs.io'.

Arrange the hostname utilizing the 'hostnamectl' command under.

hostnamectl set-hostname hostname

After that, edit the '/and so on/hosts' file to configure the FQDN server.

vim /and so forth/hosts

Change the IP handle and the area identify with your personal and paste into it.

10.5.5.21   grasp.hakase-labs.io   grasp
10.5.5.22 agent01.hakase-labs.io agent01

Save and shut.

Now restart the hostnamed service to use a brand new hostname and FQDN.

systemctl restart systemd-hostnamed

And after that, examine the hostname and the FQDN utilizing the next command.

hostname
hostname -f

And you'll get a brand new hostname and FQDN has been configured and utilized to the system.

Set the server hostname

Setup NTP Server

For the NTP server, we will use "chrony" for our servers.

Set up chrony utilizing the dnf command under.

dnf set up chrony

After that, edit the chrony configuration '/and so forth/chrony.conf' utilizing vim editor.

vim /and so on/chrony.conf

Now change the pool server with the closest pool of your nation. You possibly can verify obtainable pool NTP utilizing the 'https://www.pool.ntp.org/zone/COUNTRYID'.

Copy all out there NTP server of your nation and paste into the 'chrony.conf' file as under.

server zero.id.pool.ntp.org iburst
server 1.id.pool.ntp.org iburst
server 2.id.pool.ntp.org iburst
server three.id.pool.ntp.org iburst

Save and shut.

Now begin the chronyd service and add it to startup boot time.

systemctl begin chronyd
systemctl allow chronyd

The NTP server configuration has been accomplished.

Setup date and time

Add Puppet Repository for CentOS Eight

For the puppet repository CentOS Eight server, you possibly can set up it manually utilizing the rpm command as under.

sudo rpm -Uvh https://yum.puppet.com/puppet6-release-el-Eight.noarch.rpm

After that, verify all out there repository on the system utilizing the dnf command under.

dnf repolist

And you'll get the puppet repository has been added to the CentOS Eight system.

Add puppet repository

Disable SELinux

To disable the SELinux, you possibly can edit the '/and so on/sysconfig/selinux' configuration utilizing vim editor.

vim /and so on/sysconfig/selinux

Now change the 'SELINUX' worth configuration to "disabled".

SELINUX=disabled

Save and shut, then reboot the server.

sudo reboot

As soon as you've got logged in once more, examine the SELinux standing utilizing the next command.

sestatus

And you'll get the SELinux disabled standing.

Step 2 - Set up and Configure Puppetserver

On this step, we will set up and configure the puppetserver on the grasp node.

Set up the puppetserver utilizing the dnf command under.

sudo dnf set up puppetserver

After that, we have to edit the 'init settings' for puppetserver and alter the reminiscence allocation relying on the RAM that we've got.

Edit the puppetserver init setting that situated on the '/and so forth/sysconfig/puppetserver' utilizing vim editor.

vim /and so on/sysconfig/puppetserver

Now change the 'JAVA_ARGS' configuration for reminiscence allocation relying in your RAM.

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

Save and shut.

Subsequent, go to the '/and so forth/puppetlabs' listing and edit the puppet configuration file 'puppet.conf'.

cd /and so on/puppetlabs/
vim puppet/puppet.conf

Beneath the grasp configuration, outline the DNS various names with the FQDN of the grasp server.

[master]
....
dns_alt_names=grasp.hakase-labs.io,puppet
....

After that, outline the puppet primary server configuration as under.

[main]
certname = grasp.hakase-labs.io
server = grasp.hakase-labs.io
setting = manufacturing
runinterval = 1h

Save and shut.

Now add the puppetserver service to the startup boot time and begin the service.

systemctl allow puppetserver
systemctl begin puppetserver

The puppetserver is up and operating on CentOS Eight server with the default TCP port '8140'.

Add the puppetserver port '8140' to the firewalld utilizing the next command.

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

And consequently, the puppet grasp set up and configuration has been accomplished efficiently.

Configure the Firewall

Step three - Set up and Configure Puppet Agent

After putting in the Puppet grasp server 'grasp.hakase-labs.io', we will set up a puppet agent on the 'agent01' server.

Log in to the 'agent01' server and set up the puppet-agent package deal utilizing the dnf command under.

sudo dnf set up puppet-agent

After that, go to the '/and so forth/puppetlabs' listing and edit the configuration file 'puppet.conf' utilizing vim editor.

cd /and so on/puppetlabs/
vim puppet/puppet.conf

Change the 'certname' and 'server' configuration with your personal and paste to the configuration.

[main]
certname = agent01.hakase-labs.io
server = grasp.hakase-labs.io
setting = manufacturing
runinterval = 1h

Save and shut.

Subsequent, begin puppet service and register the Puppet agent to the grasp server utilizing the next command.

/choose/puppetlabs/bin/puppet useful resource service puppet guarantee=operating allow=true

And you'll get the outcome as under.

Start puppet service

The puppet agent is now up and operating, it is trying to register to the Puppet grasp server.

Now again to the Puppet grasp server and examine of pending certificates requests.

/choose/puppetlabs/bin/puppetserver ca record

And you'll get the 'agent01.hakase-labs.io' certificates on the listing.

Now signal the 'agent01' certificates utilizing the command under.

/choose/puppetlabs/bin/puppetserver ca signal --certname agent01.hakase-labs.io

And the puppet agent is now has been registered to the grasp server.

Register puppet agent

Step four - Confirm Puppet Agent Configuration

Now confirm the Puppet agent configuration and check the connection between the puppet agent and grasp utilizing the next command.

/choose/puppetlabs/bin/puppet agent --test

And you'll get the outcome as under.

Test puppet agent

Consequently, the Puppet agent pulled the configuration from the puppet grasp and utilized it to the server with none error.

Step 5 - Create First Manifest

At this stage, the set up and configuration of Puppet for grasp and agent have been accomplished.

And for this step, we will check our setup by creating the primary puppet manifest for putting in the httpd package deal.

Go to the '/and so on/puppetlabs/code/environments/manufacturing/manifests' listing and create the primary puppet manifest file 'httpd.pp'.

cd /and so forth/puppetlabs/code/
cd environments/manufacturing/manifests

vim httpd.pp

Paste the next configuration.

node 'agent01.hakase-labs.io' 
package deal 'httpd':
guarantee => "put in",

service 'httpd':
guarantee => operating,
allow => true

Save and shut.

Create Manifest

Now go to the Puppet agent node 'agento01' and run the next command.

/choose/puppetlabs/bin/puppet agent --test

And you may be proven the end result as under.

Test puppet agent

The Puppet agent pulled a brand new configuration from the Puppet grasp for putting in the httpd package deal and begin the httpd service.

On the 'agent01' node, examine the httpd service standing and examine the HTTP port '80'

systemctl standing httpd
netstat -plntu

And you'll get the httpd service is up and operating on the 'agent01' server with the default HTTP port '80'. The httpd package deal has been put in by means of the puppet manifest that we have created on the prime.

Check httpd status

And in consequence, the Puppet grasp and agent set up and configuration on CentOS Eight server have been accomplished efficiently.

Reference

Comments