1

Is there a way to print out messages to the console before executing a command in puppet. For example, let's say my manifest has:

exec {
    command => 'mycommandhere'
} 

I would like to print a message that says 'Running my command'. Is there an easy way to do this, other than calling another command before it that does the print out?

2
  • 3
    Is there some reason why you don't just call puppet with the --debug option?
    – Zoredache
    Mar 1, 2012 at 5:20
  • Didn't think of that -- I'm still pretty new to puppet. thanks. Mar 1, 2012 at 13:34

3 Answers 3

6

Sure, just chain two resources together:

notify { 'some-command':
  message => 'some-command is going to be executed now'
}

exec { 'some-command':
  command => '/path/to/some-command',
}

Notify['some-command'] -> Exec['some-command']
0
3

There is no way to write your puppet manifest to print a message exactly before your exec resource other than making it a part of the exec. For the general case of printing messages, look at notify. For your specific case, perhaps running puppet in verbose or debug mode will work.

0

You can use notice() or warning() (depending on what you want to tell the user)

notice( 'some-command is going to be executed now' )

and then simply exec right after that line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .