ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code
-
Upload
byron-miller -
Category
Technology
-
view
62 -
download
0
Transcript of ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code
![Page 1: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/1.jpg)
Austin Puppet Users Group
(ATXPUG)
Managing Puppet Complexity
![Page 2: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/2.jpg)
Modules & Complexity
Complexity is generally used to characterize something with many parts where those parts interact with each other in multiple ways.
![Page 3: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/3.jpg)
Style
• Make quality a requirement
• Know when to stop (don’t over optimize)
• DRY – Don’t Repeat Yourself
![Page 4: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/4.jpg)
DRY – Don’t repeat yourself
• Imposed Duplication – Apparent lack of choice
• Inadvertent Duplication – Not realize that they’re duplicating information
• Impatient Duplication – lazy / duplicate because it seems easier
• Interdeveloper Duplication – Multiple people on teams / multiple teams.
![Page 5: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/5.jpg)
Code
• Keep low level knowledge in code
• Reserve Comments for high level expectations
• Foster an environment where it’s easier to find and reuse existing stuff than to write it yourself.
![Page 6: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/6.jpg)
Avoid Global data
• Every time you reference global data it ties you to the other components that share data – frowned upon since 2.x days but still in a lot of puppet code
![Page 7: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/7.jpg)
Orthogonal - Safe to Fail
• Independent / lightly coupled systems
– Eliminates effects of unrelated things
– Design self contained things
• Increased productivity & contained risk
![Page 8: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/8.jpg)
Prototype (experiment)
• Architecture
• New functionality in existing systems
• Structure or contents of external data
• Third party tools or components
• Performance issues
• User interface / experience / design
![Page 9: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/9.jpg)
Experiements
• Worry less about correctness, completeness, robustness and style.
• Focus on design / definition
• Is coupling minimized?
• Can you identify potential sources of duplication?
![Page 10: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/10.jpg)
Style Guides
• https://docs.puppetlabs.com/guides/style_guide.html
![Page 11: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/11.jpg)
Test
• Loosely coupled systems easier to test –interactions between components are limited.
– Unit testing is easier
– Test in CI pipeline
• Beaker / rspect / puppet lint
![Page 12: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/12.jpg)
Refactor
• Avoid code rot. Don’t let bad code fester and turn all your code into abandonware
![Page 13: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/13.jpg)
It’s code
• Version control
• Test
• Refactor
• Share.
• forge
![Page 14: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/14.jpg)
Module Template
• Puppet Module Generate – use the boiler plate
• Use Garethr’s boiler plate – nice & updated
https://github.com/garethr/puppet-module-skeleton (more assumptions though)
![Page 15: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/15.jpg)
Data Separation
• Some use hiera.. Me no like
• ENC
– Puppet PE
– Foreman
– Homebrew
– ?
• Single source of truth? How?
![Page 16: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/16.jpg)
Parameterized Classes
• Great for ENCs
• Easy to set default values
• Portable / Shareable
![Page 17: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/17.jpg)
Class Inheritance
• Use within a module to reduce repetition (DRY)
• Inheriting from other modules decreases modularity, but hard to avoid
– ENC confusion
![Page 18: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/18.jpg)
Code Defensively
• Catch unexpected events before they break things – gracefully bow out if you don’t support platform
• Puppet Future parser helps –
– Line error failure reporting
– Type checking (out of stdlib)
![Page 19: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/19.jpg)
I wish
• More modules exposed puppet resources
• Augeus (or similar) was internalized across every platform so there was an easy meta catalog instead of is osfamily = yaddy yaddyyadda
• Open source puppet had strong direction.. 3.7 PE is out.. What next for OS?
![Page 20: ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code](https://reader036.fdocuments.in/reader036/viewer/2022071815/55a93a2c1a28ab2f0a8b4876/html5/thumbnails/20.jpg)
Discussions
• I’m out of slides, time for interaction