Why Puppet?

The Basics

By scmGalaxy.com

About Me

DevOps@RajeshKumar.XYZ

Problem

A tale of growth...

application for configuration management-puppet

Add a database

add a database for configuration management

Make database redundant

make database redundant for configuration management

Application server redundancy

application server redundancy for configuration management

Add a load balancer

add a load balancer for configuration management

Webscale!

webscale for configuration management

Now we need a caching layer

now we need a caching layer for configuration management

Infrastructure has a Topology

infrastructure has a topology for configuration management

Your Infrastructure is a Snowflake

your infrastructure is a snowflake for configuration management

Complexity Increases Quickly

complexity increases quickly for configuration management puppet

Puppet Solves this problem

4 Major Challenges for SysAdmin

4 major challenges for of puppet

Why not use script?

  • Write
  • Test
  • Debug

Scripts Take Time

Scripts Are Procedural

Scripts Are Idiosyncratic

  • Multiple ways of doing the same thing
  • A script written by one person may be indecipherable to another

Script must be written for each Operating
System version or Distribution

  • We will talk about Windows Later, lets check it in Linux

Package Managers and Names Differ Across Distributions

Service Managers Differ Across Versions of the Same Distribution

    CentOS/RHEL 6

  • Upstart
    • restart httpd


CentOS/RHEL7

  • systemd
    • systemctl restart httpd

What about Windows?

Windows is not Immune

MP owerShell Script written in version 2
may not natively work in versions 3+

What about Group Policies?

Don’t support non Windows operating systems

Requiresan Active Directory infrastructure

Extensible... using scripts

Solution - Puppet

Puppet overcome the shortcomings of other
configuration management approaches

Puppet Programs are Declarative Vs Procedural

“What”instead of “how”

Less complex

Easy to create,understand,and share

Puppet Abstracts Resources

puppet abstracts resources
  • A single Puppet program can work on different operating systems and distributions
a single puppet program can work

One Puppet Master to Rule Them All

Other Tools…

  • What about other configuration management systems?

InfoWorld ScoreCard(2013)

infoworld-scorecard(2013) for puppet

CFEngine and Chef

    CFEngine

  • Complex
  • Behaves differently across operating systems

Chef

  • Requiresknowledgeof Ruby

Puppet is used by

puppet is used by management systems

End of this session

end of this session for puppet

What is Puppet?

Puppet manages your infrastructure. You describe configurations in an easy-to-read declarative language, and Puppet will bring your systems into the desired state and keep them there.

You have a problem.

But there is a solution.

End of this session

/puppet master
configuration management puppet
node at work puppet

So what's really gonig on?

So what's really gonig on?

DESIRED STATE

drift for puppet
puppet agent
the puppet master compiles
puppet for m n
nice reports for puppet

What is Puppet Enterprise?

At the end of this course you will be able to:

  • Explain what Puppet Enterprise is.
  • List the benefits of using Puppet Enterprise.
  • Puppet Enterprise is IT automation software that gives system administrators the power to easily automate repetitive tasks, quickly deploy critical applications, and proactively manage infrastructure, on-premises or in the cloud.
  • Puppet Enterprise automates tasks at any stage of the IT infrastructure lifecycle, including: discovery, provisioning, OS & app configuration management, orchestration, and reporting.

Puppet Concept

Prerequisite Knowledge

  • Basic Linux Administration from the shell

    • Text editing
    • SSH

Puppet Architecture

Server is called the Puppet Master

Client are called nodes

Puppet Master

linux for cofiuration management puppet

Nodes

run the puppet agent

Master and Nodes

master and nodes for configuration management puppet

Individual configuration items are called resource declarations

Resource Declaration Answer following….

resource declaration answer following-puppet

Resource Declaration

resource declaration of puppet

Types

Package

File

Service

Type - Title

type title of configuration management puppet

Type – Title - Attributes


						    

	node 'apserver'{
	Package {'ntp':
	ensure => installed,

	}
	...
	                       
					   

Package Resource Type

Ensures the ntp package is installed on appserverOl

Resource Title

resource title of configuration management puppet

File resource type

file resource type of configuration management puppet

Service resource type


						    
 ...
	service { 'ntpd':
	ensure => 'running',
	enable => true,
	}
   }
	                       
					    

Service Resource Type

Ensures the ntpd service is enabled and running

Resource Attributes

Answers the question,”What state do we want this resource in?”

=> Attribute/value pairs are separated by a “fat comma”

Resource Providers

resource providers of configuration management puppet

Providers for the Package resource Type


yum (RedHat)

apt(Ubuntu)

Windows(Windows)

Configuration Run


Node

  • Connects to Puppet Master
  • Sends facts about itself
    • Operating system
    • CPU architecture
    • Block devices
    • Network information

Configuration Run


Puppet Master

  • Classifies the node
  • Compiles a catalog
    • Desired state of each resource
    • Dependencies
  • Sendscatalogto node

Configuration Run


Node

  • Applies the catalog
  • Reports results to Master

Creating Manifest

Elements of a Puppet Manifest

elements of a puppet manifest

The node.pp Manifest

Stored in /etc/pu ppet/environ ments/prod uction/manifests


Puppet automatically loads all .pp files in the manifests directory

Creating a nodes.pp Manifest


						    
	$ sudo nano
	/etc/puppet/environments/production/manifests/nodes . pp
	
	node 'wiki'{
	}
	
	node 'wikitest'{
	}
	                       
					   

What Is the Goal?

Create a simple text file on each

Puppet node that says/’Created by

Puppet”followed bya timestamp

Resource Type – File
Managing Files
Goal

Create a simple text file on each

Puppet node that says/’Created by

Puppet”followed bya timestamp

Node.pp


	file{'/info.txt':
	ensure  => 'present',
	content => inline_template(created by puppet at <%= Time.now %>\n"),
	}
						    

                    
					       

Node.pp


        node 'wiki'{
		
	    file { '/info.txt':
		ensure  => 'present',
		content => inline_template(created by puppet at <%= Time.now %>\n"),
		}|
		
	}
	
	node 'wikitest'{
	}
					       

Run from Agent

run from agent-of puppet

What about the puppet override the file and for
some reason we need to recover the version>

The Client Filebucket

  • Stored on the node in
    /var/lib/puppet/clientbucket by default

Run from Agent

configuration of puppet

Managing Packages


	package{ 'ntp':
	
	  ensure =>  'installed',
	  
	}

					       

        node 'wiki'{
		
	 file { '/info.txt':
		ensure  => 'present',
		content => inline_template(created by puppet at <%= Time.now %>\n"),
	  }
		package{ 'ntp':
	
	     ensure =>  'installed',
	  }
	}
	node 'wikitest'{
	
		package{ 'ntp':
			ensure =>  'installed',
	  }
	}
					       
puppet for configuration management

Managing Services


	service { 'ntpd':
		ensure => 'running',
		enable => true,
	}
	
	service { 'ntp':
		ensure => 'running',
		enable => true,
	}
			       
managing service for configuration puppet
puppet for configuration

Selectors


	 $ntpservice = $osfamily ? {
	 
		'redhat' => 'ntpd',
		
		'debian' => 'ntp',
		
		default =>  'ntp',
	}
			           

    Constructing a Selector

  • A selector assigns one of a set of possible values to a variable based on a condition

	Replace:
	
	service { 'ntpd':
		ensure => 'running',
		enable => true,
	}
	With:
	
	service { $ntpservice:
		ensure => 'running',
		enable => true,
	}
			             

Classes

DRY = Don’t Repeat Yourself!

Puppet class # object-oriented class

Puppet ciass

A named collection of resource declarations,
variables, selectors, or any other Puppet code

Class Definition and Usage


	class linux {
	
	   package {'ntp':
	   
		ensure => 'installed',
	   }
	}

	node 'wiki' {
	
	   { class 'linux': }
	}
			           

Variables


	class linux {
	
	   $admintoo1s = ['git' 'nano', 'screen']
	   
	    package { $admintoo1s:
		ensure => 'installed',
	   }
	}

			           

Questions?

docker questions

Thanks for You