Tags
Cloud Computing, Configuration Management tool, DevOps, Infrastructure as code, Installation and Configuration, Open Source, Public Cloud, Puppet
Puppet is an open-source configuration management and automation tool that allows sysadmins to define infrastructure as code. In this blog post, we will explore the fundamentals of Puppet, its architecture, and how it can empower organizations to achieve scalable and consistent infrastructure management.
Why Puppet ?
Puppet is chosen for its ability to automate and maintain consistent configurations across diverse IT environments using infrastructure as code, ensuring efficiency, scalability, and centralized management.
Puppet Architecture :
Requirements
Launch two ubuntu instances(master and slave).
Connect to the Master Node:
Download the Puppet and install the Master
wget https://apt.puppetlabs.com/puppet-release-bionic.deb
Unpack the package :
sudo dpkg -i puppet-release-bionic.deb
Install Puppet Master :
sudo apt-get install puppet-master
Enable it :
sudo systemctl enable puppet-master
Start Puppet :
sudo systemctl start puppet-master
To communicate with slave nodes, enable the firewall :
sudo ufw allow 8140/tcp
Give the host address :
sudo nano /etc/hosts
Connect to the Slave node and download the puppet package and install puppet agent:
sudo apt-get install puppet
Give the host address :
sudo nano /etc/hosts
Give the ip of the master node.
Enable it :
sudo systemctl enable puppet
Start Puppet :
sudo systemctl start puppet
After this, go to Master and check if any certificates has been sent to the master.
sudo puppet cert sign –-all
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Warning: `puppet cert` is deprecated and will be removed in a future release.
(location: /usr/lib/ruby/vendor_ruby/puppet/application.rb:370:in `run')
Sign the Certificate :
sudo puppet cert sign –-all
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Warning: `puppet cert` is deprecated and will be removed in a future release.
(location: /usr/lib/ruby/vendor_ruby/puppet/application.rb:370:in `run')
After signing this, both the master and slave nodes can interact.
Manifest – It is the collection of resource declaration using .pp extension
Create a manifest file by going to the directory :
cd /etc/puppet/code/environments/production/manifests
Create site.pp file
nano site.pp
file {'/tmp/test.txt':
ensure => present,
mode => '0644',
content => "it works on ${ipaddress_eth0}!\n",
}
Restart puppet :
sudo systemctl restart puppet-master
Go to Slave node :
Check for the changes
sudo puppet agent --test
Read the file :
root@puppet-2:~#cat test.txt
It works on 192.168.101.66!
Go to the directory :
Now, we wil install Nginx in the slave node by modifying the manifest file.
cd /etc/puppet/code/environments/production/manifests
Create site.pp file
nano site.pp
Create file :
node default{
package {'nginx':
ensure => installed,
}
file {'/tmp/status.txt':
content => 'Nginx Installed',
mode => '0644',
}
}
Save and Exit.
Check for the changes in the slave node :
sudo puppet agent --test
Go to web browser and type the ip address :
As you can see, Nginx has been successfully installed on the slave node.