Puppet Module Best Practices - Puppet Camp Silicon Valley
-
Upload
puppet-labs -
Category
Documents
-
view
1.940 -
download
1
description
Transcript of Puppet Module Best Practices - Puppet Camp Silicon Valley
Ryan ColemanWriting Better
Modules@ryanycoleman | [email protected]
Where I Came From
• Penn Stater
• Professional Traveler
• Blacksmith
#PuppetCamp
#PuppetCamp
#PuppetCamp
#PuppetCamp
#PuppetCamp
#PuppetCamp
#PuppetCamp
Writing Better Modules
#PuppetCamp
Why Share?
Keep it modular
Dependencies can be your friend
PL Style Guide#PuppetCamp
#PuppetCamp
#PuppetCamp
#PuppetCamp
#PuppetCamp
Development Tools
Vim
•vim-pathogen or vundle (for plugins)
•snipmate (like TextMate)
•tabular
•syntastic
•mv-vim-puppet
Class Layout & Parameter Naming
Text
http://ruth-tay.deviantart.com/art/Hydra-121089045
VS
Private classes should be discrete
Validate your input
https://github.com/stdmod/puppet-modules
A community-driven effort to standardize on param names
Roles & Profiles
Roles are the service to be offered, roll-up profiles
Profiles merge tech modules with business logic
Containment
Anchor Pattern
Contain (Puppet 3.4+)
Documentationthe most important part!
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?
http://docs.puppetlabs.com/puppet/3/reference/modules_documentation.html
Versioning
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
http://links.puppetlabs.com/bgtm
Data & Modules
Why separate?
Two Types of Data
•Site
•Which port do I bind to?
•Logistics
•Which package for this OS?
Logistics
•params.pp
•ripienaar/module_data
Params.pp
./data/operatingsystem/Amazon.yaml
http://forge.puppetlabs.com/ripienaar/module_data
http://forge.puppetlabs.com/ripienaar/module_data
Site
•node definitions
•ENC
Automatic Data Lookup
Built into Puppet 3
Here’s the magic!
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.
Module TestingA Brief Overview
Smoke Testing
http://www.dsrsd.com/img/img_wwrw/Sewer_Web.png
puppet apply ./tests/apache.pp
Unit Testing
http://www.pieterg.com/Media/277
Integration Testing
http://robots.thoughtbot.com/post/33771089985/rspec-integration-tests-with-capybara
rspec-system
Acceptance Testing
Beaker
Writing Better Modules
•Keep them simple & modular
•Consistent Style
•Useful Documentation
•Separate Code From Data
•Test Against Regressions
Want to help?
#PuppetCamp
Thank You!
Feel free to email or tweet anytime RE: Forge!
[email protected] - @ryanycoleman
forge.puppetlabs.com
#PuppetCamp