How to print something when running Puppet client?

I want to print out messages and variables when Puppet runs. I saw there are two functions that might help but couldn't really use them. My site.pp file:

info "running site.pp info"
debug "running site.pp debug"

When I run on the client:

puppet -t

I don't get those prints.


Solution 1:

Here is the puppet script with all the available puppet log functions.

log_levels.pp

node default {
  notice("try to run this script with -v and -d to see difference between log levels")
  notice("function documentation is available here: http://docs.puppetlabs.com/references/latest/function.html")
  notice("--------------------------------------------------------------------------")

  debug("this is debug. visible only with -d or --debug")
  info("this is info. visible only with -v or --verbose or -d or --debug")
  alert("this is alert. always visible")
  crit("this is crit. always visible")
  emerg("this is emerg. always visible")
  err("this is err. always visible")
  warning("and this is warning. always visible")
  notice("this is notice. always visible")
  #fail will break execution
  fail("this is fail. always visible. fail will break execution process")

}

Script output (on puppet 2.7): different log levels colors

NB: puppet 3.x colours may alter (all the errors will be printed in red)!

Solution 2:

from the Puppet function documentation

info: Log a message on the server at level info.
debug: Log a message on the server at level debug.

You have to look a your puppetmaster logfile to find your info/debug messages.

You may use

notify{"The value is: ${yourvar}": }

to produce some output to your puppet client