Puppet is a popular open-source configuration management tool that allows you to automate the management of your server infrastructure. In this tutorial, we will walk you through the process of how to install and configure Puppet on Rocky Linux. By the end of this guide, you will have a fully functional Puppet setup ready to manage your servers.
Prerequisites
Before we get started, make sure you have the following requirements in place:
- A Rocky Linux server with root access or a user with sudo privileges
- A stable internet connection to download the necessary packages
How to Install and Configure Puppet on Rocky Linux
Update your Rocky Linux System
First, update your Rocky Linux system to ensure all the packages are up to date:
sudo dnf update -y
Install the Puppet Server on Rocky Linux
To install the Puppet server, we need to add the Puppet repository to our system. Execute the following command:
sudo dnf install -y https://yum.puppet.com/puppet6-release-el-8.noarch.rpm
Once the repository is added, install the Puppet server package:
sudo dnf install -y puppetserver
Configure the Puppet Server on Rocky Linux
After the installation is complete, we need to configure the Puppet server. Start by editing the /etc/sysconfig/puppetserver
file:
sudo nano /etc/sysconfig/puppetserver
Modify the JAVA_ARGS
line to allocate the desired amount of memory to the Puppet server. For example, to allocate 2 GB of memory, change the line to:
JAVA_ARGS="-Xms2g -Xmx2g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"
Save and exit the file.
Next, edit the Puppet configuration file located at /etc/puppetlabs/puppet/puppet.conf
. Add the following lines at the end of the file:
[main]
certname = puppet.example.com
server = puppet.example.com
environment = production
runinterval = 1h
Replace puppet.example.com
with your server’s Fully Qualified Domain Name (FQDN) or IP address. Save and exit the file.
Start and Enable the Puppet Server on Rocky Linux
Now that the Puppet server is configured, start and enable the service:
sudo systemctl start puppetserver
sudo systemctl enable puppetserver
Configure Firewall Rules on Rocky Linux
To allow clients to connect to the Puppet server, we need to open the required ports on the firewall:
sudo firewall-cmd --add-port=8140/tcp --permanent
sudo firewall-cmd --reload
Install the Puppet Agent on Rocky Linux
In this step, we will install the Puppet agent on the same Rocky Linux server. This is just for demonstration purposes; in a real-world scenario, you would install the Puppet agent on different servers that you want to manage using Puppet.
To install the Puppet agent, run the following command:
sudo dnf install -y puppet-agent
Configure the Puppet Agent on Rocky Linux
After the installation, we need to configure the Puppet agent. Edit the /etc/puppetlabs/puppet/puppet.conf
file:
sudo nano /etc/puppetlabs/puppet/puppet.conf
Add the following lines at the end of the file:
[agent]
server = puppet.example.com
Replace puppet.example.com
with the FQDN or IP address of your Puppet server. Save and exit the file.
Start and Enable the Puppet Agent on Rocky Linux
Start and enable the Puppet Agent on your Rocky Linux system by running the following commands:
sudo systemctl start puppet
sudo systemctl enable puppet
After starting and enabling the Puppet agent, it will run in the background and communicate with the Puppet master server.
Configure the Puppet Master and Agent Communication
For the Puppet master and agent to communicate properly, you need to sign the agent’s certificate request on the Puppet master server. First, check for any pending certificate requests by running the following command on the Puppet master server:
sudo /opt/puppetlabs/bin/puppetserver ca list
If you see a certificate request from your Puppet agent, sign it using the following command:
sudo /opt/puppetlabs/bin/puppetserver ca sign --certname agent.example.com
Replace agent.example.com
with the FQDN of your Puppet agent node.
Test the Puppet Agent
To test the Puppet agent, run the following command on the agent node:
sudo /opt/puppetlabs/bin/puppet agent --test
This command will force the Puppet agent to perform a manual run and apply any configurations from the Puppet master server. If everything is configured correctly, you should see output indicating that the agent is communicating with the Puppet master server and applying the specified configurations.
Conclusion
You have now successfully installed and configured Puppet on your Rocky Linux system. Puppet is a powerful configuration management tool that can help you manage and automate your infrastructure. By following this guide, you have set up the Puppet master and agent communication, allowing you to create and apply configurations across multiple nodes easily.
To further enhance your Puppet setup, consider exploring other Puppet modules and configurations. Additionally, take a look at these useful guides to learn more about various applications and services on Rocky Linux:
- How to install and configure GlusterFS on Rocky Linux
- How to install and configure Bacula Backup Server on Rocky Linux
- How to install and configure Zabbix on Rocky Linux
- How to install and configure Nagios on Rocky Linux
- How to install MongoDB on Rocky Linux
By mastering Puppet and understanding its capabilities, you can ensure that your infrastructure remains consistent, secure, and up-to-date.