SlideShare a Scribd company logo
2014 
Presented by 
The Refactor Dance 
Gary Larizza 
Professional Services | Puppet Labs 
@glarizza
http://bit.ly/refactordance 
Presented by
Presented by
Worst. Hands-on. Ever 
Presented by
Presented by 
• Abstraction and data separation 
• Data Hierarchy 
• Classification 
• Workflow 
• Sticky points and caveats
Presented by 
Classification 
Implementation Implementation
Presented by 
Role 
Hiera 
Profile Profile 
Component 
Modules
Presented by 
roles::application_server 
Hiera 
profiles::java profiles::tomcat 
Component 
Modules
Component 
Modules 
Presented by
Stop writing custom 
goddamn component 
Presented by 
modules
Presented by 
$httpd_root = "/opt/corp/data/http" 
package 
{ 
‘httpd’: 
ensure => latest, 
} 
file { 
“/opt/corp/data/http/conf.d”: 
owner => "httpd", 
ensure => directory; 
“/opt/corp/data/http/conf.d/corp.conf”: 
owner => "httpd", 
ensure => file; 
}
Stop writing component modules 
Presented by 
• Too many ‘okay’ modules 
• Maintenance & upkeep 
• You are not unique 
• You are entirely too lazy
Parameterize 
your classes 
Presented by
Presented by 
class apache {! 
case $::osfamily {! 
'RedHat': {! 
$confdir = ‘/etc/httpd/conf‘! 
$conffile = “${confdir}/httpd.conf”! 
}! 
'Debian': {! 
$confdir = ‘/etc/apache2/conf‘! 
$conffile = “${confdir}/apache2.conf”! 
}! 
}! 
}
Presented by 
class apache (! 
$confdir = $apache::params::confdir,! 
$conffile = $apache::params::conffile,! 
) inherits apache::params {! 
file { $confdir:! 
ensure => directory,! 
}! 
file { $conffile:! 
ensure => file,! 
content => template(’apache/apache.conf.erb’),! 
}! 
}
Presented by 
Parameterize classes 
• Parameters = API 
• Single-entry classes 
• The ‘Forge test’
Presented by 
Params & 
shareable data
Presented by 
class apache::params {! 
case $::osfamily {! 
'RedHat': {! 
$confdir = ‘/etc/httpd/conf‘! 
$conffile = “${confdir}/httpd.conf”! 
}! 
'Debian': {! 
$confdir = ‘/etc/apache2/conf‘! 
$conffile = “${confdir}/apache2.conf”! 
}! 
}! 
}
Presented by 
Shareable data 
• OS-specific data != private data 
• Sane defaults 
• Validation…
Presented by 
Validation
Presented by 
class xinetd (! 
$confdir = $apache::params::confdir,! 
$conffile = $apache::params::conffile,! 
) inherits xinetd::params {! 
file { $confdir:! 
ensure => directory,! 
}! 
file { $conffile:! 
ensure => file,! 
content => template(’apache/apache.conf.erb’),! 
}! 
}
Presented by 
class xinetd (! 
$confdir = $apache::params::confdir,! 
$conffile = $apache::params::conffile,! 
) inherits xinetd::params {! 
validate_absolute_path($confdir)! 
validate_absolute_path($conffile)! 
file { $confdir:! 
ensure => directory,! 
}! 
file { $conffile:! 
ensure => file,! 
content => template(’apache/apache.conf.erb’),! 
}! 
}
Presented by 
Validation 
• Functions in puppetlabs-stdlib 
• Never pass unvalidated data to resources
Presented by 
Class 
containment
Presented by 
class mysql::server (! 
## params here! 
) inherits mysql::params {! 
! 
include ::mysql::server::install! 
include ::mysql::server::config! 
include ::mysql::server::service! 
! 
}
Presented by 
class mysql::server (! 
## params here! 
) inherits mysql::params {! 
! 
include ::mysql::server::install! 
include ::mysql::server::config! 
include ::mysql::server::service! 
! 
anchor { ‘mysql:start’: }! 
-> Class[‘mysql::server::install’]! 
-> Class[‘mysql::server::config’]! 
-> Class[‘mysql::server::service’]! 
-> anchor { ‘mysql:end’: }! 
}
Presented by 
class mysql::server (! 
## params here! 
) inherits mysql::params {! 
! 
contain ::mysql::server::install! 
contain ::mysql::server::config! 
contain ::mysql::server::service! 
! 
} 
* Puppet ≥ 3.4.0
Presented by 
Class containment 
• Before Puppet 3.4.0 - use anchors 
• After Puppet 3.4.0 - use contain
Presented by 
Hiera
Presented by 
class data_in_code {! 
case $::application_tier {! 
'dev': {! 
$java_version = '6.0.3'! 
$tomcat_version = '6.0'! 
}! 
! 
'test': {! 
$java_version = '7.0.1'! 
$tomcat_version = '7.0'! 
}! 
}! 
}
class data_in_code {! 
$java_version = hiera(’java_version’)! 
$tomcat_version = hiera(’tomcat_version’)! 
} 
Presented by
Presented by 
hiera.yaml 
--- 
:backends: 
- yaml 
:yaml: 
:datadir: /etc/puppetlabs/puppet/hieradata 
:hierarchy: 
- “nodes/%{::clientcert}” 
- “location/%{::location}" 
- “tier/%{::application_tier}" 
- common
Presented by 
--- 
java_version: 7.0 
tomcat_version: 8.0 
dev.yaml 
--- 
java_version: 6.0 
tomcat_version: 7.0 
prod.yaml
Where’s 
$osfamily?! 
Presented by
What’s an 
Application 
Presented by 
Tier?
‘Application tier’ 
• Long lived 
• Data usually separate 
• ‘The Data’ 
Presented by 
! 
! 
! 
‘Environment’ 
• Short lived 
• Migration path to ‘production’ 
• ‘The Model’ 
! 
! 
!
Presented by 
Hierarchy structure? 
• How/where is data different? 
• Most -> least specific 
• Folders are your friends
Profiles 
Presented by
But first… 
a question: 
Presented by
Presented by 
include apache! 
vs.! 
class { ‘apache’: }!
Presented by 
include apache! 
include apache! 
include apache! 
include apache! 
include apache!
Presented by 
class { ‘apache’: }! 
include apache!
Presented by 
include apache! 
class { ‘apache’: }! 
include apache!
Namespacing 
Presented by
class data_in_code {! 
$java_version = hiera(’java_version’)! 
$tomcat_version = hiera(’tomcat_version’)! 
! 
notify { “Java is: ${java_version}”: }! 
} 
Presented by
Presented by 
class data_in_code {! 
$java_version = hiera(’java_version’)! 
$tomcat_version = hiera(’tomcat_version’)! 
! 
notify { “Java is: ${data_in_code::java_version}”: }! 
}
class profiles::jenkins {! 
include jenkins! 
} 
Presented by
class profiles::jenkins {! 
include ???????! 
} 
Presented by
class profiles::jenkins {! 
include ::jenkins! 
} 
Presented by
Presented by 
Data 
separation
Presented by 
class data_in_code {! 
case $::application_tier {! 
'dev': {! 
$java_version = '6.0.3'! 
$tomcat_version = '6.0'! 
}! 
! 
'test': {! 
$java_version = '7.0.1'! 
$tomcat_version = '7.0'! 
}! 
}! 
}
Presented by 
class profiles::tomcat {! 
$java_version = hiera(’java_version’)! 
$tomcat_version = hiera(’tomcat_version’)! 
! 
class { ’::tomcat’:! 
version => $tomcat_version,! 
}! 
! 
class { ’::java’:! 
version => $java_version,! 
}! 
}
Presented by 
class apache {! 
file { ‘/opt/custom/key.pem’:! 
ensure => file,! 
source => ’puppet:///modules/apache/key.pem'! 
}! 
! 
file { ‘/things/that/dont/belong/in/apache’:! 
ensure => file,! 
source => ’puppet:///modules/apache/blargh'! 
} ! 
}
Presented by 
class profiles::apache {! 
include apache! 
$keypath = hiera(’apache_keypath’)! 
! 
file { “${keypath}/key.pem”:! 
ensure => file,! 
source => ’puppet:///modules/profiles/key.pem'! 
}! 
! 
file { ‘/things/that/dont/belong/in/apache’:! 
ensure => file,! 
source => ’puppet:///modules/profiles/blargh'! 
}! 
}
Dependencies 
Presented by
Presented by 
class tomcat {! 
class { ‘java’:! 
version => ‘6.0’,! 
}! 
! 
Class[‘java’]! 
-> Class[‘tomcat’]! 
}
Presented by 
class profiles::tomcat {! 
$java_version = hiera(’java_version’)! 
$tomcat_version = hiera(’tomcat_version’)! 
! 
class { ‘::java’:! 
version => $java_version,! 
}! 
class { ‘::tomcat’:! 
version => $tomcat_version,! 
}! 
! 
Class[‘::java’]! 
-> Class[‘::tomcat’]! 
}
class profiles::tomcat {! 
include profiles::java! 
$tomcat_version = hiera(’tomcat_version’)! 
! 
class { ‘::tomcat’:! 
Presented by 
version => $tomcat_version,! 
}! 
! 
Class[‘profiles::java’]! 
-> Class[‘::tomcat’]! 
}
Presented by 
Profiles 
• Hiera for business-specific data 
• Proprietary resources 
• Inter-class dependencies and containment 
• Implementation ‘libraries’
Roles 
Presented by
Classification 
Presented by
denuatapp06p 
Presented by 
falcor
roles::app_server::pci 
Presented by 
roles::proxy
class roles {! 
include profiles::security::base! 
include profiles::mycorp::users! 
include profiles::mycorp::os_base! 
} 
Presented by
class roles::app_server inherits roles {! 
include profiles::tomcat! 
include profiles::our_app! 
include profiles::shibboleth! 
Presented by 
! 
Class[‘profiles::tomcat’]! 
-> Class[‘profiles::our_app’]! 
-> Class[‘profiles::shibboleth’]! 
}
class roles::app_server::pci inherits 
roles::app_server {! 
include profiles::pci! 
} 
Presented by
Presented by 
class roles::app_server::pci {! 
include profiles::security::base! 
include profiles::mycorp::users! 
include profiles::mycorp::os_base! 
include profiles::pci! 
include profiles::tomcat! 
include profiles::our_app! 
include profiles::shibboleth! 
include profiles::pci! 
! 
Class[‘profiles::java’]! 
-> Class[‘profiles::our_app’]! 
-> Class[‘profiles::shibboleth’]! 
}
Presented by 
Roles 
• Hostnames minus Hiera 
• Technology-independent 
• Inheritance makes sense (or not)
Workflow 
Presented by
Presented by 
Module 
Pinning
forge "http://forge.puppetlabs.com"! 
! 
# Modules from the Puppet Forge! 
mod "puppetlabs/apache"! 
mod "puppetlabs/ntp"! 
! 
# Modules from Github using various references! 
mod 'notifyme',! 
:git => 'git://github.com/glarizza/puppet-notifyme',! 
:ref => '50c01703b2e3e352520a9a2271ea4947fe17a51f'! 
! 
mod 'profiles',! 
:git => 'git://github.com/glarizza/puppet-profiles',! 
:ref => '3611ae4253ff01762f9bda1d93620edf8f9a3b22' 
Presented by
R10k - Bad name, good robot 
1. Ensuring modules based on a Puppetfile 
2. Dynamically creating Puppet environments 
Presented by
Presented by 
Puppetfile 
Manifest 
Hieradata 
Control Repository
Presented by 
Puppetfile 
Manifest 
Hieradata 
Puppetfile 
Manifest 
Hieradata 
Puppetfile 
Manifest 
Hieradata
Presented by 
Puppetfile 
Manifest 
Hieradata 
Branch Branch 
Puppetfile 
Manifest 
Hieradata 
Puppetfile 
Manifest 
Hieradata 
Puppet Environment Puppet Environment
Presented by 
Demo
Presented by 
Summary 
• Simple, generic component modules 
• Extract company-specific data with Hiera 
• Layer implementation with Profiles 
• Classification with Profiles 
• R10k for module pinning/workflow

More Related Content

What's hot

Puppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet Camp Berlin 2014: Manageable puppet infrastructurePuppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet
 
Puppet at Bazaarvoice
Puppet at BazaarvoicePuppet at Bazaarvoice
Puppet at Bazaarvoice
Puppet
 
Puppet Camp Portland 2015: Introduction to Hiera (Beginner)
Puppet Camp Portland 2015: Introduction to Hiera (Beginner)Puppet Camp Portland 2015: Introduction to Hiera (Beginner)
Puppet Camp Portland 2015: Introduction to Hiera (Beginner)
Puppet
 
SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09
Elizabeth Smith
 
Moose
MooseMoose
Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09
Elizabeth Smith
 
Puppet atbazaarvoice
Puppet atbazaarvoicePuppet atbazaarvoice
Puppet atbazaarvoiceDave Barcelo
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0
Puppet
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Puppet
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet -
Puppet
 
Using hiera with puppet
Using hiera with puppetUsing hiera with puppet
Using hiera with puppet
Scott Lackey
 
Puppet camp chicago-automated_testing2
Puppet camp chicago-automated_testing2Puppet camp chicago-automated_testing2
Puppet camp chicago-automated_testing2nottings
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
Elizabeth Smith
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
Elizabeth Smith
 
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Puppet
 
Puppet for Sys Admins
Puppet for Sys AdminsPuppet for Sys Admins
Puppet for Sys Admins
Puppet
 
Introduction to Perl and BioPerl
Introduction to Perl and BioPerlIntroduction to Perl and BioPerl
Introduction to Perl and BioPerl
Bioinformatics and Computational Biosciences Branch
 
Getting Hiera and Hiera
Getting Hiera and HieraGetting Hiera and Hiera
Getting Hiera and Hiera
Puppet
 
Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)Jacob Kaplan-Moss
 

What's hot (20)

Puppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet Camp Berlin 2014: Manageable puppet infrastructurePuppet Camp Berlin 2014: Manageable puppet infrastructure
Puppet Camp Berlin 2014: Manageable puppet infrastructure
 
Puppet at Bazaarvoice
Puppet at BazaarvoicePuppet at Bazaarvoice
Puppet at Bazaarvoice
 
Puppet Camp Portland 2015: Introduction to Hiera (Beginner)
Puppet Camp Portland 2015: Introduction to Hiera (Beginner)Puppet Camp Portland 2015: Introduction to Hiera (Beginner)
Puppet Camp Portland 2015: Introduction to Hiera (Beginner)
 
SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09SPL to the Rescue - Tek 09
SPL to the Rescue - Tek 09
 
Moose
MooseMoose
Moose
 
Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09
 
Puppet atbazaarvoice
Puppet atbazaarvoicePuppet atbazaarvoice
Puppet atbazaarvoice
 
Migrating to Puppet 4.0
Migrating to Puppet 4.0Migrating to Puppet 4.0
Migrating to Puppet 4.0
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet -
 
Using hiera with puppet
Using hiera with puppetUsing hiera with puppet
Using hiera with puppet
 
Puppet camp chicago-automated_testing2
Puppet camp chicago-automated_testing2Puppet camp chicago-automated_testing2
Puppet camp chicago-automated_testing2
 
Spl in the wild
Spl in the wildSpl in the wild
Spl in the wild
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
 
Puppet for Sys Admins
Puppet for Sys AdminsPuppet for Sys Admins
Puppet for Sys Admins
 
Introduction to Perl and BioPerl
Introduction to Perl and BioPerlIntroduction to Perl and BioPerl
Introduction to Perl and BioPerl
 
Getting Hiera and Hiera
Getting Hiera and HieraGetting Hiera and Hiera
Getting Hiera and Hiera
 
Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)
 

Viewers also liked

Getting started with Puppet
Getting started with PuppetGetting started with Puppet
Getting started with Puppetjeyg
 
Puppets ppt
Puppets pptPuppets ppt
Puppets ppt
pramod kumar
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
joshbeard
 
Introduction to puppet
Introduction to puppetIntroduction to puppet
Introduction to puppetHabeeb Rahman
 
Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles Pattern
Puppet
 
The importance of puppets
The importance of puppetsThe importance of puppets
The importance of puppets
Kokilavaani Narayanan
 

Viewers also liked (6)

Getting started with Puppet
Getting started with PuppetGetting started with Puppet
Getting started with Puppet
 
Puppets ppt
Puppets pptPuppets ppt
Puppets ppt
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
 
Introduction to puppet
Introduction to puppetIntroduction to puppet
Introduction to puppet
 
Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles Pattern
 
The importance of puppets
The importance of puppetsThe importance of puppets
The importance of puppets
 

Similar to Refactor Dance - Puppet Labs 'Best Practices'

Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?
Tushar Sharma
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Intro to Rails
Intro to Rails Intro to Rails
Intro to Rails
epiineg1
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011
Puppet
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
Kris Wallsmith
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
Daniel Cukier
 
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet
 
BP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best Practices
Alfresco Software
 
What's new in Django 1.2?
What's new in Django 1.2?What's new in Django 1.2?
What's new in Django 1.2?
Jacob Kaplan-Moss
 
Puppet Camp LA 2015: Basic Puppet Module Design (Beginner)
Puppet Camp LA  2015: Basic Puppet Module Design (Beginner)Puppet Camp LA  2015: Basic Puppet Module Design (Beginner)
Puppet Camp LA 2015: Basic Puppet Module Design (Beginner)
Puppet
 
Puppetcamp module design talk
Puppetcamp module design talkPuppetcamp module design talk
Puppetcamp module design talk
Jeremy Kitchen
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
Alona Mekhovova
 
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
John Hann
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
Darren Craig
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
 
Sprockets
SprocketsSprockets

Similar to Refactor Dance - Puppet Labs 'Best Practices' (20)

Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Intro to Rails
Intro to Rails Intro to Rails
Intro to Rails
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011Oliver hookins puppetcamp2011
Oliver hookins puppetcamp2011
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
Puppet Camp Chicago 2014: Smoothing Troubles With Custom Types and Providers ...
 
BP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best Practices
 
What's new in Django 1.2?
What's new in Django 1.2?What's new in Django 1.2?
What's new in Django 1.2?
 
Puppet Camp LA 2015: Basic Puppet Module Design (Beginner)
Puppet Camp LA  2015: Basic Puppet Module Design (Beginner)Puppet Camp LA  2015: Basic Puppet Module Design (Beginner)
Puppet Camp LA 2015: Basic Puppet Module Design (Beginner)
 
Puppetcamp module design talk
Puppetcamp module design talkPuppetcamp module design talk
Puppetcamp module design talk
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
 
Sprockets
SprocketsSprockets
Sprockets
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 

Recently uploaded

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 

Recently uploaded (20)

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 

Refactor Dance - Puppet Labs 'Best Practices'

  • 1. 2014 Presented by The Refactor Dance Gary Larizza Professional Services | Puppet Labs @glarizza
  • 4. Worst. Hands-on. Ever Presented by
  • 5. Presented by • Abstraction and data separation • Data Hierarchy • Classification • Workflow • Sticky points and caveats
  • 6. Presented by Classification Implementation Implementation
  • 7. Presented by Role Hiera Profile Profile Component Modules
  • 8. Presented by roles::application_server Hiera profiles::java profiles::tomcat Component Modules
  • 10. Stop writing custom goddamn component Presented by modules
  • 11. Presented by $httpd_root = "/opt/corp/data/http" package { ‘httpd’: ensure => latest, } file { “/opt/corp/data/http/conf.d”: owner => "httpd", ensure => directory; “/opt/corp/data/http/conf.d/corp.conf”: owner => "httpd", ensure => file; }
  • 12. Stop writing component modules Presented by • Too many ‘okay’ modules • Maintenance & upkeep • You are not unique • You are entirely too lazy
  • 14. Presented by class apache {! case $::osfamily {! 'RedHat': {! $confdir = ‘/etc/httpd/conf‘! $conffile = “${confdir}/httpd.conf”! }! 'Debian': {! $confdir = ‘/etc/apache2/conf‘! $conffile = “${confdir}/apache2.conf”! }! }! }
  • 15. Presented by class apache (! $confdir = $apache::params::confdir,! $conffile = $apache::params::conffile,! ) inherits apache::params {! file { $confdir:! ensure => directory,! }! file { $conffile:! ensure => file,! content => template(’apache/apache.conf.erb’),! }! }
  • 16. Presented by Parameterize classes • Parameters = API • Single-entry classes • The ‘Forge test’
  • 17. Presented by Params & shareable data
  • 18. Presented by class apache::params {! case $::osfamily {! 'RedHat': {! $confdir = ‘/etc/httpd/conf‘! $conffile = “${confdir}/httpd.conf”! }! 'Debian': {! $confdir = ‘/etc/apache2/conf‘! $conffile = “${confdir}/apache2.conf”! }! }! }
  • 19. Presented by Shareable data • OS-specific data != private data • Sane defaults • Validation…
  • 21. Presented by class xinetd (! $confdir = $apache::params::confdir,! $conffile = $apache::params::conffile,! ) inherits xinetd::params {! file { $confdir:! ensure => directory,! }! file { $conffile:! ensure => file,! content => template(’apache/apache.conf.erb’),! }! }
  • 22. Presented by class xinetd (! $confdir = $apache::params::confdir,! $conffile = $apache::params::conffile,! ) inherits xinetd::params {! validate_absolute_path($confdir)! validate_absolute_path($conffile)! file { $confdir:! ensure => directory,! }! file { $conffile:! ensure => file,! content => template(’apache/apache.conf.erb’),! }! }
  • 23. Presented by Validation • Functions in puppetlabs-stdlib • Never pass unvalidated data to resources
  • 24. Presented by Class containment
  • 25. Presented by class mysql::server (! ## params here! ) inherits mysql::params {! ! include ::mysql::server::install! include ::mysql::server::config! include ::mysql::server::service! ! }
  • 26. Presented by class mysql::server (! ## params here! ) inherits mysql::params {! ! include ::mysql::server::install! include ::mysql::server::config! include ::mysql::server::service! ! anchor { ‘mysql:start’: }! -> Class[‘mysql::server::install’]! -> Class[‘mysql::server::config’]! -> Class[‘mysql::server::service’]! -> anchor { ‘mysql:end’: }! }
  • 27. Presented by class mysql::server (! ## params here! ) inherits mysql::params {! ! contain ::mysql::server::install! contain ::mysql::server::config! contain ::mysql::server::service! ! } * Puppet ≥ 3.4.0
  • 28. Presented by Class containment • Before Puppet 3.4.0 - use anchors • After Puppet 3.4.0 - use contain
  • 30. Presented by class data_in_code {! case $::application_tier {! 'dev': {! $java_version = '6.0.3'! $tomcat_version = '6.0'! }! ! 'test': {! $java_version = '7.0.1'! $tomcat_version = '7.0'! }! }! }
  • 31. class data_in_code {! $java_version = hiera(’java_version’)! $tomcat_version = hiera(’tomcat_version’)! } Presented by
  • 32. Presented by hiera.yaml --- :backends: - yaml :yaml: :datadir: /etc/puppetlabs/puppet/hieradata :hierarchy: - “nodes/%{::clientcert}” - “location/%{::location}" - “tier/%{::application_tier}" - common
  • 33. Presented by --- java_version: 7.0 tomcat_version: 8.0 dev.yaml --- java_version: 6.0 tomcat_version: 7.0 prod.yaml
  • 35. What’s an Application Presented by Tier?
  • 36. ‘Application tier’ • Long lived • Data usually separate • ‘The Data’ Presented by ! ! ! ‘Environment’ • Short lived • Migration path to ‘production’ • ‘The Model’ ! ! !
  • 37. Presented by Hierarchy structure? • How/where is data different? • Most -> least specific • Folders are your friends
  • 39. But first… a question: Presented by
  • 40. Presented by include apache! vs.! class { ‘apache’: }!
  • 41. Presented by include apache! include apache! include apache! include apache! include apache!
  • 42. Presented by class { ‘apache’: }! include apache!
  • 43. Presented by include apache! class { ‘apache’: }! include apache!
  • 45. class data_in_code {! $java_version = hiera(’java_version’)! $tomcat_version = hiera(’tomcat_version’)! ! notify { “Java is: ${java_version}”: }! } Presented by
  • 46. Presented by class data_in_code {! $java_version = hiera(’java_version’)! $tomcat_version = hiera(’tomcat_version’)! ! notify { “Java is: ${data_in_code::java_version}”: }! }
  • 47. class profiles::jenkins {! include jenkins! } Presented by
  • 48. class profiles::jenkins {! include ???????! } Presented by
  • 49. class profiles::jenkins {! include ::jenkins! } Presented by
  • 50. Presented by Data separation
  • 51. Presented by class data_in_code {! case $::application_tier {! 'dev': {! $java_version = '6.0.3'! $tomcat_version = '6.0'! }! ! 'test': {! $java_version = '7.0.1'! $tomcat_version = '7.0'! }! }! }
  • 52. Presented by class profiles::tomcat {! $java_version = hiera(’java_version’)! $tomcat_version = hiera(’tomcat_version’)! ! class { ’::tomcat’:! version => $tomcat_version,! }! ! class { ’::java’:! version => $java_version,! }! }
  • 53. Presented by class apache {! file { ‘/opt/custom/key.pem’:! ensure => file,! source => ’puppet:///modules/apache/key.pem'! }! ! file { ‘/things/that/dont/belong/in/apache’:! ensure => file,! source => ’puppet:///modules/apache/blargh'! } ! }
  • 54. Presented by class profiles::apache {! include apache! $keypath = hiera(’apache_keypath’)! ! file { “${keypath}/key.pem”:! ensure => file,! source => ’puppet:///modules/profiles/key.pem'! }! ! file { ‘/things/that/dont/belong/in/apache’:! ensure => file,! source => ’puppet:///modules/profiles/blargh'! }! }
  • 56. Presented by class tomcat {! class { ‘java’:! version => ‘6.0’,! }! ! Class[‘java’]! -> Class[‘tomcat’]! }
  • 57. Presented by class profiles::tomcat {! $java_version = hiera(’java_version’)! $tomcat_version = hiera(’tomcat_version’)! ! class { ‘::java’:! version => $java_version,! }! class { ‘::tomcat’:! version => $tomcat_version,! }! ! Class[‘::java’]! -> Class[‘::tomcat’]! }
  • 58. class profiles::tomcat {! include profiles::java! $tomcat_version = hiera(’tomcat_version’)! ! class { ‘::tomcat’:! Presented by version => $tomcat_version,! }! ! Class[‘profiles::java’]! -> Class[‘::tomcat’]! }
  • 59. Presented by Profiles • Hiera for business-specific data • Proprietary resources • Inter-class dependencies and containment • Implementation ‘libraries’
  • 64. class roles {! include profiles::security::base! include profiles::mycorp::users! include profiles::mycorp::os_base! } Presented by
  • 65. class roles::app_server inherits roles {! include profiles::tomcat! include profiles::our_app! include profiles::shibboleth! Presented by ! Class[‘profiles::tomcat’]! -> Class[‘profiles::our_app’]! -> Class[‘profiles::shibboleth’]! }
  • 66. class roles::app_server::pci inherits roles::app_server {! include profiles::pci! } Presented by
  • 67. Presented by class roles::app_server::pci {! include profiles::security::base! include profiles::mycorp::users! include profiles::mycorp::os_base! include profiles::pci! include profiles::tomcat! include profiles::our_app! include profiles::shibboleth! include profiles::pci! ! Class[‘profiles::java’]! -> Class[‘profiles::our_app’]! -> Class[‘profiles::shibboleth’]! }
  • 68. Presented by Roles • Hostnames minus Hiera • Technology-independent • Inheritance makes sense (or not)
  • 71. forge "http://forge.puppetlabs.com"! ! # Modules from the Puppet Forge! mod "puppetlabs/apache"! mod "puppetlabs/ntp"! ! # Modules from Github using various references! mod 'notifyme',! :git => 'git://github.com/glarizza/puppet-notifyme',! :ref => '50c01703b2e3e352520a9a2271ea4947fe17a51f'! ! mod 'profiles',! :git => 'git://github.com/glarizza/puppet-profiles',! :ref => '3611ae4253ff01762f9bda1d93620edf8f9a3b22' Presented by
  • 72. R10k - Bad name, good robot 1. Ensuring modules based on a Puppetfile 2. Dynamically creating Puppet environments Presented by
  • 73. Presented by Puppetfile Manifest Hieradata Control Repository
  • 74. Presented by Puppetfile Manifest Hieradata Puppetfile Manifest Hieradata Puppetfile Manifest Hieradata
  • 75. Presented by Puppetfile Manifest Hieradata Branch Branch Puppetfile Manifest Hieradata Puppetfile Manifest Hieradata Puppet Environment Puppet Environment
  • 77. Presented by Summary • Simple, generic component modules • Extract company-specific data with Hiera • Layer implementation with Profiles • Classification with Profiles • R10k for module pinning/workflow