How to Install and Configure Puppet on CentOS 7
Installation and Configuration of Puppet on Redhat 9/Redhat 8/Redhat 7/CentOS 8/CentOS 7
Puppet is an open source and enterprise configuration
management tool in DevOps. Puppet is use to configuring and managing the puppet
client machines that is connect with the puppet server by use of puppet agent. The
puppet use languages are Ruby DSL (domain-specific language) and puppet
language. The supported platform of puppet are Microsoft Windows,
Debian/Ubuntu, Red Hat/CentOS/Fedora and MacOS X. The configurations that manage the puppet
clients save on a puppet server is “config repository”, configuration has
written in compiled format (catalog). The files have a configuration that
applied on a puppet client machine is called “manifest”, the manifest files
extension is “.pp”. The manifest file will create on directory location
“/etc/puppet/manifests”, as per need multiple manifests file are create for
single purpose is called a module. The module must have readme file with a
basic description that how to use this module and module should have
metadata.json file that containing version, dependencies, information and
intended operating systems. To define resources (files, users, groups, command,
packages etc.) on puppet code classes are also use to organize code better and
reuse the code with the help of classes easily. The puppet master server connect
with puppet client machine through puppet agent, agent take all the information
from puppet master server by use of catalog then deploy the configuration on a
puppet client machine. Puppet master server use port 8140 to allow puppet
client machine to take the information from puppet master server by use of
puppet agent. Puppet client node (agent node) contact with the Puppet master
server in every 1800 seconds to take updated configurations (puppet codes) for
execute the necessary tasks. Puppet client node (agent node) communicate with
the Puppet master server through secure certificate.
Puppet is a leading tool of DevOps as compare to Chef to
automate the process for packages installation, server setup, system management
(users, groups, services) etc. Puppet is a software that allow system
administrator and developer work together. By use of puppet developer build,
test and launch the application without the need of system administrator that
allocate the resources.
Types of Puppet: There are the two types of puppet
available for system management to automate process of configuration centrally.
Open source Puppet: Open source puppet is a free software that download
from the puppet website freely and deployed on a Linux base operating system (RedHat/CentOS/Fedora
and Debian/Ubuntu) with some easy steps.
Enterprise Puppet: This version have cost to provide services and
features like command-line tools, compliance reporting, role-based access
control, GUI, API, and orchestration.
Benefit of Puppet: Puppet is based on Infrastructure
as code that resolve issue through continuous delivery and automated
deployment. Puppet also have platform that is open source developer community,
where free puppet codes are available on different scenarios.
The lab scenario are based on two machine on domain
environment “pakistan.local1”, details are mention below.
192.168.10.11
puppetmasterserver.pakistan.local1
192.168.10.226 lamp.pakistan.local1
Note: stop and disable the
service “firewalld” and set the selinux in permissive mode.
Puppet Server Machine: To install the Puppet server on server machine first enable the repository on server machine. To enable the repository on Redhat/CentOS/Fedora, type the below mention command.
For RedatHat 7yum install http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm -yoryum install http://yum.puppetlabs.com/puppet-release-el-7.noarch.rpm -yFor RedatHat 8dnf install https://yum.puppetlabs.com/puppet-release-el-8.noarch.rpm -yFor RedatHat 9dnf install https://yum.puppetlabs.com/puppet-release-el-9.noarch.rpm -y
ls -lrt /etc/yum.repos.d/
To install the package “puppet-server” on puppet server,
type the below mention command.
yum install puppet-server -y
To modify the main configuration file of puppet, modify the
file on directory location “/etc/puppet/puppet.conf” by use of editor “vi”.
vi /etc/puppet/puppet.conf
Provide the dns alt name and certificate name on main configuration file of puppet “/etc/puppet/puppet.conf”, this lab is perform in domain environment “pakistan.local1”.
dns_alt_names=puppet,puppet.pakistan.local1,puppetmasterserver.pakistan.local1certname = puppet
To generate the certificate on puppet master server, type
the below mention command.
sudo -u puppet puppet master --no-daemonize --verbose
To start, enable and check the status of service
“puppetmaster” on puppet server, type the below mention command.
systemctl start puppetmastersystemctl enable puppetmastersystemctl status puppetmaster
Puppet Client Machine: To install the Puppet on
client machine first enable the repository on client machine. To enable the
repository on Redhat/CentOS/Fedora, type the below mention command.
For RedatHat 7yum install http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm -yoryum install http://yum.puppetlabs.com/puppet-release-el-7.noarch.rpm -yFor RedatHat 8dnf install https://yum.puppetlabs.com/puppet-release-el-8.noarch.rpm -yFor RedatHat 9dnf install https://yum.puppetlabs.com/puppet-release-el-8.noarch.rpm -y
To install the puppet agent on client machine, type the
below mention command. Puppet agent is used to communicate puppet client
machine with the puppet server machine for centrally manage the catalog
configurations that apply from puppet master server to puppet client machine.
yum install puppet -y
Modify the puppet
configuration file on client machine by use of editor “vi”, the puppet
configuration file is availaible on directory location “/etc/puppet/puppet.conf”.
vi /etc/puppet/puppet.conf
Add the server IP address or hostname or fully qualified
domain name on client machine puppet configuration file in Agent area.
server = puppetmasterserver.pakistan.local1
After modify the puppet
configuration file on client machine, start and enable the service “puppet” by
type the below mention command.
systemctl start puppetsystemctl enable puppet
Server Machine: To sign the puppet client machine certificate on puppet server machine, first
list the certificate then sign the certificate by type the below mention
command.
puppet cert listpuppet cert sign lamp.pakistan.local1puppet cert sign --all
This is the acknowledge or sign the client certificate.
Connection between the puppet master and agent has been establish.
Client Machine: To verify the certificate sign properly from puppet master node to puppet client node, type the below mention command.
puppet agent --fingerprint
puppet agent -t
vi /etc/puppet/manifests/site.ppExample 1: Start or Stop with Enable or Disable any service from puppet master server to puppet client machine (puppet agent install machine).
node default {service { 'httpd':ensure => 'running',enable => 'true',}}
node default {service { 'httpd':ensure => 'stopped',enable => 'false',}}
Install downloaded Puppet Module:puppet module install /owais/abc.tar.gzorpuppet module install /owais/vimInstall Puppet Module through Internet:puppet module install vim
vi /etc/puppet/manifests/site.pp
node default {class { 'vim':}}
node 'host1', 'host2' {class { 'vim':}}
puppet module search vim
mkdir /etc/puppet/modules/postfixThen we will create a directory "manifests" in the directory location "/etc/puppet/modules/postfix" by use of command "mkdir".
mkdir /etc/puppet/modules/postfix/manifests
vi /etc/puppet/modules/postfix/manifests/init.pp
class postfix {#Intall Postfix (mail server) Packagepackage {'postfix':ensure => present,}#Postfix service enable and runningservice {'postfix':ensure => running,enable => true,}}
node default { }node 'host1', 'host2' {include postfix}
puppet parser validate site.pp
puppet resource --types
puppet resource service postfixpuppet resource file /etc/hostspuppet resource mount /appspuppet resource user owais
puppet describe --listorpuppet describe file
runinterval = 15m
Comments
Post a Comment