SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Puppet Configuration Management
Afroz Hussain
Agenda
1. Puppet Overview
 What is Puppet
 How puppet works?
 Puppet Architecture
2. Installation and Configuration
 Installing Puppet
 Configuring Puppet Master and Agent
3. Puppet Master
 Puppet configuration tree
 Puppet configuration files
4.Puppet Language Basics
 The declarative language
 Resources
Agenda (Cont..)
5. Puppet Language Advanced
 Facter
 Variables
 Conditional statement
 Templates
 Resource relationship
Agenda (Cont..)
3. Provisioning Hosts with Puppet
 Configuring Nodes
 Versioning Modules
 Creating Modules for NTP
 Puppet Forge
 Extending puppet with custom facts, types and providers
 Mcollective
 Troubleshooting and Best Practices.
Puppet Overview
What is Puppet ?
 Puppet is a configuration management system that allows you to define the
state of your IT infrastructure, then automatically enforces the correct state.
 Puppet automates tasks that system admins often do manually, freeing up
time and mental space so system admins can work on the projects that
deliver greater business value.
 Puppet automates every step of the software delivery process: from
provisioning of physical and virtual machines to orchestration and reporting.
 Puppet ensures consistency, reliability and stability. It also facilitates closer
collaboration between system admins and developers, enabling more efficient
delivery of cleaner, better-designed code.
Puppet Overview
How puppet works?
 Once you install Puppet, every node (physical server, device or virtual machine) in
your infrastructure has a Puppet agent installed on it. You'll also have a server
designated as the Puppet master.
 Enforcement takes place during regular Puppet runs, which follow these steps:
 Fact collection. The Puppet agent on each node sends facts about the node's
configuration — detailing the hardware, operating system, package versions and other
information — to the Puppet master.
 Catalog compilation. The Puppet master uses facts provided by the agents to compile
detailed data about how each node should be configured — called the catalog — and
sends it back to the Puppet agent.
 Enforcement. The agent makes any needed changes to enforce the node's desired state.
 Report. Each Puppet agent sends a report back to the Puppet master, indicating any
changes that have been made to its node's configuration.
 Report sharing. Puppet's open API can send data to third-party tools, so you can share
infrastructure information with other teams.
Puppet Overview
Puppet Architecture
Puppet Overview
Puppet Architecture
 Configuration Language:
 “Puppet’s configuration language has always been focused on the best combination of simplicity and power, and my
goal was always to have it be more like a configuration file than a programming language,” wrote Luke Kanies, founder
and CEO of Puppet Lab.
 It supports DSL (domain specific language).
 Transaction
 Once the catalog is entirely constructed, it is passed on to the Transaction
 Transaction runs on the client, which pulls the Catalog down via HTTP
 The transaction performs a relatively straightforward task: walk the graph
the order specified by the various relationships, and make sure each resource is in sync.
 Resource Abstraction Layer
 the work is actually done by the Resource Abstraction Layer (RAL),
 The RAL was the first component created in Puppet, it most clearly
defines what the user can do.
 The job of the RAL is to define what it means to be a resource and how
resources can get work done on the system
Installation and Configuration
Installation
 Step 1: Enable the Puppet Labs Package Repository
 $ sudo rpm -ivh http://yum.puppetlabs.com/el/6.4/products/x86_64/puppetlabs-release-6-7.noarch.rpm
 After installing the repos, open your /etc/yum.repos.d/puppetlabs.repo file for editing. Locate the
[puppetlabs-devel] stanza, and change the value of the enabled key from 0 to 1:
 Step 2: Install Puppet on the Puppet Master Server
 On your puppet master node, run sudo yum install puppet-server
 $ sudo puppet resource package puppet-server ensure=latest
 You’ll need to restart the puppet master web server after upgrading.
 Step 3: Install Puppet on Agent Nodes
 On your other nodes, run sudo yum install puppet
 $ sudo puppet resource package puppet ensure=latest
 You’ll need to restart the puppet service after upgrading.
Installation and Configuration
Configure Puppet Master Server
Installation and Configuration
Configure Puppet Agent
Puppetmaster
Puppet Configuration tree
 Puppet.conf
 General puppet master settings
 Auth.conf
 General ACL which control http access
 Filesever.conf
 it isn’t necessary- Puppet automatically serves files from the files directory of
modules, and most users find this sufficient.
 Manifests directory
 Site.pp: global default conf
 Nodes.pp: manage nodes
 Modules: contains all modules
Puppetmaster
Puppet Configuration files
Puppet language basics
The declarative language
 About the language:
 With Puppet, we declare how the node must be.
 Everything you want to manage have to be explicitly declared.
 A Puppet program is called a manifest
 Central manifest : site.pp
 Puppet load modules manifests
 into manifests, we define classes.
 We write resources inside these classes
Puppet language basics
The declarative language
 The declarative language
 The fundamental unit of modeling
 Like a “function”
 Inside, a series of attributes and their values
 Resources types and attributes are predefined by Puppet
 List of available resources
 http://docs.puppetlabs.com/references/stable/type.html
 Skeleton
 Ressource-name { ‘title’ : attribute = value }
Puppet language basics
Resources
 File
 Manage files
 Content
 Permissions
 Ownership
 Source attribute
 Copy a file from the Puppetmaster to the node
 puppet:/// followed by the relative source of the file
 placed in /etc/puppet/modules/module-name/files/
Puppet language basics
Resources
 Package
 Manage packages
 Wide provider support
 APT
 Aptitude
 YUM
 And more..
 Install, upgrade, uninstall packages
 The last or defined package version
Puppet language basics
Resources
 Service
 Manage services
 Start, stop, restart, start on boot (enable) services
Puppet language advanced
Facter
 The system profiler
 Software used by Puppet
 Installed on nodes
 Collect various data, "facts",on node
 Many facts already defined by Facter
 Possibility to create your own facts
Puppet language advanced
Variables
 Variables into classes
 Begin by $
 Can use facts or you own defined variables
 Often used with conditional statements
 Case statement
 If statement
Puppet language advanced
Conditional statements
 Based on
 the truth value of a variable
 the value of an expression
 The truth of an arithmetic expression
Puppet language advanced
Templates
 Personalized text files
 Permit to have personalized configuration per node
 Use ERB language
 Retrieve and use facts
 Use file resource
 ERB file placed in module template directory
Puppet language advanced
Resources relationship
 Relationship meta-parameters
 Before
 Resource is applied before the target resource
 require
 Resource is applied after the target resource
 notify
 Like before + The target resource will refresh if the notifying resource changes
 subscribe
 Like require + The subscribing resource will refresh if thetarget resource changes.
Puppet language advanced
Resources relationship
 Ordering relationship
 These two examples are mutually-exclusive
Puppet language advanced
Resources relationship
 Notification relationship
 These two examples are mutually-exclusive
Puppet language advanced
Resources relationship
 Chaining and refreshing
 Ordering resources
 The resource on the left is applied before the resource on the right.
 ->
 Refreshing
 Kind of trigger
 Restart a service after a file update
 ~>
Modules
ssh
 class sshd {
package { 'openssh-server':
ensure => latest
}
service { 'ssh':
subscribe => File[sshdconfig],
require => Package['openssh-server'],
}
file { 'sshdconfig':
name => '/etc/ssh/sshd_config',
owner => root,
group => root,
mode => 644,
source => 'puppet:///sshd/sshd_config',
require => Package['openssh-server'],
}
}
Modules
ssh using templates
 class sshd {
port = "22",
keyregenerationinterval = "3600",
syslogfacility = "AUTHPRIV",
loglevel = "info",
package { 'openssh-server':
ensure => latest
}
service { 'ssh':
subscribe => File[sshdconfig],
require => Package['openssh-server'],
}
file { 'sshdconfig':
name => '/etc/ssh/sshd_config',
owner => root,
group => root,
mode => 644,
content => template("sshd/sshd_config.erb"),
require => Package['openssh-server'],
}
}
Modules
template for ssh
 sshd_config.erb
 Port <%= port %>
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
UsePrivilegeSeparation yes
KeyRegenerationInterval <%= keyregenerationinterval %>
ServerKeyBits 768
SyslogFacility <%= syslogfacility %>
LogLevel <%= loglevel %>
………
Module
NTPClass ntp {
$ntp1=“1.2.3.4”
package { "ntp":
ensure => latest,
}
file { '/etc/ntp.conf':
owner => root,
group => root,
mode => 644,
content => template("ntp/ntp.conf.erb"),
require => Package["ntp"],
}
service { "ntpd":
name => $operatingsystem ? {
/OracleLinux|RedHat|OEL|CentOS/ => "ntpd",
"SLES" => "ntp“
},
enable => true,
ensure => $ntpd,
require => Package["ntp"],
subscribe => File["/etc/ntp.conf"],
Modules:
template for NTP
ntp.conf.erb
server <%= ntp1 %>
<% if ntp2 != nil %>
server <%= ntp2 %>
<% end %>

Contenu connexe

Tendances

Puppet modules: A Holistic Approach - Geneva
Puppet modules: A Holistic Approach - GenevaPuppet modules: A Holistic Approach - Geneva
Puppet modules: A Holistic Approach - GenevaAlessandro Franceschi
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operationsgrim_radical
 
Essential applications management with Tiny Puppet
Essential applications management with Tiny PuppetEssential applications management with Tiny Puppet
Essential applications management with Tiny PuppetAlessandro Franceschi
 
Making Your Capistrano Recipe Book
Making Your Capistrano Recipe BookMaking Your Capistrano Recipe Book
Making Your Capistrano Recipe BookTim Riley
 
State of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DCState of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DCPuppet
 
Using Puppet - Real World Configuration Management
Using Puppet - Real World Configuration ManagementUsing Puppet - Real World Configuration Management
Using Puppet - Real World Configuration ManagementJames Turnbull
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopWalter Heck
 
PuppetCamp SEA 1 - Puppet Deployment at OnApp
PuppetCamp SEA 1 - Puppet Deployment  at OnAppPuppetCamp SEA 1 - Puppet Deployment  at OnApp
PuppetCamp SEA 1 - Puppet Deployment at OnAppWalter Heck
 
Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Martin Alfke
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011Carlos Sanchez
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with AnsibleIvan Serdyuk
 
Puppet slides for intelligrape
Puppet slides for intelligrapePuppet slides for intelligrape
Puppet slides for intelligrapeSharad Aggarwal
 
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011Carlos Sanchez
 
Automated Java Deployments With Rpm
Automated Java Deployments With RpmAutomated Java Deployments With Rpm
Automated Java Deployments With RpmMartin Jackson
 

Tendances (20)

Puppet modules: A Holistic Approach - Geneva
Puppet modules: A Holistic Approach - GenevaPuppet modules: A Holistic Approach - Geneva
Puppet modules: A Holistic Approach - Geneva
 
Intro to-puppet
Intro to-puppetIntro to-puppet
Intro to-puppet
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
 
Essential applications management with Tiny Puppet
Essential applications management with Tiny PuppetEssential applications management with Tiny Puppet
Essential applications management with Tiny Puppet
 
Making Your Capistrano Recipe Book
Making Your Capistrano Recipe BookMaking Your Capistrano Recipe Book
Making Your Capistrano Recipe Book
 
Puppi. Puppet strings to the shell
Puppi. Puppet strings to the shellPuppi. Puppet strings to the shell
Puppi. Puppet strings to the shell
 
State of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DCState of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DC
 
Puppet: From 0 to 100 in 30 minutes
Puppet: From 0 to 100 in 30 minutesPuppet: From 0 to 100 in 30 minutes
Puppet: From 0 to 100 in 30 minutes
 
Puppet modules for Fun and Profit
Puppet modules for Fun and ProfitPuppet modules for Fun and Profit
Puppet modules for Fun and Profit
 
Using Puppet - Real World Configuration Management
Using Puppet - Real World Configuration ManagementUsing Puppet - Real World Configuration Management
Using Puppet - Real World Configuration Management
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
 
Puppet fundamentals
Puppet fundamentalsPuppet fundamentals
Puppet fundamentals
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
 
PuppetCamp SEA 1 - Puppet Deployment at OnApp
PuppetCamp SEA 1 - Puppet Deployment  at OnAppPuppetCamp SEA 1 - Puppet Deployment  at OnApp
PuppetCamp SEA 1 - Puppet Deployment at OnApp
 
Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
Puppet slides for intelligrape
Puppet slides for intelligrapePuppet slides for intelligrape
Puppet slides for intelligrape
 
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011
 
Automated Java Deployments With Rpm
Automated Java Deployments With RpmAutomated Java Deployments With Rpm
Automated Java Deployments With Rpm
 

En vedette

Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetMichael Lessard
 
Getting Started with Puppet - PuppetConf 2013
Getting Started with Puppet - PuppetConf 2013Getting Started with Puppet - PuppetConf 2013
Getting Started with Puppet - PuppetConf 2013Puppet
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet SystemPuppet
 
Scalable systems management with puppet
Scalable systems management with puppetScalable systems management with puppet
Scalable systems management with puppetPuppet
 
Puppet Module Reusability - What I Learned from Shipping to the Forge
Puppet Module Reusability - What I Learned from Shipping to the ForgePuppet Module Reusability - What I Learned from Shipping to the Forge
Puppet Module Reusability - What I Learned from Shipping to the ForgePuppet
 
Mercurial DVCS presentation to DevJam 11/4/2009
Mercurial DVCS presentation to DevJam 11/4/2009Mercurial DVCS presentation to DevJam 11/4/2009
Mercurial DVCS presentation to DevJam 11/4/2009Ted Naleid
 
Mercurial training
 Mercurial training Mercurial training
Mercurial trainingTrung Huynh
 
Svn vs mercurial vs github
Svn  vs  mercurial vs  githubSvn  vs  mercurial vs  github
Svn vs mercurial vs githubVinoth Kannan
 
PuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppet
 
Getting started with Puppet
Getting started with PuppetGetting started with Puppet
Getting started with Puppetjeyg
 
Puppet overview
Puppet overviewPuppet overview
Puppet overviewjoshbeard
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Serverprogrammings guru
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query OptimizationBrian Gallagher
 

En vedette (20)

Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with Puppet
 
Getting Started with Puppet - PuppetConf 2013
Getting Started with Puppet - PuppetConf 2013Getting Started with Puppet - PuppetConf 2013
Getting Started with Puppet - PuppetConf 2013
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet System
 
Scalable systems management with puppet
Scalable systems management with puppetScalable systems management with puppet
Scalable systems management with puppet
 
Puppet Module Reusability - What I Learned from Shipping to the Forge
Puppet Module Reusability - What I Learned from Shipping to the ForgePuppet Module Reusability - What I Learned from Shipping to the Forge
Puppet Module Reusability - What I Learned from Shipping to the Forge
 
Mercurial
MercurialMercurial
Mercurial
 
Virt monitoring
Virt monitoringVirt monitoring
Virt monitoring
 
Mercurial DVCS presentation to DevJam 11/4/2009
Mercurial DVCS presentation to DevJam 11/4/2009Mercurial DVCS presentation to DevJam 11/4/2009
Mercurial DVCS presentation to DevJam 11/4/2009
 
Mercurial training
 Mercurial training Mercurial training
Mercurial training
 
Mercurial 簡介
Mercurial 簡介Mercurial 簡介
Mercurial 簡介
 
Svn vs mercurial vs github
Svn  vs  mercurial vs  githubSvn  vs  mercurial vs  github
Svn vs mercurial vs github
 
PuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbquery
 
Introduction to Puppetry
Introduction to PuppetryIntroduction to Puppetry
Introduction to Puppetry
 
Getting started with Puppet
Getting started with PuppetGetting started with Puppet
Getting started with Puppet
 
Sql joins
Sql joinsSql joins
Sql joins
 
Puppets ppt
Puppets pptPuppets ppt
Puppets ppt
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
 
SQL Joins
SQL JoinsSQL Joins
SQL Joins
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
 

Similaire à Puppet_training

Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and AgentRanjit Avasarala
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with PuppetAlessandro Franceschi
 
Puppet for Developers
Puppet for DevelopersPuppet for Developers
Puppet for Developerssagarhere4u
 
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...Simplilearn
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceohadlevy
 
Puppet Camp Boston 2014: Keynote
Puppet Camp Boston 2014: Keynote Puppet Camp Boston 2014: Keynote
Puppet Camp Boston 2014: Keynote Puppet
 
Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet
 
A DevOps guide to Kubernetes
A DevOps guide to KubernetesA DevOps guide to Kubernetes
A DevOps guide to KubernetesPaul Czarkowski
 
Understanding lwrp development
Understanding lwrp developmentUnderstanding lwrp development
Understanding lwrp developmentjtimberman
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
Puppet Keynote by Ralph Luchs
Puppet Keynote by Ralph LuchsPuppet Keynote by Ralph Luchs
Puppet Keynote by Ralph LuchsNETWAYS
 
Puppet Dashboard at HEP, Cambridge
Puppet Dashboard at HEP, CambridgePuppet Dashboard at HEP, Cambridge
Puppet Dashboard at HEP, CambridgeSantanu Das
 
Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesPuppet
 
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin PiebiakWorkflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin PiebiakNETWAYS
 

Similaire à Puppet_training (20)

Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and Agent
 
Puppet demo
Puppet demoPuppet demo
Puppet demo
 
Puppet
PuppetPuppet
Puppet
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
Puppet quick start guide
Puppet quick start guidePuppet quick start guide
Puppet quick start guide
 
Puppet for Developers
Puppet for DevelopersPuppet for Developers
Puppet for Developers
 
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
 
Puppet - an introduction
Puppet - an introductionPuppet - an introduction
Puppet - an introduction
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conference
 
Puppet
PuppetPuppet
Puppet
 
Puppet Camp Boston 2014: Keynote
Puppet Camp Boston 2014: Keynote Puppet Camp Boston 2014: Keynote
Puppet Camp Boston 2014: Keynote
 
Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013
 
Puppet meetup testing
Puppet meetup testingPuppet meetup testing
Puppet meetup testing
 
A DevOps guide to Kubernetes
A DevOps guide to KubernetesA DevOps guide to Kubernetes
A DevOps guide to Kubernetes
 
Understanding lwrp development
Understanding lwrp developmentUnderstanding lwrp development
Understanding lwrp development
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Puppet Keynote by Ralph Luchs
Puppet Keynote by Ralph LuchsPuppet Keynote by Ralph Luchs
Puppet Keynote by Ralph Luchs
 
Puppet Dashboard at HEP, Cambridge
Puppet Dashboard at HEP, CambridgePuppet Dashboard at HEP, Cambridge
Puppet Dashboard at HEP, Cambridge
 
Workflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large EnterprisesWorkflow story: Theory versus practice in Large Enterprises
Workflow story: Theory versus practice in Large Enterprises
 
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin PiebiakWorkflow story: Theory versus Practice in large enterprises by Marcin Piebiak
Workflow story: Theory versus Practice in large enterprises by Marcin Piebiak
 

Puppet_training

  • 2. Agenda 1. Puppet Overview  What is Puppet  How puppet works?  Puppet Architecture 2. Installation and Configuration  Installing Puppet  Configuring Puppet Master and Agent 3. Puppet Master  Puppet configuration tree  Puppet configuration files 4.Puppet Language Basics  The declarative language  Resources
  • 3. Agenda (Cont..) 5. Puppet Language Advanced  Facter  Variables  Conditional statement  Templates  Resource relationship
  • 4. Agenda (Cont..) 3. Provisioning Hosts with Puppet  Configuring Nodes  Versioning Modules  Creating Modules for NTP  Puppet Forge  Extending puppet with custom facts, types and providers  Mcollective  Troubleshooting and Best Practices.
  • 5. Puppet Overview What is Puppet ?  Puppet is a configuration management system that allows you to define the state of your IT infrastructure, then automatically enforces the correct state.  Puppet automates tasks that system admins often do manually, freeing up time and mental space so system admins can work on the projects that deliver greater business value.  Puppet automates every step of the software delivery process: from provisioning of physical and virtual machines to orchestration and reporting.  Puppet ensures consistency, reliability and stability. It also facilitates closer collaboration between system admins and developers, enabling more efficient delivery of cleaner, better-designed code.
  • 6. Puppet Overview How puppet works?  Once you install Puppet, every node (physical server, device or virtual machine) in your infrastructure has a Puppet agent installed on it. You'll also have a server designated as the Puppet master.  Enforcement takes place during regular Puppet runs, which follow these steps:  Fact collection. The Puppet agent on each node sends facts about the node's configuration — detailing the hardware, operating system, package versions and other information — to the Puppet master.  Catalog compilation. The Puppet master uses facts provided by the agents to compile detailed data about how each node should be configured — called the catalog — and sends it back to the Puppet agent.  Enforcement. The agent makes any needed changes to enforce the node's desired state.  Report. Each Puppet agent sends a report back to the Puppet master, indicating any changes that have been made to its node's configuration.  Report sharing. Puppet's open API can send data to third-party tools, so you can share infrastructure information with other teams.
  • 8. Puppet Overview Puppet Architecture  Configuration Language:  “Puppet’s configuration language has always been focused on the best combination of simplicity and power, and my goal was always to have it be more like a configuration file than a programming language,” wrote Luke Kanies, founder and CEO of Puppet Lab.  It supports DSL (domain specific language).  Transaction  Once the catalog is entirely constructed, it is passed on to the Transaction  Transaction runs on the client, which pulls the Catalog down via HTTP  The transaction performs a relatively straightforward task: walk the graph the order specified by the various relationships, and make sure each resource is in sync.  Resource Abstraction Layer  the work is actually done by the Resource Abstraction Layer (RAL),  The RAL was the first component created in Puppet, it most clearly defines what the user can do.  The job of the RAL is to define what it means to be a resource and how resources can get work done on the system
  • 9. Installation and Configuration Installation  Step 1: Enable the Puppet Labs Package Repository  $ sudo rpm -ivh http://yum.puppetlabs.com/el/6.4/products/x86_64/puppetlabs-release-6-7.noarch.rpm  After installing the repos, open your /etc/yum.repos.d/puppetlabs.repo file for editing. Locate the [puppetlabs-devel] stanza, and change the value of the enabled key from 0 to 1:  Step 2: Install Puppet on the Puppet Master Server  On your puppet master node, run sudo yum install puppet-server  $ sudo puppet resource package puppet-server ensure=latest  You’ll need to restart the puppet master web server after upgrading.  Step 3: Install Puppet on Agent Nodes  On your other nodes, run sudo yum install puppet  $ sudo puppet resource package puppet ensure=latest  You’ll need to restart the puppet service after upgrading.
  • 12. Puppetmaster Puppet Configuration tree  Puppet.conf  General puppet master settings  Auth.conf  General ACL which control http access  Filesever.conf  it isn’t necessary- Puppet automatically serves files from the files directory of modules, and most users find this sufficient.  Manifests directory  Site.pp: global default conf  Nodes.pp: manage nodes  Modules: contains all modules
  • 14. Puppet language basics The declarative language  About the language:  With Puppet, we declare how the node must be.  Everything you want to manage have to be explicitly declared.  A Puppet program is called a manifest  Central manifest : site.pp  Puppet load modules manifests  into manifests, we define classes.  We write resources inside these classes
  • 15. Puppet language basics The declarative language  The declarative language  The fundamental unit of modeling  Like a “function”  Inside, a series of attributes and their values  Resources types and attributes are predefined by Puppet  List of available resources  http://docs.puppetlabs.com/references/stable/type.html  Skeleton  Ressource-name { ‘title’ : attribute = value }
  • 16. Puppet language basics Resources  File  Manage files  Content  Permissions  Ownership  Source attribute  Copy a file from the Puppetmaster to the node  puppet:/// followed by the relative source of the file  placed in /etc/puppet/modules/module-name/files/
  • 17. Puppet language basics Resources  Package  Manage packages  Wide provider support  APT  Aptitude  YUM  And more..  Install, upgrade, uninstall packages  The last or defined package version
  • 18. Puppet language basics Resources  Service  Manage services  Start, stop, restart, start on boot (enable) services
  • 19. Puppet language advanced Facter  The system profiler  Software used by Puppet  Installed on nodes  Collect various data, "facts",on node  Many facts already defined by Facter  Possibility to create your own facts
  • 20. Puppet language advanced Variables  Variables into classes  Begin by $  Can use facts or you own defined variables  Often used with conditional statements  Case statement  If statement
  • 21. Puppet language advanced Conditional statements  Based on  the truth value of a variable  the value of an expression  The truth of an arithmetic expression
  • 22. Puppet language advanced Templates  Personalized text files  Permit to have personalized configuration per node  Use ERB language  Retrieve and use facts  Use file resource  ERB file placed in module template directory
  • 23. Puppet language advanced Resources relationship  Relationship meta-parameters  Before  Resource is applied before the target resource  require  Resource is applied after the target resource  notify  Like before + The target resource will refresh if the notifying resource changes  subscribe  Like require + The subscribing resource will refresh if thetarget resource changes.
  • 24. Puppet language advanced Resources relationship  Ordering relationship  These two examples are mutually-exclusive
  • 25. Puppet language advanced Resources relationship  Notification relationship  These two examples are mutually-exclusive
  • 26. Puppet language advanced Resources relationship  Chaining and refreshing  Ordering resources  The resource on the left is applied before the resource on the right.  ->  Refreshing  Kind of trigger  Restart a service after a file update  ~>
  • 27. Modules ssh  class sshd { package { 'openssh-server': ensure => latest } service { 'ssh': subscribe => File[sshdconfig], require => Package['openssh-server'], } file { 'sshdconfig': name => '/etc/ssh/sshd_config', owner => root, group => root, mode => 644, source => 'puppet:///sshd/sshd_config', require => Package['openssh-server'], } }
  • 28. Modules ssh using templates  class sshd { port = "22", keyregenerationinterval = "3600", syslogfacility = "AUTHPRIV", loglevel = "info", package { 'openssh-server': ensure => latest } service { 'ssh': subscribe => File[sshdconfig], require => Package['openssh-server'], } file { 'sshdconfig': name => '/etc/ssh/sshd_config', owner => root, group => root, mode => 644, content => template("sshd/sshd_config.erb"), require => Package['openssh-server'], } }
  • 29. Modules template for ssh  sshd_config.erb  Port <%= port %> Protocol 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key UsePrivilegeSeparation yes KeyRegenerationInterval <%= keyregenerationinterval %> ServerKeyBits 768 SyslogFacility <%= syslogfacility %> LogLevel <%= loglevel %> ………
  • 30. Module NTPClass ntp { $ntp1=“1.2.3.4” package { "ntp": ensure => latest, } file { '/etc/ntp.conf': owner => root, group => root, mode => 644, content => template("ntp/ntp.conf.erb"), require => Package["ntp"], } service { "ntpd": name => $operatingsystem ? { /OracleLinux|RedHat|OEL|CentOS/ => "ntpd", "SLES" => "ntp“ }, enable => true, ensure => $ntpd, require => Package["ntp"], subscribe => File["/etc/ntp.conf"],
  • 31. Modules: template for NTP ntp.conf.erb server <%= ntp1 %> <% if ntp2 != nil %> server <%= ntp2 %> <% end %>