Seven Habits of Highly Effective Puppet Users
David Danzilio @djdanzilio
1
$(whoami)
2
What’s talk this about?
A collection of observations of high performing Puppet users
Habits?
What’s a habit?
“[A habit is] an acquired behavior pattern regularly followed until it has become almost involuntary”
Habits are hard
You don’t think about habits
Seven Habits• Think like a software developer
• Treat Puppet like code
• Stop, drop, and design
• Test all the things
• Continuous integration and deployment
• Make nice with Ruby
• Get involved
Seven Habits of Highly Effective Puppet Users
Habit #1 Think like a software developer
14Habit 1: Think like a software developer
Seven Habits of Highly Effective Puppet Users
You’re not a system administrator anymore
15Habit 1: Think like a software developer
Seven Habits of Highly Effective Puppet Users
You’re a software developer
16Habit 1: Think like a software developer
Seven Habits of Highly Effective Puppet Users
System Administration ≠
Software Development
18Habit 1: Think like a software developer
Seven Habits of Highly Effective Puppet Users
Why did we think this would be easy?!
19Habit 1: Think like a software developer
Seven Habits of Highly Effective Puppet Users
Puppet is easy because it’s a DSL
20Habit 1: Think like a software developer
FALSEFALSE
Seven Habits of Highly Effective Puppet Users
We just made it easy to write bad code
22Habit 1: Think like a software developer
Seven Habits of Highly Effective Puppet Users
You can’t expect people to be good at something they’ve never done
23Habit 1: Think like a software developer
I’m a doctor, not an engineer.I’m a doctor, not an engineer.24
Seven Habits of Highly Effective Puppet Users
Software engineering is a mature discipline
25Habit 1: Think like a software developer
Seven Habits of Highly Effective Puppet Users
This is particularly important in Puppet 4
26Habit 1: Think like a software developer
Seven Habits of Highly Effective Puppet Users
Habit #2 Treat Puppet like code
27Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Stop thinking of Puppet as just configuration data
28Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Infrastructure as CODE
29Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Infrastructure as
CODE30Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Version Control
32Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Documentation
34Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
README
36Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Inline documentation
38Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Refactoring
40Habit 2: Treat Puppet like code
***
Seven Habits of Highly Effective Puppet Users
Code Review
42Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Style
43Habit 2: Treat Puppet like code
44
Seven Habits of Highly Effective Puppet Users
puppet-lint
45Habit 2: Treat Puppet like code
Seven Habits of Highly Effective Puppet Users
Habit #3 Stop, drop, and design
46Habit 3: Stop, drop, and design
47 **
Seven Habits of Highly Effective Puppet Users
Software needs to be designed
48Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Separation of Concerns
49Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Package, File, Service
50Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Roles and Profiles
51Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Identify Interfaces
52Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
What information does your module need?
53Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Where does that information come from?
54Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Where does that information need to go?
55Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Public and Private classes
56Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Data Separation
57Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Data in your Puppet code is bad
58Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Hiera
59Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
params
60Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Module data
61Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Stability
62Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Identify a stable feature set
63Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Semantic Versioning
64Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Simplicity
65Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
UNIX Philosophy
66Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Focus on your module’s core functionality
67Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Hooks
68Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
class jabberd ( ... $manage_package = true, $manage_repository = false, $manage_service = true, ... ) {
...
}
69Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Write modules as if they’re going to be open sourced
70Habit 3: Stop, drop, and design
Seven Habits of Highly Effective Puppet Users
Habit #4 Test all the things
71Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
The toolchain has improved dramatically
73Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
Testing has become relatively inexpensive
74Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
Your infrastructure is too important to not test
75Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
How?
77Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
puppet-syntax
78Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
rspec-puppet
79Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
describe ‘myclass’ do it { should compile.with_all_deps } end
80Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
beaker
81Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users 82Habit 4: Create a culture of testing
kitchen-ci
Seven Habits of Highly Effective Puppet Users
serverspec
83Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
describe package('httpd') do it { should be_installed } end
describe service('httpd') do it { should be_enabled } it { should be_running } end
describe port(80) do it { should be_listening } end
84Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
Why test Puppet?
85Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
Complexity
86Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
Test first!
88Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
Make your tests count
89Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
it do should contain_file(‘/etc/ssh/sshd_config’).with({ ‘ensure’ => ‘present’, ‘owner’ => ‘root’, ‘group’ => ‘root’, ‘mode’ => ‘0644’, }) end
91Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
context ‘with port => 2222’ do let(:params) {{ :port => ‘2222’ }}
it do should contain_file(‘/etc/ssh/sshd_config’).with_content( %r{Port 2222} ) end end
92Habit 4: Create a culture of testing
Seven Habits of Highly Effective Puppet Users
Habit #5 Continuous Integration and
Deployment
93Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Build a pipeline
94Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Automated testing
96Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Unit Tests
97Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Integration Tests
98Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Acceptance tests
99Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Test under real world conditions
100Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Seven Habits of Highly Effective Puppet Users
Puppet versions
103Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Operating System versions
104Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Ruby versions
105Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Dependency versions
106Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Automated deployment
107Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
librarian-puppet, r10k, MCollective, Capistrano
108Habit 5: Continuous integration and deployment
Seven Habits of Highly Effective Puppet Users
Habit #6 Make nice with Ruby
109Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
Puppet is Ruby
111Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
Get over it
112Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
Why?
114Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
rake
115Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
rspec
116Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
bundler
117Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
guard
118Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
Custom Types, Providers, and Facts
119Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
If you want to do anything advanced
120Habit 6: Make nice with Ruby
Seven Habits of Highly Effective Puppet Users
Habit #7 Get involved
121Habit 7: Get involved
Seven Habits of Highly Effective Puppet Users
Puppet is rapidly evolving
122Habit 7: Get involved
Seven Habits of Highly Effective Puppet Users
Your experience is valuable
123Habit 7: Get involved
Seven Habits of Highly Effective Puppet Users
Share your modules
124Habit 7: Get involved
Seven Habits of Highly Effective Puppet Users
Speak at conferences
125Habit 7: Get involved
Seven Habits of Highly Effective Puppet Users
Answer questions
126Habit 7: Get involved
Seven Habits of Highly Effective Puppet Users
Blog about it
127Habit 7: Get involved
Questions?
Thank you!
David Danzilio@djdanzilio
http://blog.danzilio.net
Image Credits
• http://simpsons.wikia.com/wiki/File:Homer-simpson-brain,1280x800,18857.jpg • https://dcarchives.files.wordpress.com/2014/06/habit-change-1964-mcphee-priller.jpg • http://www.quickmeme.com/meme/3plfef • http://www.quickmeme.com/Bad-Habit-Bruce • http://www.mememaker.net/static/images/templates/747303.jpg • http://knowyourmeme.com/photos/230191-wtf-is-this-shit • http://programmerryangosling.tumblr.com/image/22790837971 • http://www.quickmeme.com/img/d3/d36ad81bae0a8d69cd91f81065d8b0a19d9dfc1b63753093992282d6aa8b35dd.jpg • http://www.avatar3trailer.com/gangnam-style/gangnam_style_psy_05.jpg • http://www.troll.me/images/pissed-off-obama/refactor-your-fucking-code.jpg • http://www.globalnerdy.com/2011/05/30/ruby-foo/ • http://www.quickmeme.com/meme/3twnp6 • http://smashingboxes.com/ideas/beginners-guide-to-test-driven-development-tdd • http://www.pythian.com/blog/service-reliability-how-systems-administration-is-evolving-part-one/ • http://www.troll.me/2012/03/07/uncategorized/dont-worry-guys-i-got-programmer-cred/ • http://www.savthecoder.com/blog/saturday-meme-5-futurama-fry-tests-his-new-method • http://www.quickmeme.com/meme/3uc80p/ • http://i.qkme.me/3tde6j.jpg • http://i.qkme.me/3sekdw.jpg • http://www.quickmeme.com/meme/3sm9k1?id=229466593 • http://i.ytimg.com/vi/HUSSKWWg-0c/maxresdefault.jpg • http://blog.15five.com/wp-content/uploads/2013/09/Hypnosis_for_bad_habits_nyc.jpg • http://www.keepcalm-o-matic.co.uk/p/keep-calm-and-rtfm-27/