How to print something when running Puppet client?

Iftach Bar picture Iftach Bar · Nov 9, 2010 · Viewed 99.4k times · Source

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.

Answer

Aleksey Timohin picture Aleksey Timohin · May 21, 2013

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)!