Puppet – Automating Infrastructure Configuration#
What is Puppet?#
Puppet is an open-source configuration management tool that automates the provisioning, configuration, and management of infrastructure. It ensures that your systems are configured consistently and correctly according to predefined policies.
Why is Puppet a Configuration Management Tool?#
Automates Setup: Ensures systems are consistently configured.
Infrastructure as Code: Uses a declarative language to define configurations.
Consistency: Enforces policies across systems, reducing configuration drift.
Use Cases#
Provisioning: Automate setup of new servers.
Configuration: Maintain consistent system configurations.
Deployment: Automate software installations and updates.
Compliance: Ensure systems meet regulatory standards.
Dependencies#
Puppet Agent: Installed on managed nodes.
Puppet Master: Central server distributing configurations.
Modules/Manifests: Code defining resource states.
Setting Up Puppet#
To set up Puppet, you need a master server (Puppet Master) and one or more agent servers (Puppet Agents). Here’s a simplified guide:
Initial Setup #
Update your repositories:#
sudo apt update sudo apt upgrade Install Docker:
sudo apt install docker.ioPull the Puppet image:
sudo docker pull puppetCreate the Puppet Master container:
sudo docker run --name puppet-master -it puppet7Start the Docker service:
sudo systemctl start dockerRun the Puppet Master container:
sudo docker start puppet-masterCheck if the container is running:
sudo docker ps -aInstalling Puppet Server:
apt install puppetserverEnter the container and install necessary utilities:
apt install vim net-toolsIf you encounter issues with broken packages, run the following commands:
apt update && sudo apt upgradecomm : apt –fix-broken install
apt cleanapt autoremove && sudo apt-get autoremoveapt-get install puppet-agentapt-get install puppet-module-puppetlabs-mailalias-coreapt-get install puppetserver
else
Check the Java version:
java -version(Note : Adjust Java configuration if necessary to manage system memory usage)
Check Puppet service:
netstat -ntulp(If you see port 8140, it means Puppet is listening to all ports.)
Set up the Certificate Authority:
/opt/puppetlabs/bin/puppetserver ca setup**
Check system information:**
facter -pFind the Fully Qualified Domain Name (FQDN):
facter -p | grep fqdnCreate a
.ppfile for Puppet configurations:puppet apply filename.ppCreating the Puppet Agent
Create the Puppet Agent container using the same image:
sudo docker run --name puppet-agent01 -it puppet(Note : Start and run the Puppet Agent container as described earlier)
Install Puppet Agent in the container:
apt install puppet-agentEstablishing Communication
Update
/etc/hostswith IP and FQDN:vi /etc/hosts (Note: Add the IP and FQDN at the end of the file)Run commands in the Puppet Agent container to establish communication with the master:
/opt/puppetlabs/bin/puppetserver ca setupIn the Puppet Master container, configure autosign in
/etc/puppetlabs/puppet/puppet.conf:autosign = true
In the Puppet Agent container, test the connection to the Puppet Master:
puppet agent --test puppet_masterfqdnManaging Puppet Policies for both(master & agent )
In the Puppet Master container, navigate to:
cd /etc/puppetlabs/code/environments/production/manifests/(Note : In this directory create this file )
Create
init.ppandsite.ppfiles to define policies and configurations.In the Puppet Agent container, run the following command to apply policies from the master:
To run again you have to run this command again and again :
puppet agent --test puppet_masterfqdnP.S.
If you spot any mistakes, please don’t hesitate to point them out. We’re all here to learn together! 😊
Haris
FAST (NUCES)
BS Computer Science | Class of 2027📌 GitHub: https://github.com/Zenvila
📌 LinkedIn: https://www.linkedin.com/in/haris-shahzad-7b8746291/
📌 Member: COLAB (Research Lab)
