How to Setup Puppet Master and Agent on CentOS 8
Puppet is an open source configuration management and server automation framework. Puppet can run on all Linux/unix and Microsoft Windows systems. It allows you to manage and perform administrative tasks and the configuration of multiple systems from one master server.
In this article, you will learn how to install Puppet on CentOS 8. I will install and configure a CentOS 8 server as a puppet 'master', and the other one as an 'agent'.
Prerequisites
- 2 CentOS 8 servers
- 0.0.14 master.theskillpedia.com 4 GB Memory
- 0.0.15 agent.theskillpedia.com 3 GB RAM
- Root privileges
What we will do:
- Puppet Pre-Installation
- Install and Configure Puppet server
- Install and Configure Puppet Agent
- Verify Puppet Agent Configuration
- 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 on both machines by editing the hosts using vim
Add the following configuration to the end of the line.
10.0.0.14 master.theskillpedia.com 10.0.0.15 agent.theskillpedia.com[caption id="attachment_6210" align="aligncenter" width="735"] host-file-for-puppet[/caption]
- Now test using the ping command on both machines to verify the connectivity
- Configure NTP Server. It's very important to keep in synchronization the time between master and agent server. Install the chrony packages on both servers using the dnf
- Edit the /etc/chrony.conf file and add, change, or remove the following.
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst
- To enable agent to connect to the chrony on puppet master, change chrony.conf :
- Adjust Firewall Setting
# firewall-cmd --add-service=ntp --permanent
success
# firewall-cmd --reload
success
- Restart the NTP service:
- Disable SELinux. Edit the SELinux configuration using vim.
Change the SELINUX value to 'disabled'.
SELINUX=disabledSave and exit.
- Add Puppet Repository on both machines using the rpm command.
- When it is complete, reboot both servers.
Step 2 - Install and Configure Puppetserver
- Let us install the
puppetserver
on the master.theskillpedia.com server using thednf
- Configure the max memory allocation of 2GB for puppetserver by editing the 'puppetserver' configuration.
change/verify the line as below.
JAVA_ARGS="-Xms2g –Xmx2g "Save and exit.
- Go to the puppet configuration directory and edit the 'puppet.conf' file.
Add the following configuration.
[master] dns_alt_names=master.theskillpedia.com,puppet main] certname = master.theskillpedia.com server = master.theskillpedia.com environment = production runinterval = 1hSave and exit.
- Now start the puppetserver and enable it to launch at boot time.
The Puppetserver installation and configuration has been completed successfully.
- If you're using firewalld on your system, add the puppetserver port to the list using the firewall-cmd following command.
Step 3 - Install and Configure Puppet Agent
- Install the puppet agent on the 'agent.theskillpedia.com' server using the dnf command.
- After the installation is complete, go to the puppet configuration directory and edit the puppet.conf file.
Paste the following configuration.
[main] certname = agent.theskillpedia.com server = master.theskillpedia.com environment = production runinterval = 1hSave and exit.
- Register the puppet agent to the puppet master by runing the following command on the puppet agent shell.
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 following command.
You will get the pending Certificate Signing Request (CSR) from the puppet agent server 'agent.theskillpedia.com'.
- Sign the certificate using the command below.
The result should be similar to the following:
[caption id="attachment_6211" align="aligncenter" width="768"] puppet-cert-sign-agent[/caption]
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 following command on the puppet agent to verify the configuration.
And you will get the result as shown below.
[caption id="attachment_6212" align="aligncenter" width="447"] puppet-agent-test[/caption]
The output indicates that the Puppet agent pulled the configuration from the puppet master and applied to the server without any error.
Step 5 - Create First Manifest
- Let us create a simple manifest for Apache httpd web server installation for testing. On the puppet master server, go to the '/etc/puppetlabs/code/' directory and create the new manifest file 'site.pp' using vim.
Save and exit.
- Open the puppet agent server shell and run the command below.
The command will retrieve new manifest configuration file from the puppet master and then apply it to the agent server.
- Open your web browser and type the IP address of the puppet agent, . You will get the default HTTP page as below.
[caption id="attachment_6215" align="aligncenter" width="768"] puppet-manifet-example[/caption]
The httpd web server has been installed using the puppet manifest. Installation and configuration of the Puppet Master and Puppet Agent on CentOS 8 has been completed successfully.