About | FAQ | Help
Ask Your Question

send email whenever service is started

asked 2013-12-09 02:18:51 -0500

Red Cricket gravatar image

updated 2013-12-09 02:29:55 -0500

I have a module that has these lines ...

    # make sure foo is up and running
    service { "foo":
                    name    => "foo" ,
                  enable  => true ,
                  ensure  => running,

and when I run # pkill -9 foo on the agent, puppet restarts foo just fine, but I would like to have an email sent to me whenever foo needed to be started.


edit retag flag offensive close merge delete



Try with the tagmail feature (http://docs.puppetlabs.com/references/latest/report.html#tagmail), however not sure if it only trigger when there is a state change.

golja gravatar imagegolja ( 2013-12-09 10:28:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-12-09 05:38:51 -0500

doc75 gravatar image


One idea would be to add an Exec statement in your manifest:

exec { 'send email on restart of service x':
   command     => 'script_sending_mail.sh',
   refreshonly => true, # ensure only run when service is modified
   path        => [ 'dir1', 'dir2'], # any directory need to run the script above

You just need to add the

notify => Exec['send email on restart of service x']

inside your service definition.

This is just a guess and has not been tested. Hope this helps.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-12-09 02:18:51 -0500

Seen: 683 times

Last updated: Dec 09 '13