Hi, I need to add one line to /etc/securetty, say it needs to be ttyS1. Do not add it if ttyS1 already exists in file /etc/securetty. How to achieve this using puppet module in puppet 2.5? This file is different than the other examples using augeas, this one only has value per line, not name-val pair. Thanks, Hai -- 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.
hai wu <haiwu.us@gmail.com> writes:> Hi, I need to add one line to /etc/securetty, say it needs to be ttyS1. Do > not add it if ttyS1 already exists in file /etc/securetty.I strongly suggest you copy into place a file that contains exactly the content you want: editing files in place is an invitation to screw things up later, and for a security related file that can be terrible.> How to achieve this using puppet module in puppet 2.5? This file is > different than the other examples using augeas, this one only has value per > line, not name-val pair.You /could/ use an exec like this: exec { "/bin/echo ttyS1 >> /etc/securetty": unless "/bin/grep ttyS1 /etc/securetty" } I *really* don''t recommend that approach. Daniel -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons -- 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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> How to achieve this using puppet module in puppet 2.5? This file is > different than the other examples using augeas, this one only has value per > line, not name-val pair.you can find and example here: http://git.puppet.immerda.ch/?p=module-virtual.git;a=blob;f=manifests/xenu/centos.pp;h=e0015dce2ecda2074f4cdead0e12983bd1c8b2f6;hb=9fff47d82c3c5cf607b84c28f8ab371c17b46639 that also works on 0.25.x pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyEnygACgkQbwltcAfKi39VzACcCkln3QLpIi1v3LYT1fB9Rd2v pZMAniye/zkIJpz2iyopm/ElvfqVYAyK =b8NY -----END PGP SIGNATURE----- -- 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 Sep 6, 2010, at 3:41 AM, hai wu wrote:> Hi, I need to add one line to /etc/securetty, say it needs to be ttyS1. Do not add it if ttyS1 already exists in file /etc/securetty. > > How to achieve this using puppet module in puppet 2.5? This file is different than the other examples using augeas, this one only has value per line, not name-val pair.Which examples are you looking at? There''s a lengthy discussion of this very scenario in the Wiki. http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas#Paths+for+Numbered+Items -- Rob McBroom <http://www.skurfer.com/> -- 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.
This one is different from examples on that page, in that file /etc/securetty is not name value pair, it just has values in it. I used the following as the workaround: augeas { "securetty": context => "/files/etc/securetty", changes => [ "set *[.=''tty9''] ttyS1", ], onlyif => "match ttyS1 size == 0", } But I was not able to figure out how to just add one new line without changing existing line. Hai On Wed, Sep 8, 2010 at 9:08 AM, Rob McBroom <mailinglist0@skurfer.com>wrote:> On Sep 6, 2010, at 3:41 AM, hai wu wrote: > > > Hi, I need to add one line to /etc/securetty, say it needs to be ttyS1. > Do not add it if ttyS1 already exists in file /etc/securetty. > > > > How to achieve this using puppet module in puppet 2.5? This file is > different than the other examples using augeas, this one only has value per > line, not name-val pair. > > Which examples are you looking at? There''s a lengthy discussion of this > very scenario in the Wiki. > > > http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas#Paths+for+Numbered+Items > > -- > Rob McBroom > <http://www.skurfer.com/> > > -- > 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<puppet-users%2Bunsubscribe@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 Wed, Sep 8, 2010 at 7:39 AM, hai wu <haiwu.us@gmail.com> wrote:> This one is different from examples on that page, in that file > /etc/securetty is not name value pair, it just has values in it. I used the > following as the workaround: > > augeas { "securetty": > context => "/files/etc/securetty", > changes => [ > "set *[.=''tty9''] ttyS1", > ], > onlyif => "match ttyS1 size == 0", > } > >You can use combination of ins and set to inject at the beginning of the file since this file is not a key/value pair like most augeas managed files: augeas { "foo": context => "/files/etc/securetty", changes => [ "ins 0 before /files/etc/securetty/1", "set /files/etc/securetty/0 ttyS1", ], onlyif => "match *[.=''ttyS1''] size == 0", } 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.
On Sep 8, 2010, at 10:39 AM, hai wu wrote:> This one is different from examples on that page, in that file /etc/securetty is not name value pair, it just has values in itI don''t know what you mean. Most of the discussion on that page (and certainly the stuff in the "numbered items" section I referred to) deals with numbered items and not name/value pairs. Having said that, there appears to be a 4th category of numbered items that isn''t documented there that looks like this: 1 = value I would tell you to just set it with set /files/etc/securetty/*[. = ''ttyS1''] ttyS1 but that doesn''t appear to work for some reason. You may be stuck using last() (or ins) and onlyif. -- Rob McBroom <http://www.skurfer.com/> -- 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.