Hi, I have a template file which I would like to append to an existing file (in this case I wish to add a few lines to /etc/motd). Unless I''ve missed it, it does not appear that file has an append option. Is there an easy way copy to the end of a file Thanks Paul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Paul Lathrop
2008-Nov-11 01:47 UTC
[Puppet Users] Re: Appending a file to an existing file
Paul, Besides "exec" there really isn''t. However, it seems odd to me that you wouldn''t just put those initial lines into your template. Why isn''t that a reasonable solution? --Paul On Mon, Nov 10, 2008 at 9:36 AM, paul matthews <paulsmatthews@googlemail.com> wrote:> > Hi, > > I have a template file which I would like to append to an existing > file (in this case I wish to add a few lines to /etc/motd). Unless > I''ve missed it, it does not appear that file has an append option. Is > there an easy way copy to the end of a file > > Thanks > Paul > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Subhasis Dasgupta
2008-Nov-11 07:04 UTC
[Puppet Users] Re: Appending a file to an existing file
http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText may be useful for you -Subhasis 2008/11/11 Paul Lathrop <paul@tertiusfamily.net>> > Paul, > > Besides "exec" there really isn''t. However, it seems odd to me that > you wouldn''t just put those initial lines into your template. Why > isn''t that a reasonable solution? > > --Paul > > On Mon, Nov 10, 2008 at 9:36 AM, paul matthews > <paulsmatthews@googlemail.com> wrote: > > > > Hi, > > > > I have a template file which I would like to append to an existing > > file (in this case I wish to add a few lines to /etc/motd). Unless > > I''ve missed it, it does not appear that file has an append option. Is > > there an easy way copy to the end of a file > > > > Thanks > > Paul > > > > > > > > > > >-- Subhasis Dasgupta --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
paul matthews
2008-Nov-11 10:41 UTC
[Puppet Users] Re: Appending a file to an existing file
Hi Paul, Thanks for the reply. Our set up here is slightly odd in that I need to run a security tool which creates motd and then the puppet part adds a few more lines with some extra variables. This is my first post to the group btw so thanks for the reply. Being relatively new to puppet it so far seems a great tool but does seem to be lacking a bit with file manipulation resources. I did have a look at augeas but it seemed overly complex for what I was trying to achieve. I''ll use ''exec'' as you suggested Thanks Paul 2008/11/11 Paul Lathrop <paul@tertiusfamily.net>> > Paul, > > Besides "exec" there really isn''t. However, it seems odd to me that > you wouldn''t just put those initial lines into your template. Why > isn''t that a reasonable solution? > > --Paul > > On Mon, Nov 10, 2008 at 9:36 AM, paul matthews > <paulsmatthews@googlemail.com> wrote: > > > > Hi, > > > > I have a template file which I would like to append to an existing > > file (in this case I wish to add a few lines to /etc/motd). Unless > > I''ve missed it, it does not appear that file has an append option. Is > > there an easy way copy to the end of a file > > > > Thanks > > Paul > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
paul matthews wrote:> Thanks for the reply. Our set up here is slightly odd in that I need to run > a security tool which creates motd and then the puppet part adds a few more > lines with some extra variables.Alternatively to exec, you could: 1) let the security tool fix the motd once 2) copy it to the puppetmaster and convert it into a template with your extra lines 3) change your puppet manifests to only deploy the new motd template if there''s evidence the security script has run. Something like: file { "/etc/motd": content => template("motd.erb"), onlyif => "test -f /path/to/evidence_log" } would be simple, integrating your security tool into your puppet manifests would be another way. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
paul matthews
2008-Nov-11 14:16 UTC
[Puppet Users] Re: Appending a file to an existing file
Hi Mike, I think I''ll try your option 2 as option 3 would mean over-writing the dynamic data in motd that the security tool has added Thanks for your help Rgds Paul 2008/11/11 Mike Renfro <renfro@tntech.edu>> > paul matthews wrote: > > > Thanks for the reply. Our set up here is slightly odd in that I need to > run > > a security tool which creates motd and then the puppet part adds a few > more > > lines with some extra variables. > > Alternatively to exec, you could: > > 1) let the security tool fix the motd once > > 2) copy it to the puppetmaster and convert it into a template with your > extra lines > > 3) change your puppet manifests to only deploy the new motd template if > there''s evidence the security script has run. Something like: > > file { "/etc/motd": > content => template("motd.erb"), > onlyif => "test -f /path/to/evidence_log" > } > > would be simple, integrating your security tool into your puppet > manifests would be another way. > > -- > Mike Renfro / R&D Engineer, Center for Manufacturing Research, > 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
paul matthews wrote:> I think I''ll try your option 2 as option 3 would mean over-writing the > dynamic data in motd that the security tool has addedThose were three steps for a single option. The template applied in step 3 would *be* the template you mark up in step 2, but would only get applied if and only if you found a particular log file or trace that indicated your security tool (JASS or whatever) had run. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > 1) let the security tool fix the motd once > > 2) copy it to the puppetmaster and convert it into a template with your > extra lines > > 3) change your puppet manifests to only deploy the new motd template if > there''s evidence the security script has run. Something like: > > file { "/etc/motd": > content => template("motd.erb"), > onlyif => "test -f /path/to/evidence_log" > } > > would be simple, integrating your security tool into your puppet > manifests would be another way. >I don''t believe this will work as the onlyif attribute is only available for the exec type. But something similiar using the generate function might work. file { "/etc/motd": content =>generate (<script that runs the security tool server side then cats on the extra lines>) , } Of course the security tool may not work as a server side run, but this might give you an idea to work with. Evan --~--~---------~--~----~------------~-------~--~----~ 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 11/12/2008 9:28 AM, Evan Hisey wrote:> I don''t believe this will work as the onlyif attribute is only > available for the exec type. But something similiar using the generate > function might work.Could have sworn I saw onlyif in the metaparameters list, but I obviously didn''t. So if you could integrate the security tool into puppet itself, then you could have: - a file entry that contains the extra lines for the motd - an exec entry that runs the security tool - an exec entry that looks for evidence the security tool has run, and then adds the extra lines onto the motd -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
paul matthews
2008-Nov-12 17:05 UTC
[Puppet Users] Re: Appending a file to an existing file
Mike, I''ll give that a go. Thanks very much for all your answers Cheers Paul 2008/11/12 Mike Renfro <renfro@tntech.edu>> > On 11/12/2008 9:28 AM, Evan Hisey wrote: > > > I don''t believe this will work as the onlyif attribute is only > > available for the exec type. But something similiar using the generate > > function might work. > > Could have sworn I saw onlyif in the metaparameters list, but I > obviously didn''t. So if you could integrate the security tool into > puppet itself, then you could have: > > - a file entry that contains the extra lines for the motd > > - an exec entry that runs the security tool > > - an exec entry that looks for evidence the security tool has run, and > then adds the extra lines onto the motd > > -- > Mike Renfro / R&D Engineer, Center for Manufacturing Research, > 931 372-3601 / Tennessee Technological University > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Paul Lathrop
2008-Nov-13 00:42 UTC
[Puppet Users] Re: Appending a file to an existing file
Hi Paul, In that case, use a template. Templates are just ERB, so you can run your security tool from within the template to get the header part of the file. --Paul On Tue, Nov 11, 2008 at 2:41 AM, paul matthews <paulsmatthews@googlemail.com> wrote:> Hi Paul, > > Thanks for the reply. Our set up here is slightly odd in that I need to run > a security tool which creates motd and then the puppet part adds a few more > lines with some extra variables. This is my first post to the group btw so > thanks for the reply. Being relatively new to puppet it so far seems a great > tool but does seem to be lacking a bit with file manipulation resources. I > did have a look at augeas but it seemed overly complex for what I was trying > to achieve. I''ll use ''exec'' as you suggested > > Thanks > Paul > > > > 2008/11/11 Paul Lathrop <paul@tertiusfamily.net> >> >> Paul, >> >> Besides "exec" there really isn''t. However, it seems odd to me that >> you wouldn''t just put those initial lines into your template. Why >> isn''t that a reasonable solution? >> >> --Paul >> >> On Mon, Nov 10, 2008 at 9:36 AM, paul matthews >> <paulsmatthews@googlemail.com> wrote: >> > >> > Hi, >> > >> > I have a template file which I would like to append to an existing >> > file (in this case I wish to add a few lines to /etc/motd). Unless >> > I''ve missed it, it does not appear that file has an append option. Is >> > there an easy way copy to the end of a file >> > >> > Thanks >> > Paul >> > >> > > >> > >> >> > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---