Paul Elliott
2010-Feb-22 16:23 UTC
[Puppet Users] Augeas type: Removing an entry from /etc/hosts
Hi all, I''m just starting to look at using Augeas with Puppet to manage some of our configuration files. I thought I would start with a simple task of removing an entry from the /etc/hosts file. I''m not finding it simple though! We have a number of hosts with entries in the /etc/hosts file like this: 127.0.1.1 hostname We would like to remove these lines. Now I know this can be done with a simple exec of sed but if possible I would like to use it as a good test exercise with Augeas. Now, it''s pretty easy to do this with augtool, as follows: root@miscreant:/home/pre500# augtool augtool> match /files/etc/hosts/*/ipaddr 127.0.1.1 /files/etc/hosts/4/ipaddr augtool> rm /files/etc/hosts/4 rm : /files/etc/hosts/4 3 augtool> save Saved 1 file(s) But I can''t see how this would translate to work in Puppet as I need to match the relevant path before I can issue the rm. Am I missing something obvious here? -- Paul Elliott, UNIX Systems Administrator Computing Service, University of York -- 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.
John Lyman
2010-Feb-22 16:46 UTC
[Puppet Users] Re: Augeas type: Removing an entry from /etc/hosts
> ... I know this can be done with a simple exec of sed but ...Or with the "host" native type. See http://docs.reductivelabs.com/references/stable/type.html#host -- 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 Elliott
2010-Feb-23 10:51 UTC
Re: [Puppet Users] Augeas type: Removing an entry from /etc/hosts
Hi David, On 22/02/10 19:25, David Lutterkort wrote:> You can do this by looking for the entries with a single path > expression: > augtool> match /files/etc/hosts/*[ipaddr = ''127.0.1.1''] > gives you all entries in /etc/hosts with that IP. To remove them, just > do ''rm'' instead of ''match''. From your post, I wasn''t sure if you had<snip>> [1] http://augeas.net/page/Path_expressionsPerfect, that''s just what I was looking for and it works like a charm. Thanks, Paul. -- Paul Elliott, UNIX Systems Administrator Computing Service, University of York -- 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.
Jesús Couto
2010-Feb-23 12:37 UTC
Re: [Puppet Users] Augeas type: Removing an entry from /etc/hosts
On a tangent, anybody using augeas under puppet to manage /etc/sudoers? ... and how? I was thinking about doing so to add/delete several commands to an administrator group as part of setting up an apache/tomcat/whatever instance, but cant figure out how to do it, for reasons similar to this example. And rm doesnt work for adding :-P -------------------------------------------------------- Jesús Couto F. -- 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.
Rob McBroom
2010-Feb-23 19:02 UTC
Re: [Puppet Users] Augeas type: Removing an entry from /etc/hosts
On Feb 23, 2010, at 7:37 AM, Jesús Couto wrote:> On a tangent, anybody using augeas under puppet to manage /etc/sudoers? ... and how?I tried, but all I could get it to do was add the entries to the end of `/etc/sudoers` over and over every 30 minutes. I gave up and made a define that calls some hacky execs. I’d love to hear there’s a way (in 0.24.8). -- 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.
David Lutterkort
2010-Feb-24 23:32 UTC
Re: [Puppet Users] Augeas type: Removing an entry from /etc/hosts
On Tue, 2010-02-23 at 14:02 -0500, Rob McBroom wrote:> On Feb 23, 2010, at 7:37 AM, Jesús Couto wrote: > > > On a tangent, anybody using augeas under puppet to > > manage /etc/sudoers? ... and how? > > I tried, but all I could get it to do was add the entries to the end > of `/etc/sudoers` over and over every 30 minutes. I gave up and made a > define that calls some hacky execs. > > I’d love to hear there’s a way (in 0.24.8).I''d wager that the problem was that you were missing an onlyif that would keep the changes from being applied when the entries are there already. David -- 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.
Rob McBroom
2010-Feb-26 13:24 UTC
Re: [Puppet Users] Augeas type: Removing an entry from /etc/hosts
On Feb 24, 2010, at 6:32 PM, David Lutterkort wrote:> On Tue, 2010-02-23 at 14:02 -0500, Rob McBroom wrote: >> I’d love to hear there’s a way (in 0.24.8). > > I''d wager that the problem was that you were missing an onlyif that > would keep the changes from being applied when the entries are there > already.I know that, and in theory you’re right. But bug #2141 has prevented so many of my `onlyif`s from working in 0.24.8 that I don’t even bother trying. I’m basically waiting until EPEL gets 0.25.x to really use Augeas. -- Rob McBroom <http://www.skurfer.com/> Because it screws up the order in which people normally read text. Original message:> Why is it bad to top-post your reply?-- 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.