On Thu, Jul 7, 2011 at 9:43 AM, romuald FREBAULT <[email protected]> wrote:
> Hi,
>
> We decide to manage all our specific crons for applications with puppet.
> As all people who creates crons does'nt have to cope with puppet syntax, the
> easier way to do that seemed to be giving them a place on the puppetmaster
> where placing their crons, and deploying those crons in /etc/cron.d on
> nodes.
> That works fine, but i can't get a cron being removed on the node when
> removed on the puppetmaster.
>
> I can't use purge (it would be too easy ;-) because some package install
> crons in /etc/crons.d and we don't want to remove these crons, and we don't
> want to get them handle by puppet due to errors risk in case of
> update/upgrade....
>
> has anyone an idea of how i could have managed files removed on destnation
> when removed from source without using the entierely purge function?
>
Well just an idea and it's a bit hideous because I'm abusing resource
behaviors, and please give it more testing and feedback. So the
process:
deploy cron jobs with .puppet extension
touch any crontab files with puppet extentions (unless mask the Exec
so it doesn't show up in logs).
use tidy to clean up old *.puppet files.
define cronfile ($content) {
file { "/etc/cron.d/${name}.puppet":
owner => "root",
group => "root",
mode => "0400",
content => $content,
}
exec { "update_${name}_timestamp":
command => '/bin/false',
unless => "/bin/touch /etc/cron.d/${name}.puppet",
require => File["/etc/cron.d/${name}.puppet"],
before => Tidy['/etc/cron.d'],
}
}
tidy { "/etc/cron.d":
age => "30m",
recurse => 1,
matches => ["*.puppet"],
}
cronfile { "demo":
content => "* * * * * * /bin/true",
}
Set the tidy age to something sane so it doesn't remove files you just
deployed (basically anything longer than a single puppet run), and
this won't remove any files that doesn't have *.puppet extension.
About the only thing to add is maybe ensure ntp timesync before you
start touching any files. If you use cronfile custom resource it will
deploy the cronjob in the right directory with appropriate extensions.
Thanks,
Nan
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.