Puppet Module Best Practices - Puppet Camp Silicon Valley

2,329
-1

Published on

Ryan Coleman presents "Puppet Module Best Practices" at Puppet Camp Silicon Valley 2014

0 Comments
13 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,329
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
80
Comments
0
Likes
13
Embeds 0
No embeds

No notes for slide
  • Ryan was a RedHat sysadmin for Penn State before joining Puppet Labs
    as a professional services engineer. Now is product owner for the Forge.
  • The Puppet Forge is a community driven web service for contributing and finding Puppet modules.
  • The following are examples of what you will find on the Forge.
  • Many Puppet modules offer users way too many interaction points or one massive entry point that is too difficult to comprehend. The end result isn’t user friendly and doesn’t help with maintenance either.
  • The answer, use Hiera!
    Seriously, these docs rock. Read them. http://docs.puppetlabs.com/hiera/1/index.html
  • But really, just get yourself onto Puppet 3 and take advantage of automatic Hiera!
  • This slide could be more visual vs text-based
  • There’s already an alternative out there, for consulting foreman as your data backend
  • Hiera backends are pluggable too. Here are two examples.
  • If you want to add your influence to our products, join the Puppet Labs Test Pilots program!
    https://puppetlabs.com/community/puppet-test-pilots-program/
  • Seriously, join our team. It’ll be awesome.
  • Puppet Module Best Practices - Puppet Camp Silicon Valley

    1. 1. Ryan Coleman Writing Better Modules @ryanycoleman | ryan@puppetlabs.com
    2. 2. Where I Came From • • • Penn Stater Professional Traveler Blacksmith #PuppetCamp
    3. 3. #PuppetCamp
    4. 4. #PuppetCamp
    5. 5. #PuppetCamp
    6. 6. #PuppetCamp
    7. 7. #PuppetCamp
    8. 8. #PuppetCamp
    9. 9. Writing Better Modules #PuppetCamp
    10. 10. Why Share?
    11. 11. Keep it modular
    12. 12. Dependencies can be your friend
    13. 13. PL Style Guide #PuppetCamp
    14. 14. #PuppetCamp
    15. 15. #PuppetCamp
    16. 16. #PuppetCamp
    17. 17. #PuppetCamp
    18. 18. Development Tools
    19. 19. Vim • vim-pathogen or vundle (for plugins) • snipmate (like TextMate) • tabular • syntastic • mv-vim-puppet
    20. 20. Class Layout & Parameter Naming
    21. 21. Tex t http://ruth-tay.deviantart.com
    22. 22. VS
    23. 23. Private classes should be discrete
    24. 24. Validate your input
    25. 25. https://github.com/stdmod/pup pet-modules A community-driven effort to standardize on param names
    26. 26. Roles & Profiles
    27. 27. Roles are the service to be offered, roll-up profiles Profiles merge tech modules with business logic
    28. 28. Containment
    29. 29. Anchor Pattern
    30. 30. Contain (Puppet 3.4+)
    31. 31. Documentation the most important part!
    32. 32. Answer these questions • What technology does your module manage? • What does it intend to do? • How does it do it? (impact on the system) • How should one use it?
    33. 33. http://docs.puppetlabs.com/puppet/3/reference/modules_ documentation.html
    34. 34. Versioning
    35. 35. Semantic Versioning • Based on Major.Minor.Patch scheme • X.0.0 Major version for breaking change • 0.X.0 Minor version for new non-breaking functionality • 0.0.X Patch version for backwards compatible bug fixes
    36. 36. http://links.puppetlabs.com/bgtm
    37. 37. Data & Modules
    38. 38. Why separate?
    39. 39. Two Types of Data • Site • Which port do I bind to? • Logistics • Which package for this OS?
    40. 40. Logistics • params.pp • ripienaar/module_data
    41. 41. http://forge.puppetlabs.com/ripienaar/module_data http://forge.puppetlabs.com/ripienaar/module_data ./data/operatingsystem/Amazon.yaml Params.pp
    42. 42. Site • node definitions • ENC
    43. 43. Automatic Data Lookup Built into Puppet 3
    44. 44. Here’s the magic!
    45. 45. Data Lookup Order • Use explicit class declaration values • • • Query Data Binding Use the default value from class. Fail compilation with an error if no value can be found.
    46. 46. Module Testing A Brief Overview
    47. 47. Smoke Testing http://www.dsrsd.com/img/img_wwrw/Sewer_Web.png
    48. 48. puppet apply ./tests/apache.pp
    49. 49. Unit Testing http://www.pieterg.com/Media/277
    50. 50. Integration Testing http://robots.thoughtbot.com/post/33771089985/rspec-integration-tests-with-capybara
    51. 51. rspec-system
    52. 52. Acceptance Testing
    53. 53. Beaker
    54. 54. Writing Better Modules • Keep them simple & modular • Consistent Style • Useful Documentation • Separate Code From Data • Test Against Regressions
    55. 55. Want to help? #PuppetCamp
    56. 56. Thank You! Feel free to email or tweet anytime RE: Forge! ryan@puppetlabs.com - @ryanycoleman forge.puppetlabs.com #PuppetCamp

    ×