Slides from a talk I gave at PuppetConf 2014.
Abstract: Puppet is an incredibly powerful tool, and part of that power is its flexibility. Flexibility often leads to a wide range of ideas on implementation. I've consulted on countless Puppet implementations, and I've seen the entire spectrum, ranging from bat-shit insane to picture perfect. But even the bat-shit insane implementations worked (to a point), and at some point, what seemed bat-shit to me was picture perfect to the folks running it. As I got to understand some of the unique implementations, I started to ask myself: if there's no clear right way to implement Puppet, is there a particularly effective way?
When trying to answer this question I started by looking at the teams who got it right, and a pattern quickly emerged. All of these teams had common behaviors that went far beyond policies and procedures. These behaviors were broadly understood by team members, nearly universally adhered to, and almost second nature. These habits led to more stable, maintainable, and well understood Puppet deployments. In this talk, I'll share with you the behaviors I saw and discuss how you can turn these seemingly obvious best practices into habits amongst your team members.
13. 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
14. Seven Habits of Highly Effective Puppet Users
Habit #1
Think like a software developer
14Habit 1: Think like a software developer
15. Seven Habits of Highly Effective Puppet Users
You’re not a system administrator
anymore
15Habit 1: Think like a software developer
16. Seven Habits of Highly Effective Puppet Users
You’re a software developer
16Habit 1: Think like a software developer
17.
18. Seven Habits of Highly Effective Puppet Users
System Administration
≠
Software Development
18Habit 1: Think like a software developer
19. Seven Habits of Highly Effective Puppet Users
Why did we think this would be
easy?!
19Habit 1: Think like a software developer
20. Seven Habits of Highly Effective Puppet Users
Puppet is easy because it’s a DSL
20Habit 1: Think like a software developer
22. Seven Habits of Highly Effective Puppet Users
We just made it easy to write bad
code
22Habit 1: Think like a software developer
23. 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
24. I’m a doctor, not an engineer.I’m a doctor, not an engineer.24
25. Seven Habits of Highly Effective Puppet Users
Software engineering is a mature
discipline
25Habit 1: Think like a software developer
26. Seven Habits of Highly Effective Puppet Users
This is particularly important in
Puppet 4
26Habit 1: Think like a software developer
27. Seven Habits of Highly Effective Puppet Users
Habit #2
Treat Puppet like code
27Habit 2: Treat Puppet like code
28. Seven Habits of Highly Effective Puppet Users
Stop thinking of Puppet
as just configuration data
28Habit 2: Treat Puppet like code
29. Seven Habits of Highly Effective Puppet Users
Infrastructure as
CODE
29Habit 2: Treat Puppet like code
30. Seven Habits of Highly Effective Puppet Users
Infrastructure as
CODE
30Habit 2: Treat Puppet like code
31.
32. Seven Habits of Highly Effective Puppet Users
Version Control
32Habit 2: Treat Puppet like code
33.
34. Seven Habits of Highly Effective Puppet Users
Documentation
34Habit 2: Treat Puppet like code
35.
36. Seven Habits of Highly Effective Puppet Users
README
36Habit 2: Treat Puppet like code
37.
38. Seven Habits of Highly Effective Puppet Users
Inline documentation
38Habit 2: Treat Puppet like code
39.
40. Seven Habits of Highly Effective Puppet Users
Refactoring
40Habit 2: Treat Puppet like code
70. Seven Habits of Highly Effective Puppet Users
Write modules as if they’re going to
be open sourced
70Habit 3: Stop, drop, and design
71. Seven Habits of Highly Effective Puppet Users
Habit #4
Test all the things
71Habit 4: Create a culture of testing
72.
73. Seven Habits of Highly Effective Puppet Users
The toolchain has improved
dramatically
73Habit 4: Create a culture of testing
74. Seven Habits of Highly Effective Puppet Users
Testing has become relatively
inexpensive
74Habit 4: Create a culture of testing
75. Seven Habits of Highly Effective Puppet Users
Your infrastructure is too important
to not test
75Habit 4: Create a culture of testing
76.
77. Seven Habits of Highly Effective Puppet Users
How?
77Habit 4: Create a culture of testing
78. Seven Habits of Highly Effective Puppet Users
puppet-syntax
78Habit 4: Create a culture of testing
79. Seven Habits of Highly Effective Puppet Users
rspec-puppet
79Habit 4: Create a culture of testing
80. Seven Habits of Highly Effective Puppet Users
describe ‘myclass’ do
it { should compile.with_all_deps }
end
80Habit 4: Create a culture of testing
81. Seven Habits of Highly Effective Puppet Users
beaker
81Habit 4: Create a culture of testing
82. Seven Habits of Highly Effective Puppet Users 82Habit 4: Create a culture of testing
kitchen-ci
83. Seven Habits of Highly Effective Puppet Users
serverspec
83Habit 4: Create a culture of testing
84. 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
85. Seven Habits of Highly Effective Puppet Users
Why test Puppet?
85Habit 4: Create a culture of testing
86. Seven Habits of Highly Effective Puppet Users
Complexity
86Habit 4: Create a culture of testing
87.
88. Seven Habits of Highly Effective Puppet Users
Test first!
88Habit 4: Create a culture of testing
89. Seven Habits of Highly Effective Puppet Users
Make your tests count
89Habit 4: Create a culture of testing
90.
91. 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
92. 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
93. Seven Habits of Highly Effective Puppet Users
Habit #5
Continuous Integration and
Deployment
93Habit 5: Continuous integration and deployment
94. Seven Habits of Highly Effective Puppet Users
Build a pipeline
94Habit 5: Continuous integration and deployment
95.
96. Seven Habits of Highly Effective Puppet Users
Automated testing
96Habit 5: Continuous integration and deployment
97. Seven Habits of Highly Effective Puppet Users
Unit Tests
97Habit 5: Continuous integration and deployment
98. Seven Habits of Highly Effective Puppet Users
Integration Tests
98Habit 5: Continuous integration and deployment
99. Seven Habits of Highly Effective Puppet Users
Acceptance tests
99Habit 5: Continuous integration and deployment
100. Seven Habits of Highly Effective Puppet Users
Test under real world conditions
100Habit 5: Continuous integration and deployment