Introduction of Puppet
What is Puppet?
Puppet is a configuration management tool available as an
open-source and enterprise versions. It runs on many Unix based
systems as well as on Windows.
Puppet is produced by Puppet Labs, founded in 2005. It is written in
Ruby and released as free software under the GNU General Public
License (GPL) until version 2.7.0 and the Apache License 2.0 after
that.
Puppet is designed to manage the configuration of Unix-like and
Microsoft Windows systems declarative. The user describes system
resources and their state, either using Puppet declarative language or
Ruby DSL (domain-specific language)
Why do we use Puppet?
We use Puppet, because puppet is a configuration
management tool which is more powerful that helps system
administrators to automate the provisioning, configuration,
and management of a server infrastructure. Puppet enables
system administrators and DevOps to work faster and
smarter.
How Puppet works?
This information is stored in files called “Puppet manifests”
with extension of “.pp”. Puppet discovers the system
information via a utility called Facter, and compiles the
Puppet manifests into a system-specific catalog containing
resources and resource dependency, which are applied
against the target systems. Any action taken by Puppet are
then reported.
Puppet Architecture
Puppet
Node1 Agent | Facter
Dashboard
Module Forge Puppet
Master
Node2 Puppet
Data
Agent | Facter
Puppet Architecture Components?
Puppet Master
Puppet master is a service runs on the main server which
used to manage the entire clients to deploy, configure and
maintains the infrastructures.
Puppet Architecture Components?
Puppet Agent
Puppet master is a service which runs on the client sends the
request the catalog to the puppet master and applies it by
checking each resource the catalog describes. If it finds any
resources that are not in their desired state, it makes any
changes necessary to correct them.
After applying the catalog, the agent submits a report to the
Puppet master.
Puppet Architecture Components?
Catalog
A catalog is a document the describes the desired system
state for one specific server. It lists all of the resources that
need to be managed, as well as any dependencies between
those resources.
Puppet Architecture Components?
Manifests
Manifests are files with extension “.pp”, where we declare all
resources to be checked or to be changed. Resources may
be files, packages, services and so on.
Puppet Architecture Components?
Resources Types
type (package, service, file, user, mount, exec)
Title (how the resources types are called and referred)
Puppet Architecture Components?
Sample syntax
type { ‘title’:
argument => value,
other_arg => value,
}
Samples of Resources
Verify the openssh package
package { ‘openssh’:
ensure => present,
}
Samples of Resources
Create a /etc/devops file
file { ‘devops’:
path => /ect/devops,
}
Samples of Resources
Start httpd service
service { ‘httpd’:
ensure => running,
Enable => true,
}
Samples of Resources
Use below command
puppet describe --list
Classes
class mysql (
root_password => ‘defautl_value’,
port => 3306,
)
{
package { ‘mysql-server’:
ensure => present,
}
Service { ‘mysql’:
ensure => running,
}
}
How the puppet connections are getting established between puppet
master and puppet agent node?
Puppet agent nodes and Puppet masters
communicate via https with client-verification.
The Puppet master provides an http
interface, with various endpoints available.
Puppet Node2
Master
When requesting or submitting anything to
the master, the agent makes an https request
to one of those endpoints.
Build Lab for Puppet
Node2
Puppet
Master
Hostname: master Hostname: client
Role: Puppet Master Role: Puppet Agent
OS: RHEL OS: RHEL
IP address: 10.0.0.4 IP address: 10.0.0.5
Prerequisites
● Make sure both servers are accessible
● Make sure an entry of each host in
/etc/hosts for name resolution on both
Puppet
nodes or configure it in DNS to resolve Node2
Master the IP.
cat /etc/hosts
10.0.0.4 master.sans.lan master
10.0.0.5 client.sans.lan master
Prerequisites
● Disable firewall on both nodes if enabled
systemctl stop firewalld;
systemctl disable firewalld
Puppet Node2
Master
● Make sure internet connection on both
nodes to install packages from
puppetlabs repositories.
● Update servers.
Prepare
Server
Now.. Node
Puppet
Master
Hostname: master Hostname: client
Role: Puppet Master Role: Puppet Agent
OS: RHEL OS: RHEL
IP address: 10.0.0.4 IP address: 10.0.0.5
Install Step by Step
● Install puppetlabs repository on both servers (M/C)
yum -y install
http://yum.puppetlabs.com/puppetlabs-release-el-
Puppet
Master
7.noarch.rpm
Node
Install Step by Step
● Install required package on the master server
yum -y install puppet-server
Puppet
Master
Install Step by Step
● Modify the puppet.conf file
vi /etc/puppet/puppet.conf
Puppet
Master [main]
dns_alt_names = master master.sans.lan
certname = master
[agent]
:wq
Install Step by Step
● Generate the certificate in Master
sudo -u puppet puppet master --no-daemonize --verbose
Once the certificate is generated press Ctrl + C
Puppet
Master
Install Step by Step
● Start puppet service and enable
systemctl start puppetmaster
systemctl enable puppetmaster
Puppet
Master
Install Step by Step
● Install puppet agent in client
yum -y install puppet
Node
Install Step by Step
● Modify the puppet.conf file in client
vi /etc/puppet/puppet.conf
[main]
Node
[agent]
server = puppet.sans.lan
:wq
Install Step by Step
● Generate the signing request certificate from the
puppet agent node client.
puppet agent -t
Node
Install Step by Step
● sign the certificates to be signed from the puppet
master node master
puppet cert list
Puppet You can see one certificate is requested.
Master
puppet cert sign client.sans.lan
Install Step by Step
● start and enable puppet agent server in client
systemctl start puppet
systemctl enable puppet
Node
Install Step by Step
● Verify the certificate signed properly with the
puppet master.
puppet agent --fingerprint
Node