Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
3  
Is there some reason why you don't just call puppet with the --debug option? –  Zoredache Mar 1 '12 at 5:20
    
Didn't think of that -- I'm still pretty new to puppet. thanks. –  Jeff Storey Mar 1 '12 at 13:34
add comment

3 Answers

up vote 5 down vote accepted

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']
share|improve this answer
    
Thanks for the reply. –  Jeff Storey Mar 21 '12 at 4:52
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.