Puppet is a powerful configuration management tool that automates the process of managing your infrastructure. Setting up a Puppet Master and its clients can seem daunting, but with this guide, you'll be equipped to handle the initial configuration with ease. This blog will walk you through the steps needed to set up a Puppet Master and client, ensuring a smooth and secure connection between them.
Step 1: Initial Setup for Both Master and Client
Downloading and Installing Needed RPM
Before you begin, ensure that both the Master and the client machines have the necessary RPM installed. This can be done by running:
rpm -ivUh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
This command will install the EPEL (Extra Packages for Enterprise Linux) repository, providing additional packages for your setup.
Step 2: Installing the Puppet Server and Client
Master: Installing Puppet Server
On your Master machine, install the Puppet Server with Yum:
yum install puppet-server
Client: Installing Puppet
On the client machine, install the Puppet client software:
yum install puppet
Step 3: Configuring Hostnames and Network
Ensure that the Master and client can communicate with each other by setting up the hostnames correctly.
Edit the Hosts File
Add the following entries to the /etc/hosts file on both the Master and client:
xxx.xxx.xxx.xxx master.puppet.com
xxx.xxx.xxx.xxx client.puppet.com
Replace xxx.xxx.xxx.xxx with the appropriate IP addresses.
Test the Connection
Test the connectivity between the Master and client using the ping command:
ping -c 3 client.puppet.com
ping -c 3 master.puppet.com
Step 4: Setting Up Iptables
For secure communication, you need to ensure that the correct port is open on both the Master and client.
Modify Iptables Rules
You can either disable Iptables or open port 8140, which Puppet uses for communication:
iptables -A INPUT -p tcp --dport 8140 -m state --state NEW,ESTABLISHED -j ACCEPT
Step 5: Starting the Puppet Master Server
With the configurations set, it's time to start the Puppet Master.
Start the Server
On the Master machine, start the Puppet Master service:
/etc/init.d/puppetmaster restart
Step 6: Client Certificate Signing
Puppet uses a certificate-based authentication system. The client will request a certificate from the Master, which needs to be signed.
Check for Signed Certificates
From the client machine, initiate a certificate signing request:
puppetd --server=master.puppet.com --waitforcert 60 --test
Sign the Client's Certificate
On the Master, list all unsigned certificates:
Sign the client's certificate:
puppetca --sign client.puppet.com
Step 7: Creating Configuration for Clients
With the infrastructure in place, you'll now need to define the desired state of your client systems in the Puppet Master.
Edit the Manifest File
Add configurations to /etc/puppet/manifests/site.pp on the Master. Here's a sample configuration:
# Create "/tmp/testfile" if it doesn't exist.
file { "/tmp/outside":
ensure => present,
mode => 644,
owner => root,
group => root
}
class test_class {
file { "/tmp/testfile":
ensure => present,
mode => 644,
owner => root,
group => root
}
}
package {
'httpd':
ensure => installed }
service {
'httpd':
ensure => true,
enable => true,
require => Package['httpd']
}
# tell puppet on which client to run the class
node client {
include test_class
}
Conclusion
Congratulations! If you've followed these steps without error, your Puppet Master and client are now configured and communicating securely. With your infrastructure now under Puppet's management, you're set to automate your configurations, ensuring consistency and reliability across your environment. Remember, Puppet is incredibly powerful and flexible. Continue exploring its capabilities to fully harness its potential in managing your infrastructure.