Brian Dunbar
2012-Oct-01 19:05 UTC
[Puppet Users] Puppet cron job class stamps file with date-time. How?
New puppet user. I see that the cron class creates a cronjob with a date-time in the header, which is cool. # HEADER: This file was autogenerated at Mon Oct 01 11:43:25 -0500 2012 by puppet. # HEADER: While it can still be managed manually, it is definitely not recommended. 1. How does it do that? 2. I''d like to be able to edit the text, customize it. 3. More particularly, how can I put a date/time stamp in other managed files? I tried to do so with a template but that was not working out so well. Regards, ~brian -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ. 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.
Jo Rhett
2012-Oct-04 19:08 UTC
Re: [Puppet Users] Puppet cron job class stamps file with date-time. How?
I would also like to know this. I keep hacking the same text into our templates. If there is a tag we could put in a template to get this output I''d like to know it. On Oct 1, 2012, at 12:05 PM, Brian Dunbar wrote:> New puppet user. I see that the cron class creates a cronjob with a date-time in the header, which is cool. > > # HEADER: This file was autogenerated at Mon Oct 01 11:43:25 -0500 2012 by puppet. > # HEADER: While it can still be managed manually, it is definitely not recommended. > > 1. How does it do that? > 2. I''d like to be able to edit the text, customize it. > 3. More particularly, how can I put a date/time stamp in other managed files? > > I tried to do so with a template but that was not working out so well. > > Regards, > > ~brian > > > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ. > 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.-- Jo Rhett Net Consonance : net philanthropy to improve open source and internet projects. -- 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.
Stephen Gran
2012-Oct-04 19:17 UTC
Re: [Puppet Users] Puppet cron job class stamps file with date-time. How?
Hi, On Thu, 2012-10-04 at 12:08 -0700, Jo Rhett wrote:> I would also like to know this. I keep hacking the same text into our > templates. If there is a tag we could put in a template to get this > output I''d like to know it. >Templates can take more than one source of data, so a trivial way to do this is something like: define my_template( $fname, $template, $owner=root, $group=$::root_group, ... ) { file { $fname: content => template(''site/header.erb'', $template, ''site/footer.erb''), owner => $owner, group => $group ... } } See the templating docs. Cheers, -- Stephen Gran Senior Systems Integrator - guardian.co.uk Please consider the environment before printing this email. ------------------------------------------------------------------ Visit guardian.co.uk - newspaper of the year www.guardian.co.uk www.observer.co.uk www.guardiannews.com On your mobile, visit m.guardian.co.uk or download the Guardian iPhone app www.guardian.co.uk/iphone and iPad edition www.guardian.co.uk/iPad Save up to 37% by subscribing to the Guardian and Observer - choose the papers you want and get full digital access. Visit guardian.co.uk/subscribe --------------------------------------------------------------------- This e-mail and all attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender and delete the e-mail and all attachments immediately. Do not disclose the contents to another person. You may not use the information for any purpose, or store, or copy, it in any way. Guardian News & Media Limited is not liable for any computer viruses or other material transmitted with or as part of this e-mail. You should employ virus checking software. Guardian News & Media Limited A member of Guardian Media Group plc Registered Office PO Box 68164 Kings Place 90 York Way London N1P 2AP Registered in England Number 908396 -- 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.
Christopher Wood
2012-Oct-04 19:19 UTC
Re: [Puppet Users] Puppet cron job class stamps file with date-time. How?
In this case the text appears to be a hardcode in a couple of providers: $ grep -r managed\ manually `pwd` /usr/lib/ruby/1.8/puppet/provider/parsedfile.rb:# HEADER: by puppet. While it can still be managed manually, it /usr/lib/ruby/1.8/puppet/provider/cron/crontab.rb:# HEADER: While it can still be managed manually, it is definitely not recommended. But this sounds like a great string for an environment-wide variable (hiera lookup) that all your templates can use. On Thu, Oct 04, 2012 at 12:08:39PM -0700, Jo Rhett wrote:> I would also like to know this. I keep hacking the same text into our > templates. If there is a tag we could put in a template to get this output > I''d like to know it. > On Oct 1, 2012, at 12:05 PM, Brian Dunbar wrote: > > New puppet user. I see that the cron class creates a cronjob with a > date-time in the header, which is cool. > # HEADER: This file was autogenerated at Mon Oct 01 11:43:25 -0500 2012 > by puppet. > # HEADER: While it can still be managed manually, it is definitely not > recommended. > 1. How does it do that? > 2. I''d like to be able to edit the text, customize it. > 3. More particularly, how can I put a date/time stamp in other managed > files? > I tried to do so with a template but that was not working out so well. > Regards, > ~brian > -- > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > To view this discussion on the web visit > [1]https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ. > To post to this group, send email to [2]puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > [3]puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > [4]http://groups.google.com/group/puppet-users?hl=en. > > -- > Jo Rhett > Net Consonance : net philanthropy to improve open source and internet > projects. > > -- > 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. > > References > > Visible links > 1. https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ > 2. mailto:puppet-users@googlegroups.com > 3. mailto:puppet-users+unsubscribe@googlegroups.com > 4. 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.
Jo Rhett
2012-Oct-04 19:45 UTC
Re: [Puppet Users] Puppet cron job class stamps file with date-time. How?
On Oct 4, 2012, at 12:17 PM, Stephen Gran wrote:> Templates can take more than one source of data, so a trivial way to do this is something like: > > content => template(''site/header.erb'', $template, ''site/footer.erb''),You know, the inconsistency between source=> and content=> caught me here. I thought that listing multiple templates used the first one found, like source. But checking the docs shows that you are right: these would be concatenated. That said, it doesn''t solve the original question about how to include the date. If the template generated the date each time, the file would be different each time and be overwritten each time, which is probably not desirableable especially if a notify or subscribe caused a service to restart. -- Jo Rhett Net Consonance : net philanthropy to improve open source and internet projects. -- 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.
Jo Rhett
2012-Oct-04 19:46 UTC
Re: [Puppet Users] Puppet cron job class stamps file with date-time. How?
I''m not sure it''s that easy. The original question about how to include the date would cause some issues.. If the hiera lookup generated the date each time, the file would be different each time and be overwritten each time, which is probably not desirableable especially if a notify or subscribe caused a service to restart. On Oct 4, 2012, at 12:19 PM, Christopher Wood wrote:> In this case the text appears to be a hardcode in a couple of providers: > > $ grep -r managed\ manually `pwd` > /usr/lib/ruby/1.8/puppet/provider/parsedfile.rb:# HEADER: by puppet. While it can still be managed manually, it > /usr/lib/ruby/1.8/puppet/provider/cron/crontab.rb:# HEADER: While it can still be managed manually, it is definitely not recommended. > > But this sounds like a great string for an environment-wide variable (hiera lookup) that all your templates can use. > > On Thu, Oct 04, 2012 at 12:08:39PM -0700, Jo Rhett wrote: >> I would also like to know this. I keep hacking the same text into our >> templates. If there is a tag we could put in a template to get this output >> I''d like to know it. >> On Oct 1, 2012, at 12:05 PM, Brian Dunbar wrote: >> >> New puppet user. I see that the cron class creates a cronjob with a >> date-time in the header, which is cool. >> # HEADER: This file was autogenerated at Mon Oct 01 11:43:25 -0500 2012 >> by puppet. >> # HEADER: While it can still be managed manually, it is definitely not >> recommended. >> 1. How does it do that? >> 2. I''d like to be able to edit the text, customize it. >> 3. More particularly, how can I put a date/time stamp in other managed >> files? >> I tried to do so with a template but that was not working out so well. >> Regards, >> ~brian >> -- >> You received this message because you are subscribed to the Google >> Groups "Puppet Users" group. >> To view this discussion on the web visit >> [1]https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ. >> To post to this group, send email to [2]puppet-users@googlegroups.com. >> To unsubscribe from this group, send email to >> [3]puppet-users+unsubscribe@googlegroups.com. >> For more options, visit this group at >> [4]http://groups.google.com/group/puppet-users?hl=en. >> >> -- >> Jo Rhett >> Net Consonance : net philanthropy to improve open source and internet >> projects. >> >> -- >> 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. >> >> References >> >> Visible links >> 1. https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ >> 2. mailto:puppet-users@googlegroups.com >> 3. mailto:puppet-users+unsubscribe@googlegroups.com >> 4. 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. >-- Jo Rhett Net Consonance : net philanthropy to improve open source and internet projects. -- 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.
Christopher Wood
2012-Oct-04 19:56 UTC
Re: [Puppet Users] Puppet cron job class stamps file with date-time. How?
You may as well port the code from the cron provider into your environment. For the generic string I was thinking of something as simple as "Don''t touch this file." On Thu, Oct 04, 2012 at 12:46:09PM -0700, Jo Rhett wrote:> I''m not sure it''s that easy. The original question about how to include > the date would cause some issues.. If the hiera lookup generated the date > each time, the file would be different each time and be overwritten each > time, which is probably not desirableable especially if a notify or > subscribe caused a service to restart. > On Oct 4, 2012, at 12:19 PM, Christopher Wood wrote: > > In this case the text appears to be a hardcode in a couple of providers: > > $ grep -r managed\ manually `pwd` > /usr/lib/ruby/1.8/puppet/provider/parsedfile.rb:# HEADER: by puppet. > While it can still be managed manually, it > /usr/lib/ruby/1.8/puppet/provider/cron/crontab.rb:# HEADER: While it can > still be managed manually, it is definitely not recommended. > > But this sounds like a great string for an environment-wide variable > (hiera lookup) that all your templates can use. > > On Thu, Oct 04, 2012 at 12:08:39PM -0700, Jo Rhett wrote: > > I would also like to know this. I keep hacking the same text into > our > > templates. If there is a tag we could put in a template to get this > output > > I''d like to know it. > > On Oct 1, 2012, at 12:05 PM, Brian Dunbar wrote: > > New puppet user. I see that the cron class creates a cronjob with > a > > date-time in the header, which is cool. > > # HEADER: This file was autogenerated at Mon Oct 01 11:43:25 -0500 > 2012 > > by puppet. > > # HEADER: While it can still be managed manually, it is definitely > not > > recommended. > > 1. How does it do that? > > 2. I''d like to be able to edit the text, customize it. > > 3. More particularly, how can I put a date/time stamp in other > managed > > files? > > I tried to do so with a template but that was not working out so > well. > > Regards, > > ~brian > > -- > > You received this message because you are subscribed to the Google > > Groups "Puppet Users" group. > > To view this discussion on the web visit > > [1][1]https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ. > > To post to this group, send email to > [2][2]puppet-users@googlegroups.com. > > To unsubscribe from this group, send email to > > [3][3]puppet-users+unsubscribe@googlegroups.com. > > For more options, visit this group at > > [4][4]http://groups.google.com/group/puppet-users?hl=en. > > -- > > Jo Rhett > > Net Consonance : net philanthropy to improve open source and > internet > > projects. > > -- > > You received this message because you are subscribed to the Google > Groups > > "Puppet Users" group. > > To post to this group, send email to > [5]puppet-users@googlegroups.com. > > To unsubscribe from this group, send email to > > [6]puppet-users+unsubscribe@googlegroups.com. > > For more options, visit this group at > > [7]http://groups.google.com/group/puppet-users?hl=en. > > References > > Visible links > > 1. [8]https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ > > 2. [9]mailto:puppet-users@googlegroups.com > > 3. [10]mailto:puppet-users+unsubscribe@googlegroups.com > > 4. [11]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 [12]puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > [13]puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > [14]http://groups.google.com/group/puppet-users?hl=en. > > -- > Jo Rhett > Net Consonance : net philanthropy to improve open source and internet > projects. > > -- > 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. > > References > > Visible links > 1. https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ > 2. mailto:puppet-users@googlegroups.com > 3. mailto:puppet-users+unsubscribe@googlegroups.com > 4. http://groups.google.com/group/puppet-users?hl=en > 5. mailto:puppet-users@googlegroups.com > 6. mailto:puppet-users+unsubscribe@googlegroups.com > 7. http://groups.google.com/group/puppet-users?hl=en > 8. https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ > 9. mailto:puppet-users@googlegroups.com > 10. mailto:puppet-users+unsubscribe@googlegroups.com > 11. http://groups.google.com/group/puppet-users?hl=en > 12. mailto:puppet-users@googlegroups.com > 13. mailto:puppet-users+unsubscribe@googlegroups.com > 14. 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.
Stefan Schulte
2012-Oct-04 21:39 UTC
Re: [Puppet Users] Puppet cron job class stamps file with date-time. How?
In case of the cron type it is easy for puppet to savely add a header because puppet knows the purpose of a cronfile and knows that # is treated as a comment. If you use the filetype puppet does not know what your file is for. If you ship a *.tar.gz file you certainly don''t want puppet to put a header in front of it. So to add a static header puppet has to know what kind of file you are shipping and if adding a header is safe. In my opinion this is rather complicated, e.g. a shellscript is a textfile but #!/bin/sh has to remain the first line, so puppet now has to add the header after line 1. Adding a date is a bit complicated because puppet has to strip the header from the source and target file before calculating any checksums, otherwise puppet would always treat the target out of sync. While you may be able to implement that I never thought that the date in the file was of any help. I''d just look at the mtime. This can change because of two reasons: a) puppet changed the file because the source file on the server changed. Now mtime is the time you want to have in the header b) some user changed the targetfile. This should not last long because puppet will reset the file soon and I have case a) again -Stefan On Thu, Oct 04, 2012 at 03:56:06PM -0400, Christopher Wood wrote:> You may as well port the code from the cron provider into your environment. > > For the generic string I was thinking of something as simple as "Don''t touch this file." > > On Thu, Oct 04, 2012 at 12:46:09PM -0700, Jo Rhett wrote: > > I''m not sure it''s that easy. The original question about how to include > > the date would cause some issues.. If the hiera lookup generated the date > > each time, the file would be different each time and be overwritten each > > time, which is probably not desirableable especially if a notify or > > subscribe caused a service to restart. > > On Oct 4, 2012, at 12:19 PM, Christopher Wood wrote: > > > > In this case the text appears to be a hardcode in a couple of providers: > > > > $ grep -r managed\ manually `pwd` > > /usr/lib/ruby/1.8/puppet/provider/parsedfile.rb:# HEADER: by puppet. > > While it can still be managed manually, it > > /usr/lib/ruby/1.8/puppet/provider/cron/crontab.rb:# HEADER: While it can > > still be managed manually, it is definitely not recommended. > > > > But this sounds like a great string for an environment-wide variable > > (hiera lookup) that all your templates can use. > > > > On Thu, Oct 04, 2012 at 12:08:39PM -0700, Jo Rhett wrote: > > > > I would also like to know this. I keep hacking the same text into > > our > > > > templates. If there is a tag we could put in a template to get this > > output > > > > I''d like to know it. > > > > On Oct 1, 2012, at 12:05 PM, Brian Dunbar wrote: > > > > New puppet user. I see that the cron class creates a cronjob with > > a > > > > date-time in the header, which is cool. > > > > # HEADER: This file was autogenerated at Mon Oct 01 11:43:25 -0500 > > 2012 > > > > by puppet. > > > > # HEADER: While it can still be managed manually, it is definitely > > not > > > > recommended. > > > > 1. How does it do that? > > > > 2. I''d like to be able to edit the text, customize it. > > > > 3. More particularly, how can I put a date/time stamp in other > > managed > > > > files? > > > > I tried to do so with a template but that was not working out so > > well. > > > > Regards, > > > > ~brian > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "Puppet Users" group. > > > > To view this discussion on the web visit > > > > [1][1]https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ. > > > > To post to this group, send email to > > [2][2]puppet-users@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > > [3][3]puppet-users+unsubscribe@googlegroups.com. > > > > For more options, visit this group at > > > > [4][4]http://groups.google.com/group/puppet-users?hl=en. > > > > -- > > > > Jo Rhett > > > > Net Consonance : net philanthropy to improve open source and > > internet > > > > projects. > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups > > > > "Puppet Users" group. > > > > To post to this group, send email to > > [5]puppet-users@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > > [6]puppet-users+unsubscribe@googlegroups.com. > > > > For more options, visit this group at > > > > [7]http://groups.google.com/group/puppet-users?hl=en. > > > > References > > > > Visible links > > > > 1. [8]https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ > > > > 2. [9]mailto:puppet-users@googlegroups.com > > > > 3. [10]mailto:puppet-users+unsubscribe@googlegroups.com > > > > 4. [11]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 [12]puppet-users@googlegroups.com. > > To unsubscribe from this group, send email to > > [13]puppet-users+unsubscribe@googlegroups.com. > > For more options, visit this group at > > [14]http://groups.google.com/group/puppet-users?hl=en. > > > > -- > > Jo Rhett > > Net Consonance : net philanthropy to improve open source and internet > > projects. > > > > -- > > 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. > > > > References > > > > Visible links > > 1. https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ > > 2. mailto:puppet-users@googlegroups.com > > 3. mailto:puppet-users+unsubscribe@googlegroups.com > > 4. http://groups.google.com/group/puppet-users?hl=en > > 5. mailto:puppet-users@googlegroups.com > > 6. mailto:puppet-users+unsubscribe@googlegroups.com > > 7. http://groups.google.com/group/puppet-users?hl=en > > 8. https://groups.google.com/d/msg/puppet-users/-/Wsckx5euwRgJ > > 9. mailto:puppet-users@googlegroups.com > > 10. mailto:puppet-users+unsubscribe@googlegroups.com > > 11. http://groups.google.com/group/puppet-users?hl=en > > 12. mailto:puppet-users@googlegroups.com > > 13. mailto:puppet-users+unsubscribe@googlegroups.com > > 14. 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. >-- 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.