Logging debug messages
It can be very helpful when debugging problems if you can print out information at a certain point in the manifest. This is a good way to tell, for example, if a variable isn't defined or has an unexpected value. Sometimes it's useful just to know that a particular piece of code has been run. Puppet's notify
resource lets you print out such messages.
How to do it…
Define a notify
resource in your manifest at the point you want to investigate:
notify { 'Got this far!': }
How it works…
When this resource is applied Puppet will print out the message:
notice: Got this far!
There's more…
If you're the kind of brave soul who likes experimenting, and I hope you are, you'll probably find yourself using debug messages a lot to figure out why your code doesn't work. So knowing how to get the most out of Puppet's debugging features can be a great help.
Printing out variable values
You can refer to variables in the message:
notify { "operatingsystem is ${::operatingsystem}": }
And Puppet...