Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print something when running Puppet client?

Tags:

puppet

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.

like image 338
Iftach Bar Avatar asked Nov 09 '10 15:11

Iftach Bar


People also ask

What does puppet agent command do?

Puppet agent is a core service that manages systems, with the help of a Puppet primary server. It requests a configuration catalog from a Puppet primary server server, then ensures that all resources in that catalog are in their desired state.

Which command would be used to run puppet?

Log into your primary server or client tools workstation and run one of the following commands: To specify the query on the command line: puppet job run --query '<QUERY>' <OPTIONS> To pass the query in a text file: puppet job run --query @/path/to/file.

How do you debug puppets?

Configuring the debug session To debug a simple manifest in VS Code, press F5 and VS Code will try to debug your currently active manifest by running the equivalent of puppet apply . Note that by default No Operation ( --noop ) is enabled so that your local computer will not be modified.


2 Answers

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

like image 153
Aleksey Timohin Avatar answered Sep 19 '22 10:09

Aleksey Timohin


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

like image 25
Michael Gisbers Avatar answered Sep 20 '22 10:09

Michael Gisbers