SlideShare una empresa de Scribd logo
1 de 77
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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 infrastructurePuppet
 
Puppet at Bazaarvoice
Puppet at BazaarvoicePuppet at Bazaarvoice
Puppet at BazaarvoicePuppet
 
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 09Elizabeth Smith
 
Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09Elizabeth 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.0Puppet
 
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 puppetScott 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 gtk2Elizabeth Smith
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth 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 AdminsPuppet
 
Getting Hiera and Hiera
Getting Hiera and HieraGetting Hiera and Hiera
Getting Hiera and HieraPuppet
 
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
 

La actualidad más candente (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)
 

Destacado

Getting started with Puppet
Getting started with PuppetGetting started with Puppet
Getting started with Puppetjeyg
 
Puppet overview
Puppet overviewPuppet overview
Puppet overviewjoshbeard
 
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 PatternPuppet
 

Destacado (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 a 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 puppetcamp2011Puppet
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony TechniquesKris Wallsmith
 
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 PracticesAlfresco Software
 
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 talkJeremy 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 middlewareAlona 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 2014John Hann
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren 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
 

Similar a 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
 

Último

JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 

Último (20)

JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 

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