SlideShare a Scribd company logo
Introduction to Puppet
Scripting




Shawn S. Smiley
Lead Architect
Achieve Internet
shawn.smiley@achieveinternet.com
What is puppet?

                  “Puppet is IT automation software
                  that helps system administrators
                  manage infrastructure throughout its
                  lifecycle, from provisioning and
                  configuration to patch management
                  and compliance.”




Source: www.puppetlabs.com/puppet/what-is-puppet
What does that mean?

                                       • You can setup a new server in
                                         minutes vs. hours!
                                       • You can be sure your server
                                         configurations are consistent.
                                       • You can easily deploy
                                         configuration changes to
                                         multiple servers.




Image Source: http://www.forbes.com/sites/kenkrogue/2012/09/07/the-most-important-interview-question-never-asked/
Quick Demo




Image source: http://gyaniji.blogspot.com/2011/12/demo-of-ad-posting-job.html
What happened?

• Puppet analyzed the scripts to build a picture of what the
  server should look like.
• Puppet then compared that to what the server actually
  looks like.
• It then generates and executes scripts to make the server
  configuration match that in the puppet scripts.
How vs. What

• Why is it better to describe what a system looks like
  rather than how to configure a system?
• When you describe what a system looks like, you can
  repeatedly rerun the process without fear of breaking the
  system.
• Can build platform independent scripts.
What are the pieces?

•   Puppet Software
•   Module Library
•   Node configuration file
•   [optional] Puppet Master
Modules

What are they?
• Self-contained packages that describe an aspect of a
  system (e.g. “Apache” or “MySQL”)

Are there existing packages I can leverage?
• http://forge.puppetlabs.com
• http://github.com

Where do I put them?
• /usr/share/puppet/modules
• /etc/puppet/modules
File Organization

• manifests
      • site.pp
      • nodes.pp
• modules
      • module1
       • manifests
             init.pp
       • files
       • templates
      • module2
Demo: Folder Structure




Image source: http://gyaniji.blogspot.com/2011/12/demo-of-ad-posting-job.html
Basic Syntax

• Follows basic Ruby language syntax.
• Does not fully implement the Ruby language though, only
  a subset is allowed in your puppet files.
To define an item:                To execute an item:
type title($arg1) {               include “title”
  description of resource state
}                                 type {“title”: }

                                  type {“title”:
                                    arg1 => ‘hello’
                                   }
Demo: Simple script




Image source: http://gyaniji.blogspot.com/2011/12/demo-of-ad-posting-job.html
Resource Types

• Are puppet libraries that are used to interact with the
  system.
• Puppet comes with a wide range of resource types:
       •   exec
       •   package
       •   file
       •   service
       •   notify
Full list:
http://docs.puppetlabs.com/references/latest/type.html
Facter

What are facts?
• Global variables with information about the system that
  the script is running on.

How do I see the available variables?
• facter -p

How do I use them?
• $::variable_name
Templates

• Templates are files that use a simple markup language to
  insert dynamic values.
• Templates have an .erb extension
• Typically used with the File resource. e.g.:

   file {'ntp.conf':
     path => '/etc/ntp.conf',
     ensure => file,
     content => template('ntp/ntp.conf.erb'),
     owner => root,
     mode => 0644,
   }
Relationships

• Package[“ntp”] -> File[„ntp.conf‟] ~> Service[„ntpd‟]
• “before”, “require”
• “subscribe”, “notify”



http://docs.puppetlabs.com/puppet/2.7/reference/lang_relati
onships.html#relationship-metaparameters

http://docs.puppetlabs.com/puppet/2.7/reference/lang_relati
onships.html#chaining-arrows
User-Defined Types

• Similar to functions in most languages.
• Only way to do iterations currently.
         • Call the Type with an array.


 define apache::vhost() {
   $docroot = “/var/www/${name}”
 }

 $sites = [‘site1’, ‘site2’]
 apache::vhost {$sites: }
References

Books
• Managing Infrastructure with Puppet
  (ISBN: 978-1-4493-0763-9)
• Pro Puppet (ISBN: 978-1-4302-3057-1)

Websites
• http://www.puppetlabs.com
• http://docs.puppetlabs.com/
• http://forge.puppetlabs.com/
Q&A

More Related Content

PPTX
Puppet - an introduction
PPTX
Puppet_training
PDF
Introduction to puppet
PDF
Puppet for SysAdmins
PDF
Puppet - Configuration Management Made Eas(ier)
PDF
Pro Puppet
KEY
Puppet for dummies - ZendCon 2011 Edition
PPTX
Go Faster with Ansible (PHP meetup)
Puppet - an introduction
Puppet_training
Introduction to puppet
Puppet for SysAdmins
Puppet - Configuration Management Made Eas(ier)
Pro Puppet
Puppet for dummies - ZendCon 2011 Edition
Go Faster with Ansible (PHP meetup)

What's hot (20)

PPTX
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
PPTX
Learn you some Ansible for great good!
PPTX
DevOps, A brief introduction to Vagrant & Ansible
PPT
Python Deployment with Fabric
PDF
Using Puppet - Real World Configuration Management
PDF
Learn Puppet : Quest Guide for the Learning VM
PDF
Using Puppet in Small Infrastructures
PDF
Ansible Case Studies
PDF
Getting started with Ansible
PPTX
Go Faster with Ansible (AWS meetup)
PDF
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
PDF
Ansible
PPTX
Network automation (NetDevOps) with Ansible
PDF
De-centralise and Conquer: Masterless Puppet in a Dynamic Environment
PDF
Puppet Development Workflow
PDF
Superb Supervision of Short-lived Servers with Sensu
PPTX
Automated Deployments with Ansible
PPTX
Infrastructure Automation with Chef & Ansible
PPTX
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Learn you some Ansible for great good!
DevOps, A brief introduction to Vagrant & Ansible
Python Deployment with Fabric
Using Puppet - Real World Configuration Management
Learn Puppet : Quest Guide for the Learning VM
Using Puppet in Small Infrastructures
Ansible Case Studies
Getting started with Ansible
Go Faster with Ansible (AWS meetup)
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Ansible
Network automation (NetDevOps) with Ansible
De-centralise and Conquer: Masterless Puppet in a Dynamic Environment
Puppet Development Workflow
Superb Supervision of Short-lived Servers with Sensu
Automated Deployments with Ansible
Infrastructure Automation with Chef & Ansible
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Ad

Viewers also liked (8)

DOCX
The importance of puppets
PDF
Improving Operations Efficiency with Puppet
PDF
Red Hat Satellite 6 - Automation with Puppet
PPTX
Introduction to Puppetry
PPTX
Demystifying TLS
PPTX
Puppets ppt
PPTX
Introduction to Puppet Enterprise
DOCX
College fest anchoring script
The importance of puppets
Improving Operations Efficiency with Puppet
Red Hat Satellite 6 - Automation with Puppet
Introduction to Puppetry
Demystifying TLS
Puppets ppt
Introduction to Puppet Enterprise
College fest anchoring script
Ad

Similar to Introduction to Puppet Scripting (20)

KEY
Puppet for dummies - PHPBenelux UG edition
PPTX
Automation using Puppet 3
PDF
Puppet - The IT automation software
PPTX
PPS
A Presentation about Puppet that I've made at the OSSPAC conference
KEY
Portable infrastructure with puppet
PDF
Developing IT infrastructures with Puppet
ODP
Puppet slides for intelligrape
PDF
Puppet fundamentals
PPT
Puppet
PDF
Creating a mature puppet system
PDF
Creating a Mature Puppet System
PDF
Lessons I Learned While Scaling to 5000 Puppet Agents
PPTX
Puppet for Developers
PPT
Scalable systems management with puppet
PPT
Scalable Systems Management with Puppet
PDF
Unix Automation using centralized configuration management tool
PDF
Unix Automation using centralized configuration management tool
PPTX
Puppetizing Your Organization
PPTX
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...
Puppet for dummies - PHPBenelux UG edition
Automation using Puppet 3
Puppet - The IT automation software
A Presentation about Puppet that I've made at the OSSPAC conference
Portable infrastructure with puppet
Developing IT infrastructures with Puppet
Puppet slides for intelligrape
Puppet fundamentals
Puppet
Creating a mature puppet system
Creating a Mature Puppet System
Lessons I Learned While Scaling to 5000 Puppet Agents
Puppet for Developers
Scalable systems management with puppet
Scalable Systems Management with Puppet
Unix Automation using centralized configuration management tool
Unix Automation using centralized configuration management tool
Puppetizing Your Organization
What is Puppet? | How Puppet Works? | Puppet Tutorial For Beginners | DevOps ...

More from Achieve Internet (11)

PDF
Planning & Executing Custom Drupal Integration Projects
PDF
Communicating Drupal: Documentation and Discovery
PDF
Advancing Healthcare Technology with Open Source Software
PPTX
Showcasing Human Capital: How to Effectively Market a Professional Services Firm
PPTX
Harmonious Development: Via Vagrant and Puppet
PPTX
Improving Website Performance with Memecached Webinar | Achieve Internet
PPTX
Improving Website Performance with Memecached Webinar | Achieve Internet
PDF
Drupal secure code checklist
PPTX
Helping the LatinGRAMMYs Reach a Global Audience
PPTX
Drupal and the Future of Healthcare
PPTX
Responsive Web Design_2013
Planning & Executing Custom Drupal Integration Projects
Communicating Drupal: Documentation and Discovery
Advancing Healthcare Technology with Open Source Software
Showcasing Human Capital: How to Effectively Market a Professional Services Firm
Harmonious Development: Via Vagrant and Puppet
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
Drupal secure code checklist
Helping the LatinGRAMMYs Reach a Global Audience
Drupal and the Future of Healthcare
Responsive Web Design_2013

Recently uploaded (20)

PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
KodekX | Application Modernization Development
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PPT
Teaching material agriculture food technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Cloud computing and distributed systems.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Electronic commerce courselecture one. Pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Understanding_Digital_Forensics_Presentation.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
Big Data Technologies - Introduction.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KodekX | Application Modernization Development
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Monthly Chronicles - July 2025
Teaching material agriculture food technology
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
Dropbox Q2 2025 Financial Results & Investor Presentation
Cloud computing and distributed systems.
“AI and Expert System Decision Support & Business Intelligence Systems”
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Empathic Computing: Creating Shared Understanding
Electronic commerce courselecture one. Pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Understanding_Digital_Forensics_Presentation.pptx

Introduction to Puppet Scripting

  • 1. Introduction to Puppet Scripting Shawn S. Smiley Lead Architect Achieve Internet shawn.smiley@achieveinternet.com
  • 2. What is puppet? “Puppet is IT automation software that helps system administrators manage infrastructure throughout its lifecycle, from provisioning and configuration to patch management and compliance.” Source: www.puppetlabs.com/puppet/what-is-puppet
  • 3. What does that mean? • You can setup a new server in minutes vs. hours! • You can be sure your server configurations are consistent. • You can easily deploy configuration changes to multiple servers. Image Source: http://www.forbes.com/sites/kenkrogue/2012/09/07/the-most-important-interview-question-never-asked/
  • 4. Quick Demo Image source: http://gyaniji.blogspot.com/2011/12/demo-of-ad-posting-job.html
  • 5. What happened? • Puppet analyzed the scripts to build a picture of what the server should look like. • Puppet then compared that to what the server actually looks like. • It then generates and executes scripts to make the server configuration match that in the puppet scripts.
  • 6. How vs. What • Why is it better to describe what a system looks like rather than how to configure a system? • When you describe what a system looks like, you can repeatedly rerun the process without fear of breaking the system. • Can build platform independent scripts.
  • 7. What are the pieces? • Puppet Software • Module Library • Node configuration file • [optional] Puppet Master
  • 8. Modules What are they? • Self-contained packages that describe an aspect of a system (e.g. “Apache” or “MySQL”) Are there existing packages I can leverage? • http://forge.puppetlabs.com • http://github.com Where do I put them? • /usr/share/puppet/modules • /etc/puppet/modules
  • 9. File Organization • manifests • site.pp • nodes.pp • modules • module1 • manifests  init.pp • files • templates • module2
  • 10. Demo: Folder Structure Image source: http://gyaniji.blogspot.com/2011/12/demo-of-ad-posting-job.html
  • 11. Basic Syntax • Follows basic Ruby language syntax. • Does not fully implement the Ruby language though, only a subset is allowed in your puppet files. To define an item: To execute an item: type title($arg1) { include “title” description of resource state } type {“title”: } type {“title”: arg1 => ‘hello’ }
  • 12. Demo: Simple script Image source: http://gyaniji.blogspot.com/2011/12/demo-of-ad-posting-job.html
  • 13. Resource Types • Are puppet libraries that are used to interact with the system. • Puppet comes with a wide range of resource types: • exec • package • file • service • notify Full list: http://docs.puppetlabs.com/references/latest/type.html
  • 14. Facter What are facts? • Global variables with information about the system that the script is running on. How do I see the available variables? • facter -p How do I use them? • $::variable_name
  • 15. Templates • Templates are files that use a simple markup language to insert dynamic values. • Templates have an .erb extension • Typically used with the File resource. e.g.: file {'ntp.conf': path => '/etc/ntp.conf', ensure => file, content => template('ntp/ntp.conf.erb'), owner => root, mode => 0644, }
  • 16. Relationships • Package[“ntp”] -> File[„ntp.conf‟] ~> Service[„ntpd‟] • “before”, “require” • “subscribe”, “notify” http://docs.puppetlabs.com/puppet/2.7/reference/lang_relati onships.html#relationship-metaparameters http://docs.puppetlabs.com/puppet/2.7/reference/lang_relati onships.html#chaining-arrows
  • 17. User-Defined Types • Similar to functions in most languages. • Only way to do iterations currently. • Call the Type with an array. define apache::vhost() { $docroot = “/var/www/${name}” } $sites = [‘site1’, ‘site2’] apache::vhost {$sites: }
  • 18. References Books • Managing Infrastructure with Puppet (ISBN: 978-1-4493-0763-9) • Pro Puppet (ISBN: 978-1-4302-3057-1) Websites • http://www.puppetlabs.com • http://docs.puppetlabs.com/ • http://forge.puppetlabs.com/
  • 19. Q&A

Editor's Notes

  • #5: Startup an AWS instance and run puppet apply to show what puppet does.
  • #9: Default modulepath: /etc/puppet/modules:/usr/share/puppet/modules
  • #11: Show the File Structure and examples of some modules.
  • #12: Defining an item is called a “Resource Declaration”
  • #13: Demo a simple module: The Lynx module.