Love / Hate Puppet (Puppet Gotchas)

Download Love / Hate Puppet (Puppet Gotchas)

Post on 05-Dec-2014




4 download

Embed Size (px)


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


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