Puppet User Handbook

Are you a programmer looking for a powerful tool to manage your servers? If yes, then you must take Puppet into consideration.

This Puppet cheat sheet is designed for those who have started their journey with Puppet and need a handy reference to implement what they have learned in real-time.

You can also download the printable PDF of this Puppet cheat sheet

Puppet Cheat Sheet

In the early days of software development, everything was done manually such as inspecting, operating, and delivering applications. Later on, different phases of SDLC started getting automated, and it is there Puppet came into the picture.

Puppet is an open-source configuration framework. It is a tool that gives an automatic way of inspecting, delivering, and operating applications faster. It helps in discovering content in cloud, containers, and on-premises systems and what software runs on them.

Go through these Top DevOps Interview Questions and Answers and crack any DevOps interview!

Watch this Puppet Tutorial for Beginners:

Puppet Cheat Sheet

Youtube subscribe

What is Puppet?

It is an open-source system management tool used for automating configuration management, a detailed recording and updating of information that describes the enterprise software and hardware.

This configuration framework is useful:

  • When we have a lot of machines needed to be configured in a similar way
  • When we have an infrastructure that requires dynamic scaling up/down with pre-determined config
  • To have control over all the config machines so that a centralized change gets propagated

Certification in Cloud & Devops

Puppet Architecture

Further, in this tutorial, we will look into the architecture of Puppet. The below image shows the components and workflow of Puppet:

Puppet Architecture

  • Node: It consists of a block of Puppet code.
  • Puppet Master: It is the master node that controls the flow and has the authority.
  • Catalog: It is a document describing the state of resources on a node, which is managed by Puppet.
  • Report: It is a record of the actions and infrastructure applied by a catalog during a Puppet run

Files

In Puppet, all programs, written in any programming language, are stored in a file that is used to manage directories and symlinks.

Go through the Best DevOps Course in New York to learn DevOps from scratch!

Attributes:

  • Ensure if the file exists or not and what it should be. Allowed:
    • File
    • Directory
    • Link
    • Present
    • Absent
  • Normal files:
    • Source: The source of a file
    • Content: The desired content as a string
  • Directories:
    • Source: The source of a file
    • Recurse: Whether to recursively manage the files in the directory
    • Purge: Whether the unmanaged files in the directory should be deleted
  • Symlinks:
    • Target: The symlink target
  • Others: backup, checksum, force, ignore, links, and replace

Package

It is used to manage software packages.

Attributes:

      • Name: The name of the package
      • Ensure if it should be installed or not
      • Present
      • Latest
      • Absent
      • Purged
      • Source: Where to obtain the package
      • Provider: Which packaging system to use

Want more? Learn about DevOps in-depth from this DevOps Training in Sydney!

Service

It is used to perform routine maintenance.

Attributes:

    • Name: The name of the service to run
    • Ensure the status whether it is running or stopped
    • Enable: If it should start on boot
    • Hasrestart: Whether to use the init script restart command instead of stop+start
    • Hasstatus: Whether to use the init script status command

Become a Cloud and DevOps Architect

Master DevOps by taking up this online DevOps Training in London!

Classes and Modules

Classes:

Defining classes makes the class available by its name but not by the code inside. Declaring a class evaluates the code inside too.

class my_class {
... puppet code ...
}
include my_class

Modules:

By stowing the implementation of a feature in a module, our main manifest can become much smaller, more readable, and policy-focused.

Module structure:

    • A module is a directory.
    • Module and directory names have to be the same.
    • A module contains the manifest directory (contains .pp files).
    • It should contain the init.pp file.

Don’t you dream of becoming a DevOps expert? Sign up for the DevOps Course in Toronto today!

Puppet CLI

Puppet CLI consists of a single Puppet command with multiple sub-commands.

  • Bootstrap client: Tasks that bootstrap or install Puppet on the agent node
puppet agent -t --server <puppet master> [<options>]
  • Displaying facts:
facter              # All system facts
facter -p           # All system and Puppet facts
facter -y           # YAML
facter -j           # JSON
facter [-p] <name>  # A specific fact
  • Injecting facts:
env FACTER_= puppet apply site.pp
  • Finding out effective classes on a node:
cat /var/lib/puppet/classes.txt
  • Finding out the file modification date:
cd /var/lib/puppet
for i in $(find clientbucket/ -name paths); do
echo "$(stat -c %y $i | sed 's/\..*//')       $(cat $i)";
done | sort -n
  • Disabling and enabling Puppet agent:
puppet agent --disable
puppet agent --disable <info message> #Only recent versions
puppet agent --enable\
  • Managing certificates:
puppet cert list
puppet cert list --all
puppet cert sign <name>
puppet cert clean <name> #Removes cert
  • Managing nodes:
puppet node clean <name> #Removes node + cert
  • Managing modules:
puppet module list
puppet module install <name>
puppet module uninstall <name>
puppet module upgrade <name>
puppet module search <name>

Watch this interesting video on Puppet Installation:

Puppet Cheat Sheet

Youtube subscribe
  • Inspecting resources and types:
puppet describe -l
puppet resource <type name>
puppet kick <name>
puppet kick -p 5 <names> #To trigger puppet from master
  • Debugging and deploying:
puppetd --test #To enable standard debugging options
puppetd --debug #To enable full debugging
puppetd --one-time --detailed-exitcodes #To enable exit codes
# 2=changes applied
# 4=failure
  • Other commands:
FunctionCommand
To check the versionPuppet –version
File content manifest – site.ppfile { ‘/tmp/dafile’:
content => “datext\n”,
}
File content manifest – multiple nodesnode ‘danodename’ {
file { ‘/tmp/dafile’:
content => “datext\n”,
}
}
To remove packagespackage { ‘apache2.0-common’:
ensure => absent,
}
To update packagespackage { ‘puppet’:
ensure => latest,
}
To start service at the boot timeservice { ‘nginx’:
ensure => running,
enable => true, #false disables auto-startup
}
To set to a specific versionpackage { ‘nginx’:
ensure => ‘1.1.18-1ubuntu0.1’,
}

Interested in getting an industry-recognized certification in DevOps? Enroll in Intellipaat’s DevOps Course in Bangalore!

Advantages of Puppet

  • Infrastructure as code(IAC): Puppet enables us to define IAC by easily coding a few scripts. It consists of version control, peer review, automated testing, and delivery.
  • Reduced downtime
  • Faster deployment time
  • Easy automation of repetitive tasks
  • Supports a lot of platforms like Windows, Debian, BSD, etc.

DevOps Engineers are among the highest paid professionals in the technology domain? Join DevOps Training in Hyderabad now!

In this Puppet cheat sheet, we covered almost all Puppet topics that you should know to start working with it. If you want more, Intellipaat has resources that would satisfy your quest.

If you are planning to learn DevOps in-depth, then enroll in Intellipaat’s DevOps Certification Training today!

We at Intellipaat will never leave you disappointed as our approach is not just theoretical; the course we offer will provide you step-by-step guidance and support to implement what you have learned about DevOps.

In the course, all the important DevOps concepts are included such as Docker, Chef, Git/GitHub, Ansible, Jenkins, Kubernetes, Selenium, Nagios, etc., along with Puppet. Sign up with us today and follow the right learning path toward DevOps!

Leave a Reply

Your email address will not be published. Required fields are marked *