SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
Love / Hate Puppet
         Stephen Johnson
     Stephen@puppetlabs.com
Background

• Puppetlabs employ for a a year
• I have been using Puppet since 0.24
• Currently working on the hiera_debug and
  rseencfile projects
What is this

• Its not a puppet bashing
• Interesting Puppet behavior
• What i love about puppet
Interesting Behavior


• Type Casting
• Type Equality
• Inconsistencies
• Scoping
Type Casting (FTW)

• $wibble = “3” (String)
• $wibble2 = “2” (String)
• $wtf = $wibble + wibble2 ?
Int
Type Equality

• $wibble = '3'
• $wibble2 = '2'
• $wibble3 = $wibble + $wibble2
• $wibbletest = 5
• is $wibble3 == $wibbletest
Yes
Type Equality 2

• $wibble = ‘true’
• $wibble2 = true
• is $wibble == $wibble2
No
Type Equality 3

• $wibble = 0
• $wibble2 = -1
• are they equal to true
Yes
Totally Confused Now
Type Equality


• There are many many more
• Be careful with data lookups from hiera
Inconsistencies


• Noop on a class
Noop on class


• class{'testtwo': noop => true ;}
• All the resources are noop surely
The code
The output
Scoping


• Thank good for 3.0
• Removing dynamic scoping
2.7


• Dynamic scoping is very very very
  dangerous
• Always use full scoped values
3.0


• It has been removed
• Full scope variables
Facts
• Top level variables
• Do not trust them as sent from client
• Dont use if $::hostname ==
• Export FACTER_hostname=‘puppetmaster’
• puppet agent -t
• See my blog on thatbytes.co.uk
Is not all bad

• All languages have interesting behavior
• Look at the famous “WAT’ talk from Gary
  Bernhardt
• www.destroyallsoftware.com/talks/wat
What i love

• Exported Resources
• Puppet
• Hiera
Exported Resources

• Nagios is so hard to setup all those config
  files
• Dns is so hard we have to track all those ip
  address
Nagios Automated

  • Nagios
                             node	
  webserver	
  {
	
  	
  	
  	
  @@file	
  {	
  "/etc/nagios/conf.d/$::fqdn.apachecheck.conf":	
  
	
  	
  	
  	
  	
  	
  content	
  =>	
  "nagios	
  check	
  stuff	
  n",	
  
	
  	
  	
  	
  	
  	
  tag	
  =>	
  "nagioscheck",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  }
	
  	
  	
  	
  	
  	
  	
  }
	
  	
  	
  	
  	
  	
  node	
  nagiosmachine	
  {
	
  	
  	
  	
  	
  	
  	
  	
  File	
  <<|	
  tag	
  ==	
  'nagioscheck'	
  |>>
	
  	
  	
  	
  	
  	
  }
Export the resource

  •     @@file	
  {	
  "/etc/nagios/conf.d/$::fqdn.apachecheck.conf":	
  

	
  	
  	
  	
  	
  	
  content	
  =>	
  template(‘apache/nagioscheck.erb’),	
  
	
  	
  	
  	
  	
  	
  tag	
  =>	
  "nagioscheck",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  }


  • Tagged with nagioscheck
  • Have a apache::nagios class ?
Collect the resource

  File	
  <<|	
  tag	
  ==	
  'nagioscheck'	
  |>>


• Using the tag previously
• In your nagios::server class
How does that work

• Puppetdb
• Stores configs
• Scalable
• AWESOMENESS
Puppet

• Automation
• Abstraction
• Repeatable
• Reportable
• AWESOMEABLE
Puppet gets you
        Knowledge
• Version controlled infrastructure
• Convergence
• Reporting
• Query-ability
• Removing the snowflakes
Hiera

• Puppet modules without hard-coded data
  are easily shared and more re-usable
• Infrastructure configuration can be
  managed without needing to edit Puppet
  code
• The data problem
Bad Data
if ( $::environment == ‘dev’ ) {
  $ntpserver = ‘192.168.2.1’
} else {
  if ( $::fqdn == ‘host4.mycorp.com’) {
    $ntpserver = ‘127.0.0.1’
  } else {
    $ntpserver = ‘213.21.6.4’
  }
}
Good Data
$ntpserver = hiera(‘ntpserver’)


 :hierarchy:

   - %{operatingsystem}

   - %{environment}

   - %{fqdn}

   - common
Remove Data from
        Code
• Hiera uses information to determine a
  hierarchy
• Top down hierarchy for overriding
  configuration values based on roles,
  environments, locations.... or anything else
• And do this without any coding!
Puppet 3.0

• Hiera is integrated into the core product
• Introduces data mapping for parameterized classes
• Backwards compatible
Hiera_Debug
Hiera


• What where the variables
• How looked the variables up
Debug File
Learn more


• git://github.com/nfagerlund/evil-made-
  manifest.git

Contenu connexe

Tendances

Automated release management with team city & octopusdeploy - NDC 2013
Automated release management with team city & octopusdeploy - NDC 2013Automated release management with team city & octopusdeploy - NDC 2013
Automated release management with team city & octopusdeploy - NDC 2013
Kristoffer Deinoff
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
Jacob Kaplan-Moss
 
Real-time search in Drupal. Meet Elasticsearch
Real-time search in Drupal. Meet ElasticsearchReal-time search in Drupal. Meet Elasticsearch
Real-time search in Drupal. Meet Elasticsearch
Alexei Gorobets
 

Tendances (20)

Open Source Saturday - How can I contribute to Ruby on Rails?
Open Source Saturday - How can I contribute to Ruby on Rails?Open Source Saturday - How can I contribute to Ruby on Rails?
Open Source Saturday - How can I contribute to Ruby on Rails?
 
(DEV201) AWS SDK For Go: Gophers Get Going with AWS
(DEV201) AWS SDK For Go: Gophers Get Going with AWS(DEV201) AWS SDK For Go: Gophers Get Going with AWS
(DEV201) AWS SDK For Go: Gophers Get Going with AWS
 
Ansible and AWS
Ansible and AWSAnsible and AWS
Ansible and AWS
 
What You Missed in Computer Science
What You Missed in Computer ScienceWhat You Missed in Computer Science
What You Missed in Computer Science
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
 
Automated release management with team city & octopusdeploy - NDC 2013
Automated release management with team city & octopusdeploy - NDC 2013Automated release management with team city & octopusdeploy - NDC 2013
Automated release management with team city & octopusdeploy - NDC 2013
 
Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with Elasticsearch
 
Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium Selenium Sandwich Part 1: Data driven Selenium
Selenium Sandwich Part 1: Data driven Selenium
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 
Selenium sandwich-2
Selenium sandwich-2Selenium sandwich-2
Selenium sandwich-2
 
The effective use of Django ORM
The effective use of Django ORMThe effective use of Django ORM
The effective use of Django ORM
 
Google Hacking Basics
Google Hacking BasicsGoogle Hacking Basics
Google Hacking Basics
 
DSLs Internas e Ruby
DSLs Internas e RubyDSLs Internas e Ruby
DSLs Internas e Ruby
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
 
Real-time search in Drupal. Meet Elasticsearch
Real-time search in Drupal. Meet ElasticsearchReal-time search in Drupal. Meet Elasticsearch
Real-time search in Drupal. Meet Elasticsearch
 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul Jones
 
OpenERP and Perl
OpenERP and PerlOpenERP and Perl
OpenERP and Perl
 
#ajn3.lt.marblejenka
#ajn3.lt.marblejenka#ajn3.lt.marblejenka
#ajn3.lt.marblejenka
 

Similaire à Love / Hate Puppet (Puppet Gotchas)

07-Classification.pptx
07-Classification.pptx07-Classification.pptx
07-Classification.pptx
Shree Shree
 
Ruby v cpp_preso
Ruby v cpp_presoRuby v cpp_preso
Ruby v cpp_preso
jessicard
 

Similaire à Love / Hate Puppet (Puppet Gotchas) (20)

Clean Manifests with Puppet::Tidy
Clean Manifests with Puppet::TidyClean Manifests with Puppet::Tidy
Clean Manifests with Puppet::Tidy
 
Continuous Integration For Rails Project
Continuous Integration For Rails ProjectContinuous Integration For Rails Project
Continuous Integration For Rails Project
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Puppet101
Puppet101Puppet101
Puppet101
 
Fixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data PatternsFixing Growing Pains With Puppet Data Patterns
Fixing Growing Pains With Puppet Data Patterns
 
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
 
07-Classification.pptx
07-Classification.pptx07-Classification.pptx
07-Classification.pptx
 
The basics of hacking and penetration testing 이제 시작이야 해킹과 침투 테스트 kenneth.s.kwon
The basics of hacking and penetration testing 이제 시작이야 해킹과 침투 테스트 kenneth.s.kwonThe basics of hacking and penetration testing 이제 시작이야 해킹과 침투 테스트 kenneth.s.kwon
The basics of hacking and penetration testing 이제 시작이야 해킹과 침투 테스트 kenneth.s.kwon
 
Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
 
Chef at WebMD
Chef at WebMDChef at WebMD
Chef at WebMD
 
Ruby v cpp_preso
Ruby v cpp_presoRuby v cpp_preso
Ruby v cpp_preso
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5
 
Protect Your Payloads: Modern Keying Techniques
Protect Your Payloads: Modern Keying TechniquesProtect Your Payloads: Modern Keying Techniques
Protect Your Payloads: Modern Keying Techniques
 
Puppet at Bazaarvoice
Puppet at BazaarvoicePuppet at Bazaarvoice
Puppet at Bazaarvoice
 
Lecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdfLecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdf
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
 
Strategies for Puppet code upgrade and refactoring
Strategies for Puppet code upgrade and refactoringStrategies for Puppet code upgrade and refactoring
Strategies for Puppet code upgrade and refactoring
 

Plus de Puppet

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepo
Puppet
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
Puppet
 
Enforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationEnforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automation
Puppet
 

Plus de Puppet (20)

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepo
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyaml
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
 
Puppet camp vscode
Puppet camp vscodePuppet camp vscode
Puppet camp vscode
 
Modules of the twenties
Modules of the twentiesModules of the twenties
Modules of the twenties
 
Applying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codeApplying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance code
 
KGI compliance as-code approach
KGI compliance as-code approachKGI compliance as-code approach
KGI compliance as-code approach
 
Enforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationEnforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automation
 
Keynote: Puppet camp compliance
Keynote: Puppet camp complianceKeynote: Puppet camp compliance
Keynote: Puppet camp compliance
 
Automating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNowAutomating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNow
 
Puppet: The best way to harden Windows
Puppet: The best way to harden WindowsPuppet: The best way to harden Windows
Puppet: The best way to harden Windows
 
Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020
 
Accelerating azure adoption with puppet
Accelerating azure adoption with puppetAccelerating azure adoption with puppet
Accelerating azure adoption with puppet
 
Puppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael PinsonPuppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael Pinson
 
ServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin ReeuwijkServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin Reeuwijk
 
Take control of your dev ops dumping ground
Take control of your  dev ops dumping groundTake control of your  dev ops dumping ground
Take control of your dev ops dumping ground
 
100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software
 
Puppet User Group
Puppet User GroupPuppet User Group
Puppet User Group
 
Continuous Compliance and DevSecOps
Continuous Compliance and DevSecOpsContinuous Compliance and DevSecOps
Continuous Compliance and DevSecOps
 
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick MaludyThe Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

Love / Hate Puppet (Puppet Gotchas)

  • 1. Love / Hate Puppet Stephen Johnson Stephen@puppetlabs.com
  • 2. Background • Puppetlabs employ for a a year • I have been using Puppet since 0.24 • Currently working on the hiera_debug and rseencfile projects
  • 3. What is this • Its not a puppet bashing • Interesting Puppet behavior • What i love about puppet
  • 4. Interesting Behavior • Type Casting • Type Equality • Inconsistencies • Scoping
  • 5. Type Casting (FTW) • $wibble = “3” (String) • $wibble2 = “2” (String) • $wtf = $wibble + wibble2 ?
  • 6. Int
  • 7. Type Equality • $wibble = '3' • $wibble2 = '2' • $wibble3 = $wibble + $wibble2 • $wibbletest = 5 • is $wibble3 == $wibbletest
  • 8. Yes
  • 9. Type Equality 2 • $wibble = ‘true’ • $wibble2 = true • is $wibble == $wibble2
  • 10. No
  • 11. Type Equality 3 • $wibble = 0 • $wibble2 = -1 • are they equal to true
  • 12. Yes
  • 14.
  • 15. Type Equality • There are many many more • Be careful with data lookups from hiera
  • 17. Noop on class • class{'testtwo': noop => true ;} • All the resources are noop surely
  • 20.
  • 21. Scoping • Thank good for 3.0 • Removing dynamic scoping
  • 22. 2.7 • Dynamic scoping is very very very dangerous • Always use full scoped values
  • 23. 3.0 • It has been removed • Full scope variables
  • 24. Facts • Top level variables • Do not trust them as sent from client • Dont use if $::hostname == • Export FACTER_hostname=‘puppetmaster’ • puppet agent -t • See my blog on thatbytes.co.uk
  • 25. Is not all bad • All languages have interesting behavior • Look at the famous “WAT’ talk from Gary Bernhardt • www.destroyallsoftware.com/talks/wat
  • 26. What i love • Exported Resources • Puppet • Hiera
  • 27. Exported Resources • Nagios is so hard to setup all those config files • Dns is so hard we have to track all those ip address
  • 28. Nagios Automated • Nagios node  webserver  {        @@file  {  "/etc/nagios/conf.d/$::fqdn.apachecheck.conf":              content  =>  "nagios  check  stuff  n",              tag  =>  "nagioscheck",                    }              }            node  nagiosmachine  {                File  <<|  tag  ==  'nagioscheck'  |>>            }
  • 29. Export the resource • @@file  {  "/etc/nagios/conf.d/$::fqdn.apachecheck.conf":              content  =>  template(‘apache/nagioscheck.erb’),              tag  =>  "nagioscheck",                    } • Tagged with nagioscheck • Have a apache::nagios class ?
  • 30. Collect the resource File  <<|  tag  ==  'nagioscheck'  |>> • Using the tag previously • In your nagios::server class
  • 31. How does that work • Puppetdb • Stores configs • Scalable • AWESOMENESS
  • 32. Puppet • Automation • Abstraction • Repeatable • Reportable • AWESOMEABLE
  • 33. Puppet gets you Knowledge • Version controlled infrastructure • Convergence • Reporting • Query-ability • Removing the snowflakes
  • 34. Hiera • Puppet modules without hard-coded data are easily shared and more re-usable • Infrastructure configuration can be managed without needing to edit Puppet code • The data problem
  • 35. Bad Data if ( $::environment == ‘dev’ ) { $ntpserver = ‘192.168.2.1’ } else { if ( $::fqdn == ‘host4.mycorp.com’) { $ntpserver = ‘127.0.0.1’ } else { $ntpserver = ‘213.21.6.4’ } }
  • 36. Good Data $ntpserver = hiera(‘ntpserver’) :hierarchy: - %{operatingsystem} - %{environment} - %{fqdn} - common
  • 37. Remove Data from Code • Hiera uses information to determine a hierarchy • Top down hierarchy for overriding configuration values based on roles, environments, locations.... or anything else • And do this without any coding!
  • 38. Puppet 3.0 • Hiera is integrated into the core product • Introduces data mapping for parameterized classes • Backwards compatible
  • 40. Hiera • What where the variables • How looked the variables up