SlideShare a Scribd company logo
Greenfield Puppet
David Danzilio
@djdanzilio
$(whoami)
What’s this all about?
A collection of wisdom that I
wish I had available when I
first started using Puppet
This could change in future
releases
Don’t just take my word for it
Greenfield Puppet: Getting it right from the start
– Wikipedia
“a greenfield is a project that lacks any constraints
imposed by prior work”
Greenfield Puppet: Getting it right from the start
A (not so) hypothetical
scenario…
Department of
BasketweavingFUFoo University
class apache {!
package { [‘apache2’, ‘rails’, ‘libapache2-mod-passenger’]:!
ensure => present,!
}!
file { ‘/etc/apache2/sites-enabled/bw-app.conf’:!
ensure => file,!
source => ‘puppet:///apache/bw-app.conf',!
require => Package[‘apache2’],!
}!
file { ‘/var/www/bw-app’:!
ensure => directory,!
owner => www-data,!
group => www-data,!
source => ‘puppet:///apache/bw-app',!
recurse => true,!
require => File[‘/etc/apache2/sites-enabled/bw-app.conf’]!
}!
service { ‘apache2’:!
ensure => running,!
require => [!
File[‘/var/www/bw-app’],!
Package[’rails’, ‘libapache2-mod-passenger’],!
]!
}!
}
I want to use
Graphite
for all my!
basket data
OH NOES!
Greenfield Puppet: Getting it right from the start
–Doug McIlroy
“Write programs that do one thing and do it
well. Write programs to work together.”
Modules
Don’t write modules unless
you absolutely have to!
Greenfield Puppet: Getting it right from the start
Check the Forge first
2,617
Don’t customize Forge
modules!
Use the Roles and Profiles
pattern
Roles and Profiles
Craig Dunn’s blog post:
“Designing Puppet – Roles
and Profiles”
A node includes one role
node db01.example.com {
include role::db::server
}
!
node db02.example.com {
include role::db::server::dev
}
A role includes one or more
profiles
class role::base {
include profile::base
}
!
class role::db::server inherits role::base {
include profile::mysql
include profile::application::database
}
!
class role::db::server::dev inherits role::base {
include profile::mysql
include profile::percona
}
A profile manages modules
class profile::mysql {
!
$mysql_version = hiera(‘mysql_version’)
!
class { ‘mysql::server’:
package_ensure => $mysql_version
}
!
class { ‘mysql::backup’: }
class { ‘nagios::mysql’: }
!
}
Like MVC for Puppet
The Forge
Look for modules with lots of
downloads and recent
updates
Lots of downloads
Recent update
Do some background
research on the author of the
module
Give priority to modules
written by Puppet Labs
Be weary of modules with
strange dependencies
WHY!??!?!
Don’t use a module without
vetting it
Greenfield Puppet: Getting it right from the start
Puppet Deployment
Have a solid deployment
pipeline
Greenfield Puppet: Getting it right from the start
Use librarian-puppet or r10k
to deploy your code to your
Puppet masters
Reliable metadata is key to a
successful Puppet deployment
$ cat /etc/facter/facts.d/metadata.json
{
"datacenter": "Boston",
"rack": "R23",
"role": "webserver",
"cluster": "C89"
}
Use environments to keep
your nodes safe
Understand the lifecycle of a
module
Use Hiera from the start
Don’t get too crazy with your
hierarchy
:hierarchy:
- “%{::app}/%{::environment}/%{::datacenter}/%{::fqdn}”
- “%{::app}/%{::environment}/%{::datacenter}”
- “%{::app}/%{::environment}”
- “%{::app}”
- “%{::cluster}/%{::environment}/%{::datacenter}/%{::fqdn}”
- “%{::cluster}/%{::environment}/%{::datacenter}”
- “%{::cluster}/%{::environment}”
- “%{::cluster}”
- “%{::environment}/%{::datacenter}/%{::fqdn}”
- “%{::environment}/%{::datacenter}”
- “%{::environment}”
- “%{::realm}/%{::region}/%{::datacenter}/%{::fqdn}”
- “%{::realm}/%{::region}/%{::datacenter}”
- “%{::realm}/%{::region}”
- “%{::realm}”
- “%{::region}”
- “%{::datacenter}/%{::rack}/%{::cluster}/%{::fqdn}”
- “%{::datacenter}/%{::rack}/%{::cluster}”
- “%{::datacenter}/%{::rack}”
- “%{::datacenter}”
- “%{::rack}”
- “%{::cluster}”
Puppet Development
Puppet code is real code
Puppet is Ruby
Greenfield Puppet: Getting it right from the start
Puppet modules need a
design specification
rspec-puppet for TDD
Design modules with other
people in mind
Fail fast
fail(“${::osfamily} is not
supported by this module.”)
Public classes should expose
a stable API
Semantic Versioning is your
friend
Major.Minor.Patch
X.0.0
0.X.0
0.0.X
Remember the UNIX
philosophy
Share your custom modules
with the community!
Manage your dependencies
with care
Keep artifacts out of your
Puppet modules
Embedding data makes your
modules less modular
class foo (
$pkg_version = $foo::params::pkg_version,
$pkg_name = $foo::params::pkg_name,
) inherits foo::params {
!
...
!
}
Keep business logic out of
templates
<% if @app == ‘foo’ %>
...
<% else %>
...
<% end %>
$template = ? $app {
‘foo’ => ‘foo.conf.erb’,
default => ‘generic.conf.erb’,
}
!
file { ‘/path/to/app.conf’:
ensure => file,
content => template(“module/${template}”),
}
Standard Library
Use the standard library to
level-up your modules
Avoid duplicate resources with
ensure_packages and
ensure_resource
package { ‘apache2’:
ensure => present,
}
ensure_packages([‘apache2’])
Validate inputs with
validate_array,
validate_bool,
validate_hash,
validate_re, and
validate_string
Protect private classes with
private
Greenfield Puppet: Getting it right from the start
Modules should be easy to
use and hard to abuse
Style
Substance
Style is important
puppet-lint
puppet-syntax
source 'https://rubygems.org'
!
gem 'rake'
gem 'puppet'
gem 'puppet-lint'
gem 'puppet-syntax'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
!
exclude_paths = [
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
]
!
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths
$ bundle install
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Installing rake 10.3.2
Installing CFPropertyList 2.2.8
Installing facter 2.1.0
Installing json_pure 1.8.1
Installing hiera 1.3.4
Installing rgen 0.6.6
Installing puppet 3.6.2
Installing puppet-lint 0.3.2
Installing puppet-syntax 1.3.0
Using bundler 1.6.2
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem
is installed.
$ bundle exec rake -T
rake lint # Run puppet-lint
rake syntax # Syntax check Puppet manifests and
rake syntax:hiera # Syntax check Hiera config files
rake syntax:manifests # Syntax check Puppet manifests
rake syntax:templates # Syntax check Puppet templates
Documentation is important
Greenfield Puppet: Getting it right from the start
Greenfield Puppet: Getting it right from the start
We’re all Keynesians now.
developers
Keeping Up
Puppet is evolving really fast
There is a fantastic
community out there
Pay attention to thought
leaders
Greenfield Puppet: Getting it right from the start
Refactor your code as the
language evolves
Greenfield Puppet: Getting it right from the start
Contribute to modules on the
Forge!
Questions?
Thank you!
Image Credits
• http://officeimg.vo.msecnd.net/en-us/images/MP900430517.jpg
• http://imgur.com/gallery/YNI5wud
• http://www.reddit.com/r/funny/comments/1jgxtq/new_york_and_boston_the_difference/
• http://openclipart.org/detail/195046/ubuntu-geek-by-stephencuyos-195046
• http://design.ubuntu.com/downloads?metadata=element-logo+brand-ubuntu
• http://commons.wikimedia.org/wiki/File:Ruby_on_Rails-logo.png
• https://github.com/phusion/passenger
• http://kaleidos.net/weapons/apache-webserver/
• http://puppetlabs.com/company/news/media-kit
• http://copiousnotes.bloginky.com/2014/06/17/summer-classic-dr-strangelove-2/
• http://imgur.com/iWKad22
• http://cheezburger.com/6230961920
• http://www.craigdunn.org/stuff/puppet_big.png
• http://www.quickmeme.com/meme/362un7
• http://programmerryangosling.tumblr.com/image/22790837971
• http://www.quickmeme.com/meme/3sogf9
• http://wall.alphacoders.com/big.php?i=238266
Further Reading
• http://www.craigdunn.org/2012/05/239/
• https://www.youtube.com/user/PuppetLabsInc/playlists
• https://github.com/puppetlabs/puppetlabs-stdlib
• http://continuousdelivery.com
• http://www.slideshare.net/PuppetLabs/tddforpuppet
• http://www.slideshare.net/PuppetLabs/roles-rofiles
• http://www.slideshare.net/PuppetLabs/steamlining-
puppetdevelopmentpuppetconfny2014
• http://garylarizza.com/blog/2013/12/08/when-to-hiera/
• http://www.devco.net/archives/2013/12/09/the-problem-with-params-pp.php
• http://www.devco.net/archives/2013/12/08/better-puppet-modules-using-hiera-data.php
• http://puppet-lint.com
• https://github.com/gds-operations/puppet-syntax

More Related Content

PDF
Puppet at janrain
KEY
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PDF
Puppet for Sys Admins
PPTX
Webinar - Windows Application Management with Puppet
PPTX
Jmx capture
KEY
PyCon US 2012 - State of WSGI 2
TXT
Alfrescotomcat stderr.2013-03-05
PDF
Puppet: Eclipsecon ALM 2013
Puppet at janrain
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
Puppet for Sys Admins
Webinar - Windows Application Management with Puppet
Jmx capture
PyCon US 2012 - State of WSGI 2
Alfrescotomcat stderr.2013-03-05
Puppet: Eclipsecon ALM 2013

What's hot (20)

PDF
The Best (and Worst) of Django
PDF
Puppet getting started by Dirk Götz
TXT
Catalina.2013 03-05
PPTX
Puppet atbazaarvoice
PDF
Django - 次の一歩 gumiStudy#3
PDF
More tips n tricks
PDF
Puppet Camp Berlin 2014: Manageable puppet infrastructure
PPTX
Puppet camp chicago-automated_testing2
DOC
Apache hadoop 2_installation
PDF
Rugged Driven Development with Gauntlt
KEY
From Dev to DevOps - ApacheCON NA 2011
PDF
Puppet: What _not_ to do
PDF
Automated Java Deployments With Rpm
PDF
Getting Started with Ansible
KEY
Puppet for Java developers - JavaZone NO 2012
PDF
The effective use of Django ORM
KEY
From Dev to DevOps - Apache Barcamp Spain 2011
PPTX
Harmonious Development: Standardizing The Deployment Process via Vagrant and ...
PDF
Build Automation 101
PDF
Fixing Growing Pains With Puppet Data Patterns
The Best (and Worst) of Django
Puppet getting started by Dirk Götz
Catalina.2013 03-05
Puppet atbazaarvoice
Django - 次の一歩 gumiStudy#3
More tips n tricks
Puppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet camp chicago-automated_testing2
Apache hadoop 2_installation
Rugged Driven Development with Gauntlt
From Dev to DevOps - ApacheCON NA 2011
Puppet: What _not_ to do
Automated Java Deployments With Rpm
Getting Started with Ansible
Puppet for Java developers - JavaZone NO 2012
The effective use of Django ORM
From Dev to DevOps - Apache Barcamp Spain 2011
Harmonious Development: Standardizing The Deployment Process via Vagrant and ...
Build Automation 101
Fixing Growing Pains With Puppet Data Patterns
Ad

Viewers also liked (7)

PDF
SOLID design principles in Ruby
KEY
SOLID Ruby, SOLID Rails
PDF
200,000 Lines Later: Our Journey to Manageable Puppet Code
PDF
Seven Habits of Highly Effective Puppet Users
PDF
Puppet Design Patterns
PDF
Puppet Design Patterns - PuppetConf
PDF
Design Patterns Illustrated
SOLID design principles in Ruby
SOLID Ruby, SOLID Rails
200,000 Lines Later: Our Journey to Manageable Puppet Code
Seven Habits of Highly Effective Puppet Users
Puppet Design Patterns
Puppet Design Patterns - PuppetConf
Design Patterns Illustrated
Ad

Similar to Greenfield Puppet: Getting it right from the start (20)

PDF
Improving Operations Efficiency with Puppet
PDF
From SaltStack to Puppet and beyond...
PPTX
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
PDF
Creating a mature puppet system
PDF
Creating a Mature Puppet System
PPTX
Puppetizing Your Organization
PDF
Intro to-puppet
PDF
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
PDF
Puppet Development Workflow
PDF
Modules of the twenties
PPS
A Presentation about Puppet that I've made at the OSSPAC conference
PPTX
PDF
Bootstrapping Puppet and Application Deployment - PuppetConf 2013
PDF
Steamlining your puppet development workflow
PDF
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
PDF
Islands: Puppet at Bulletproof Networks
PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
KEY
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
PDF
Puppet | Custom Modules & Using the Forge
Improving Operations Efficiency with Puppet
From SaltStack to Puppet and beyond...
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
Creating a mature puppet system
Creating a Mature Puppet System
Puppetizing Your Organization
Intro to-puppet
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
Puppet Development Workflow
Modules of the twenties
A Presentation about Puppet that I've made at the OSSPAC conference
Bootstrapping Puppet and Application Deployment - PuppetConf 2013
Steamlining your puppet development workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Islands: Puppet at Bulletproof Networks
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
Puppet | Custom Modules & Using the Forge

Recently uploaded (20)

PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Nekopoi APK 2025 free lastest update
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
AI in Product Development-omnex systems
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
medical staffing services at VALiNTRY
PDF
System and Network Administration Chapter 2
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
top salesforce developer skills in 2025.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Odoo Companies in India – Driving Business Transformation.pdf
PTS Company Brochure 2025 (1).pdf.......
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Reimagine Home Health with the Power of Agentic AI​
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Nekopoi APK 2025 free lastest update
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
AI in Product Development-omnex systems
CHAPTER 2 - PM Management and IT Context
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
medical staffing services at VALiNTRY
System and Network Administration Chapter 2
Navsoft: AI-Powered Business Solutions & Custom Software Development
How to Migrate SBCGlobal Email to Yahoo Easily
Odoo POS Development Services by CandidRoot Solutions
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
top salesforce developer skills in 2025.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...

Greenfield Puppet: Getting it right from the start