There are two supported ways to debug Ruby code with puppetserver
—ruby-debug and Pry. Both of these will implement a Read Eval Print Loop (REPL). A REPL allows you to type commands and have them evaluated in real time. When working with puppetserver
, this gives you the power to inspect the puppetserver
process while it is compiling a catalog or processing a report. Both ruby-debug and Pry are installed as Ruby gems. To use them with puppetserver
, you have to install them by using the puppetserver gem
command. I prefer to use Pry. So, I will show you how to use Pry in this example. We'll inspect calls to the hiera
function by using Pry. To start, install Pry for use within puppetserver
, as follows:
[root@puppet ~]# puppetserver gem install pry Fetching: coderay-1.1.0.gem (100%) Successfully installed coderay-1.1.0 Fetching: slop-3.6.0.gem (100%) Successfully installed slop-3.6.0 Fetching: method_source-0.8.2.gem (100%) Successfully installed method_source-0.8.2 Fetching: spoon...