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?

Jeff Storey
  • 448
  • 1
  • 7
  • 19

3 Answers3

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']
Justin
  • 226
  • 1
  • 1
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.

sciurus
  • 12,678
  • 2
  • 31
  • 49
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.

kaiser
  • 1,251
  • 1
  • 16
  • 24