Basic Usage

Once you have installed the debugger you just need to execute puppet with the debugger subcommand.

$ puppet debugger
Ruby Version: 3.2.8
Puppet Version: 8.10.0
Puppet Debugger Version: 1.6.0
Created by: NWOps <corey@nwops.io>
Type "commands" for a list of debugger commands
or "help" to show the help screen.


1:>>

Once you have the debugger started, use the commands command to show a list of commands.

At any point you can type any valid puppet code. Start with a few simple things then move onto more advanced puppet concepts. Just remember “garbage in, garbage out”. Syntax errors, duplicate resources, and variable re-definations will show their relevant errors.

  1. Variable assignment: $var1 = 'kaboom!'
  2. Run a function: sha1('12345')
  3. include a class include stdlib

PDK Usage

With the future inclusion of the pdk bundle exec puppet debugger command in the PDK. The puppet debugger has never been easier to use. Additionally the PDK also exposes some unique features only included with the PDK.

The pdk bundle exec puppet debugger command executes a session of the puppet debugger when inside a module and allows for exploration of puppet code.

To use, execute pdk bundle exec puppet debugger from inside your module directory. You can also supply the --puppet-version or --pe-version or --puppet-dev to swap out the puppet version when using the console. This is the unique feature that PDK provides for the debugger and is extremely valuable when determine differences between puppet versions.

Example (from within a module):

  • pdk bundle exec puppet debugger --puppet-version=5
  • pdk bundle exec puppet debugger --pe-version=2018.1

PLease note when using the new pdk bundle exec puppet debugger command the same puppet debugger options and arguments will still apply as they are simply passed through to the puppet debugger.

Example:

puppet debugger --no-facterdb --run-once -e "$os"

vs

pdk bundle exec puppet debugger --no-facterdb --run-once -e "$os"