Table of Contents
“Puppet” is an open-source system management and configuration management tool. It is used to automatically configure and manage a computer system, providing utility in ensuring consistency, tracking configurations, and applying changes in large-scale computer systems.
Puppet primarily supports various operating systems, including Linux and Unix-based systems. It is also applicable in cloud environments and on physical servers. Puppet enables a system administrator to define a specific target state, and it automatically applies the necessary steps to reach that target state.
The fundamental components of Puppet include:
- Manifests: Files written in the Puppet language that define a specific system state.
- Modules: Building blocks containing reusable Puppet manifests and other files.
- Facts (Facter): A database representing system information collected by Puppet.
- Agents: Software running on systems that communicate with the Puppet master to apply configuration changes.
Puppet assists many organizations in effectively managing complex system infrastructures. Configuration changes can be easily rolled back and traced, providing system administrators with greater control. While Puppet is an open-source project, there is also a commercial version called Puppet Enterprise.
To install Puppet, you can follow the steps below. However, always refer to the most up-to-date documentation and adhere to security best practices, as software and instructions may change over time.
Installing Puppet Agent (Client):
- Add Repository (Ubuntu):
sudo apt-get update sudo apt-get install -y puppet
- Add Repository (CentOS/RHEL):
sudo yum install -y epel-release sudo yum install -y puppet
- Start Agent Service (Ubuntu):
sudo systemctl start puppet sudo systemctl enable puppet
- Start Agent Service (CentOS/RHEL):
sudo systemctl start puppet sudo systemctl enable puppet
Installing Puppet Server (Master):
- Add Repository (Ubuntu):
sudo apt-get update sudo apt-get install -y puppetserver
- Add Repository (CentOS/RHEL):
sudo rpm -Uvh https://yum.puppet.com/puppet6-release-el-7.noarch.rpm sudo yum install -y puppetserver
- Start Server Service:
sudo systemctl start puppetserver sudo systemctl enable puppetserver
Configuring Puppet Server and Agent:
- Server Configuration (Master): Edit the server configuration file (usually
/etc/puppetlabs/puppet/puppet.conf
) to configure server settings. - Agent Configuration (Client): Edit the agent configuration file (usually
/etc/puppetlabs/puppet/puppet.conf
) to configure agent settings and specify the server address. - Manage Certificates: Certificates are required for communication between the server and agent. Puppet Certificate Authority (CA) is used to manage server and agent certificates.
These steps provide a general framework for using Puppet in a basic installation. However, it’s crucial to review specific system requirements, security policies, and documentation for future Puppet versions.
Puppet Basics:
- Manifests:
- Puppet code files with a
.pp
extension.
- Puppet code files with a
- Modules:
- Directory structures containing manifests, files, and templates.
Puppet Commands:
- Apply Manifest:
puppet apply <manifest_file.pp>
- Check Puppet Version:
puppet --version
Puppet Resources:
- Define File Resource:
file { '/path/to/file': ensure => present, content => 'File content', }
- Define Package Resource:
package { 'package_name': ensure => installed, }
- Define Service Resource:
service { 'service_name': ensure => running, }
Puppet Modules:
- Create Module:
puppet module generate <module_author>-<module_name>
- Install Module:
puppet module install <module_author>-<module_name>
Puppet Server:
- Start Puppet Server:
sudo systemctl start puppetserver
- Restart Puppet Server:
sudo systemctl restart puppetserver
- Check Puppet Server Status:
sudo systemctl status puppetserver
Puppet Agent:
- Run Puppet Agent Manually:
sudo puppet agent -t
- Enable Puppet Agent at Boot:
sudo systemctl enable puppet
Puppet Certificates:
- List Pending Certificates:
sudo puppetserver ca list --all
- Sign Certificate:
sudo puppetserver ca sign --certname <certname>
- Revoke Certificate:
sudo puppetserver ca revoke --certname <certname>
Puppet Facts:
- View Node Facts:
sudo facter
- View Specific Fact:
sudo facter <fact_name>
This cheat sheet provides a quick reference for some common Puppet commands and concepts. For more in-depth information, refer to the official Puppet documentation.