Search code examples
puppet

What exactly is the difference between notify function and notice resource in Puppet?


I can display a custom message in two ways in Puppet, either by

notice("My extra information as a function")

or by

notify{"My extra information as a resource":}

Things in common:

  • Both get evaluated on Puppet Master.
  • Both have access to facts.
  • If message is composed from variables, both would display the same string.

Things that are different:

  • The order of execution. The functions gets evaluated first, during the compilation phase. Only then the resources are fulfilled.
  • The notify can be set as a virtual or exported resource, with important implications, which are unavailable for notice
  • The notice cannot display the calling path (there is no withpath => true)
  • notice has a sister function fail, which has a power to fail the compilation of the manifest. notify cannot do that, since it starts working when the compilation is already done.

I have a feeling that I missed important aspects or maybe I was wrong in some parts. Would someone better with Puppet than me fill more details?


Solution

  • notify sends a log message to the puppet agent whereas the notice function logs a message on the puppet server/master in the notice log-level. The same goes for the err, debug, info, and warning functions.

    Keep in mind, notify is a managed resource, whereas notice is a function executed on the master.