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? thanks -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thu, Jul 7, 2011 at 9:43 AM, romuald FREBAULT <kurgan231@gmail.com> 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 puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
thank you very much, i''m gonna try this and tell you 2011/7/7 Nan Liu <nan@puppetlabs.com>> On Thu, Jul 7, 2011 at 9:43 AM, romuald FREBAULT <kurgan231@gmail.com> > 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 puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/07/2011 12:43 PM, romuald FREBAULT wrote:> > has anyone an idea of how i could have managed files removed on > destnation when removed from source without using the entierely purge > function?What you want is a /etc/cron.puppet.d and a way to link files there into /etc/cron.d (cron supports symlinks). And you want the symlinks to track the contents of the directory. That way you can use purge. You could write a script that runs on the client that does that. Run it from cron, or trigger with puppet. Something like: $ cat track-with-links #! /bin/bash m=master # master directory s=slave # slave directory for f in $( ls $s ) do [ ! -e $s/$f ] && echo removing $s/$f && rm -f $s/$f done for f in $( ls $m ) do [ ! -e $s/$f ] && echo adding $s/$f && ln -fs ../$m/$f $s/$f done here is a test session: vagn@nika:~/tmp$ ls master/ slave/ master/: baz slave/: baz vagn@nika:~/tmp$ touch master/foo ; rm master/baz vagn@nika:~/tmp$ ./track-with-links ; ls master/ slave/ removing slave/baz adding slave/foo master/: foo slave/: foo vagn@nika:~/tmp$ -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.