When Puppet isn't doing what you expect, it can be very difficult to work out why. A time-honored debugging technique used by many programmers is to print out information at different points to show you what's going on.
A handy way to do this is to use a
notify
resource. We've sneaked these into the book several times so far without explaining what they are. A notify
resource simply prints out its name to the console when you run Puppet:
notify { 'Got this far!': }
The preceding manifest produces:
ubuntu@demo:~/puppet$ papply Notice: Got this far! Notice: /Stage[main]//Node[demo]/Notify[Got this far!]/message: defined 'message' as 'Got this far!' Notice: Finished catalog run in 0.07 seconds
A simple message like this can help you figure out whether Puppet is even loading or applying a particular bit of code. If you want to find out the value of a variable at a certain point in the manifest, you can interpolate it into a string, like this:
notify { "I think my hostname...