- Puppet 2.7 Cookbook
- John Arundel
- 413字
- 2021-04-02 18:19:58
E-mailing log messages containing specific tags
If, like most sysadmins, you feel like you don't get enough e-mail, you'll be looking for a way to generate more. Another type of Puppet report is called tagmail
. This will e-mail the log messages to any address you specify.
How to do it…
- Add
tagmail
to the comma-separated list of reports inpuppet.
conf:[master] reports = store,tagmail
- Add some tags and associated e-mail addresses in the file
/etc/puppet/tagmail.conf
. For example, this line will e-mail all log messages to me:all: john@example.com
- When Puppet runs, you will get an e-mail that looks like the following:
From: report@cookbook.bitfieldconsulting.com Subject: Puppet Report for cookbook.bitfieldconsulting.com To: john@example.com Mon Jan 17 08:42:30 -0700 2011 //cookbook.bitfieldconsulting.com/Puppet (info): Caching catalog for cookbook.bitfieldconsulting.com Mon Jan 17 08:42:30 -0700 2011 //cookbook.bitfieldconsulting.com/Puppet (info): Applying configuration version '1295278949'
How it works…
Puppet looks at each line in tagmail.conf
and sends any messages matching the tag to the e-mail address specified. The special tag all
matches all messages. The tag err
matches errors as shown in the following code snippet:
err: john@example.com
You can list as many rules as you like in the tagmail.conf
file, and Puppet will send e-mails for all rules that match. In the following example, errors go to one address, and web server related messages go to another:
err: puppetmaster@example.com webserver: webteam@example.com
There's more…
The tagmail
reports are a powerful feature which you may need to experiment with a bit so that you can get the most out of them. I have given a few tips to help you in the following text.
What are tags?
Tags are explained in more detail later in this book, but for reporting purposes, it's enough to know that a tag can be the name of a node or a class. For example, the tag webserver
is matched if a machine includes the class webserver
. You can also add a tag explicitly, using the tag
function as follows:
class exim { tag("email") service { "exim4": ensure => running, enable => true, } }
Specifying multiple tags, or excluding tags
You can specify a comma-separated list of tags in tagmail.conf
, and also exclude certain tags by using an exclamation point (!
).
all, !webserver: puppetmaster@example.com
Sending reports to multiple e-mail addresses
You can send messages to multiple, comma-separated e-mail addresses as shown in the following code-snippet:
err: puppetmaster@example.com, sysadmin@example.com
See also
- Generating reports in this chapter
- Creating graphical reports in this chapter
- Using tags in this chapter
- Apache OFBiz Development: The Beginner's Tutorial
- 中文版AutoCAD 2016從入門到精通
- Premiere Pro 2022短視頻剪輯、調(diào)色與特效制作實(shí)戰(zhàn)(全彩微課版)
- Excel 2013使用詳解(修訂版)
- 中文版3ds Max 2016/VRay效果圖制作實(shí)戰(zhàn)基礎(chǔ)教程
- 中文版Illustrator 2021完全自學(xué)教程
- UG NX 12.0實(shí)例寶典
- 中文版Photoshop CS6平面設(shè)計(jì)實(shí)用教程(第2版)
- 24小時(shí)全速學(xué)會(huì)Photoshop 2021
- Moldflow 2021模流分析從入門到精通(升級(jí)版)
- 中文版Photoshop CC基礎(chǔ)培訓(xùn)教程
- Python Testing Cookbook
- Photoshop海報(bào)設(shè)計(jì)技巧與實(shí)戰(zhàn)
- UG NX 12.0中文版實(shí)戰(zhàn)從入門到精通
- 中文版SolidWorks 2018完全實(shí)戰(zhàn)技術(shù)手冊(cè)