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+unsubscr...@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+unsubscr...@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+unsubscr...@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+unsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com
> >    4. http://groups.google.com/group/puppet-users?hl=en
> >    5. mailto:puppet-users@googlegroups.com
> >    6. mailto:puppet-users+unsubscr...@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+unsubscr...@googlegroups.com
> >   11. http://groups.google.com/group/puppet-users?hl=en
> >   12. mailto:puppet-users@googlegroups.com
> >   13. mailto:puppet-users+unsubscr...@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to