How to send console notice to notify email?

14 views
Skip to first unread message

staceyt...@gmail.com

unread,
Apr 3, 2017, 11:12:00 AM4/3/17
to Puppet Users
Hi,

I am using open source puppet 3.7.3 master and client.

I would like to send the notice output of a manifest to email (I don't want to receive email about all manifests' notice, just this special manifest).

In /etc/puppet/tagmail.conf:
pkgNotSync_notice: mye...@hotmail.com

Then I created a new manifest called "pkgcheck" which will call a custom function. This custom function (http://ryanuber.com/11-06-2012/manage-sets-of-packages-in-puppet.html) is called "apply_package_list". It will check what packages are missing or with incorrect version. This function accepts two argument and has no return value.

Then I created /etc/puppet/modlues/pkgcheck/manifests/init.pp and checkpkg.pp.

In checkpkg.pp, I call this function first, then create a notify resource:

class pkgcheck::checkpkg inherits pkgcheck  {
 
   apply_package_list('/root/packagelist', 'nopurge')
  
   notify { 'packageCheck':
      noop    => true,   
      tag     => packageNotSync_notice,     
  }
}

When I ran "puppet agent -t" on my client machine, the console displays exactly what two packages are not synced (caironmm-1.0.x86_64 and libkkc-0.2.1-9.el7.x86_64):

Notice: /Package[caironmm-1.0.x86_64]/ensure: current_value absent, should be latest (noop)
Notice: /Package[libkkc-0.2.1-9.el7.x86_64]/ensure: current_value absent, should be latest (noop)
Notice: /Stage[main]/Pkgcheck::Checkpkg/Notify[packageCheck]/message: current_value absent, should be packageCheck (noop)

However, in the email I received, it only contains the last line which list the overall result:

Mon Apr 03 10:48:25 -0400 2017 /Stage[main]/Pkgcheck::Checkpkg/Notify[packageCheck]/message (notice): current_value absent, should be packageCheck (noop)

I would like to receive the email which looks the same as what is displayed on the console for this manifest.

Please advise how I can achieve this purpose?

Thanks,
Stacey
Reply all
Reply to author
Forward
0 new messages