问题原文
原帖链接 · 030 · CC BY-SA 3.0
The expectation was that there would be a mailto attribute, but the this source denies that
cron { 'resource title': name => # (namevar) The symbolic name of the cron job. This name is ensure => # The basic property that the resource should be... command => # The command to execute in the cron job. The... environment => # Any environment settings associated with this... hour => # The hour at which to run the cron job. Optional; minute => # The minute at which to run the cron job... month => # The month of the year. Optional; if specified... monthday => # The day of the month on which to run the... provider => # The specific backend to use for this `cron... special => # A special value such as 'reboot' or 'annually'... target => # The name of the crontab file in which the cron... user => # The user who owns the cron job. This user must... weekday => # The weekday on which to run the command... # ...plus any applicable metaparameters. }
The docs does not indicate if mailto is supported, e.g.:
environment
(Property: This attribute represents concrete state on the target system.)
Any environment settings associated with this cron job. They will be stored between the header and the job in the crontab. There can be no guarantees that other, earlier settings will not also affect a given cron job.
Also, Puppet cannot automatically determine whether an existing, unmanaged environment setting is associated with a given cron job. If you already have cron jobs with environment settings, then Puppet will keep those settings in the same place in the file, but will not associate them with a specific job.
Settings should be specified exactly as they should appear in the crontab, e.g., PATH=/bin:/usr/bin:/usr/sbin.
已采纳解答
原帖链接 · daff · CC BY-SA 4.0
The built-in Puppet type cron as referenced in the question has a property named environment that can be used to set environment variables for the managed cronjob.
In this case it would look like this, setting the MAILTO variable to foobar so that output of the cronjob will be mailed to user foobar:
cron { 'some-cron-job':
...
environment => 'MAILTO=foobar',
}
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
