Using the puppet debugger for lightweight exploration.
Note: all the cool embedded videos did not convert on slideshare. They will be posted later on puppet-debugger.com
2. • Twitter: @cosman2001
• Github: logicminds, nwops
• Blog: logicminds.github.io
• Slack: nwops
• Email: corey@nwops.io
• Telegram: opselite
• Devops Toolsmith and Consultant
• Puppet Service Delivery Partner
• Ruby, Node, Go Developer
• Crypto Miner and Developer
• Privacy and Security Advocator
• Retrospec-puppet
• Vim and VSCode User
• Puppet User since 2009 (10 years
Corey Osman
3. PuppetizePDX 2019
NWOPS, LLC
https://www.nwops.io
Efficient Development
“Speed (or velocity, if you prefer) is how quickly you
can accomplish a task. Efficiency is a comparison -
- a ratio -- of the useful work performed by a
machine or in a process to the total work needed to
complete a process. Speed and efficiency are
related, but they're not synonymous.”
Input / Output
4. PuppetizePDX 2019
NWOPS, LLC
https://www.nwops.io
Progressive Development
• Gain perspective.
• Evaluate your methods and procedures.
• Learn your editor and surrounding tools.
• Optimize yourself and the environment around you.
• Share with others often.
• Be aware of tools that can help you.
• Change is hard. Deal with it!
There is always a better way.
5. PuppetizePDX 2019
NWOPS, LLC
https://www.nwops.io
What is a Debugger?
• Tool used to test and debug other programs from
source code
• Expression evaluator
• Allows you to step through code
• Record and playback
• Interactive
6. PuppetizePDX 2019
NWOPS, LLC
https://www.nwops.io
Why We Need a Debugger
• Understand how values are interpolated
• Understand what functions do
• Understand how scopes work
• Understand how iterators work
• Understand how hashes and variables work
• Share code easily with the play function
• Step through your code with breakpoints
9. PuppetizePDX 2019
NWOPS, LLC
https://www.nwops.io
Testing Thoughts
• Instant feedback when compared to unit tests
• Test datatypes in real time
• Test regular expressions in real time
• Test functions in real time
• Test lookup constructs in real time
14. PuppetizePDX 2019
NWOPS, LLC
https://www.nwops.io
Break Into Your Puppet Code
• Set a breakpoint in your Puppet code (Linux support only)
• Inspect variables in any scope
• Inject the Debugger from any of the following:
• puppet apply
• spec test
• puppet debugger command
• pdk console
• pdk test
16. PuppetizePDX 2019
NWOPS, LLC
https://www.nwops.io
Integration with PDK
• PDK 1.14+ ships with the console command that invokes
the Debugger
• Works only within modules and control repos at this time
• Control repo must have a Gemfile
• Can use PDK test unit and debug::break() function
• Interchangeable rubies and puppets
• https://github.com/puppetlabs/pdk#pdk-console-command
How much input must you provide to equal the output of others? What makes you different?
How do you become more efficient? By learning how things work and not rely on google.
Spread the word by sharing what you learn.
You must measure the effort vs reward, not everything is worth doing
Continuous Improvement
Who here considers themselves a sysadmin? False! Everyone is a developer in here.
One way to become more efficient is to speed up the your feedback loop and method of learning. Remove the search engine delay if possible. A debugger can help.
Do I need to specify quotes in hash key name? How does the dig function work?
Don’t just bang on the keyboard. Bang on the keyboard with purpose!
Is there a better way? I had perspective from the programming world.
Put down your abacus and play inactively.
We can’t test thoughts with unit tests (us humans are too lazy)
Don’t think, know. Validate your thoughts in the debugger.
The goal is to bring the environment as close as possible, build scale models at home before you build an interstate.
Overall goal is to completely replicate the catalog compilation process without the server or a real environment.
This is an advanced feature and requires access to the puppet infrastructure