Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Love/Hate Puppet Melbourne

Love/Hate Puppet Melbourne

This is the talk i gave at PuppetCamp Melbourne on the 08/02/2013

Avatar for Stephen Johnson

Stephen Johnson

February 10, 2013
Tweet

More Decks by Stephen Johnson

Other Decks in Technology

Transcript

  1. Background • Puppetlabs employ for a a year • I

    have been using Puppet since 0.24 • Currently working on the hiera_debug and rseencfile projects Wednesday, 20 March 13
  2. What is this • Its not a puppet bashing •

    Interesting Puppet behavior • What i love about puppet Wednesday, 20 March 13
  3. Type Casting (FTW) • $wibble = “3” (String) • $wibble2

    = “2” (String) • $wtf = $wibble + $wibble2 ? Wednesday, 20 March 13
  4. Type Equality • $wibble = '3' • $wibble2 = '2'

    • $wibble3 = $wibble + $wibble2 • $wibbletest = 5 • is $wibble3 == $wibbletest Wednesday, 20 March 13
  5. Type Equality 2 • $wibble = ‘true’ • $wibble2 =

    true • is $wibble == $wibble2 Wednesday, 20 March 13
  6. Type Equality 3 • $wibble = 0 • $wibble2 =

    -1 • are they equal to true Wednesday, 20 March 13
  7. Type Equality • There are many many more • Be

    careful with data lookups from hiera Wednesday, 20 March 13
  8. Noop on class • class{'testtwo': noop => true ;} •

    All the resources are noop surely Wednesday, 20 March 13
  9. 2.7 • Dynamic scoping is very very very dangerous •

    Always use full scoped values Wednesday, 20 March 13
  10. 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 Wednesday, 20 March 13
  11. Is not all bad • All languages have interesting behavior

    • Look at the famous “WAT’ talk from Gary Bernhardt • www.destroyallsoftware.com/talks/wat Wednesday, 20 March 13
  12. Exported Resources • Nagios is so hard to setup all

    those config files • Dns is so hard we have to track all those ip address Wednesday, 20 March 13
  13. 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'  |>>            } Wednesday, 20 March 13
  14. 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 ? Wednesday, 20 March 13
  15. Collect the resource File  <<|  tag  ==  'nagioscheck'  |>> •

    Using the tag previously • In your nagios::server class Wednesday, 20 March 13
  16. How does that work • Puppetdb • Stores configs •

    Scalable • AWESOMENESS Wednesday, 20 March 13
  17. Puppet gets you Knowledge • Version controlled infrastructure • Convergence

    • Reporting • Query-ability • Removing the snowflakes Wednesday, 20 March 13
  18. 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 Wednesday, 20 March 13
  19. 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’ } } Wednesday, 20 March 13
  20. 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! Wednesday, 20 March 13
  21. Puppet 3.0 • Hiera is integrated into the core product

    • Introduces data mapping for parameterized classes • Backwards compatible Wednesday, 20 March 13
  22. Hiera • What where the variables • How looked the

    variables up Wednesday, 20 March 13