Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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 ...
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=‘pup...
Is not all bad• All languages have interesting behavior• Look at the famous “WAT’ talk from Gary  Bernhardt• www.destroyal...
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/$:...
Export the resource  •     @@file	  {	  "/etc/nagios/conf.d/$::fqdn.apachecheck.conf":	  	  	  	  	  	  	  content	  =>	  ...
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 s...
Hiera• Puppet modules without hard-coded data  are easily shared and more re-usable• Infrastructure configuration can be  m...
Bad Dataif ( $::environment == ‘dev’ ) {  $ntpserver = ‘192.168.2.1’} else {  if ( $::fqdn == ‘host4.mycorp.com’) {    $nt...
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  configur...
Puppet 3.0• Hiera is integrated into the core product• Introduces data mapping for parameterized classes• Backwards compat...
Hiera_Debug
Hiera• What where the variables• How looked the variables up
Debug File
Learn more• git://github.com/nfagerlund/evil-made-  manifest.git
Love / Hate Puppet (Puppet Gotchas)
Love / Hate Puppet (Puppet Gotchas)
Upcoming SlideShare
Loading in …5
×

Love / Hate Puppet (Puppet Gotchas)

3,187 views

Published on

Stephen Johnson's talk on "Love / Hate Puppet (Puppet Gotchas)" from Puppet Camp Melbourne 2013.

Published in: Technology
  • Be the first to comment

Love / Hate Puppet (Puppet Gotchas)

  1. 1. Love / Hate Puppet Stephen Johnson Stephen@puppetlabs.com
  2. 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. 3. What is this• Its not a puppet bashing• Interesting Puppet behavior• What i love about puppet
  4. 4. Interesting Behavior• Type Casting• Type Equality• Inconsistencies• Scoping
  5. 5. Type Casting (FTW)• $wibble = “3” (String)• $wibble2 = “2” (String)• $wtf = $wibble + wibble2 ?
  6. 6. Int
  7. 7. Type Equality• $wibble = 3• $wibble2 = 2• $wibble3 = $wibble + $wibble2• $wibbletest = 5• is $wibble3 == $wibbletest
  8. 8. Yes
  9. 9. Type Equality 2• $wibble = ‘true’• $wibble2 = true• is $wibble == $wibble2
  10. 10. No
  11. 11. Type Equality 3• $wibble = 0• $wibble2 = -1• are they equal to true
  12. 12. Yes
  13. 13. Totally Confused Now
  14. 14. Type Equality• There are many many more• Be careful with data lookups from hiera
  15. 15. Inconsistencies• Noop on a class
  16. 16. Noop on class• class{testtwo: noop => true ;}• All the resources are noop surely
  17. 17. The code
  18. 18. The output
  19. 19. Scoping• Thank good for 3.0• Removing dynamic scoping
  20. 20. 2.7• Dynamic scoping is very very very dangerous• Always use full scoped values
  21. 21. 3.0• It has been removed• Full scope variables
  22. 22. 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
  23. 23. Is not all bad• All languages have interesting behavior• Look at the famous “WAT’ talk from Gary Bernhardt• www.destroyallsoftware.com/talks/wat
  24. 24. What i love• Exported Resources• Puppet• Hiera
  25. 25. Exported Resources• Nagios is so hard to setup all those config files• Dns is so hard we have to track all those ip address
  26. 26. 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  |>>            }
  27. 27. 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 ?
  28. 28. Collect the resource File  <<|  tag  ==  nagioscheck  |>>• Using the tag previously• In your nagios::server class
  29. 29. How does that work• Puppetdb• Stores configs• Scalable• AWESOMENESS
  30. 30. Puppet• Automation• Abstraction• Repeatable• Reportable• AWESOMEABLE
  31. 31. Puppet gets you Knowledge• Version controlled infrastructure• Convergence• Reporting• Query-ability• Removing the snowflakes
  32. 32. 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
  33. 33. Bad Dataif ( $::environment == ‘dev’ ) { $ntpserver = ‘192.168.2.1’} else { if ( $::fqdn == ‘host4.mycorp.com’) { $ntpserver = ‘127.0.0.1’ } else { $ntpserver = ‘213.21.6.4’ }}
  34. 34. Good Data$ntpserver = hiera(‘ntpserver’) :hierarchy: - %{operatingsystem} - %{environment} - %{fqdn} - common
  35. 35. 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!
  36. 36. Puppet 3.0• Hiera is integrated into the core product• Introduces data mapping for parameterized classes• Backwards compatible
  37. 37. Hiera_Debug
  38. 38. Hiera• What where the variables• How looked the variables up
  39. 39. Debug File
  40. 40. Learn more• git://github.com/nfagerlund/evil-made- manifest.git

×