Andrew Pollock
2010-Oct-06 18:31 UTC
[Puppet Users] Using Augeas to manage /etc/network/interfaces from Puppet
Hi, Sorry for the broad distribution, I''m not sure who best can help me. I''m trying to add a new interface stanza to /etc/network/interfaces. With augtool, I can accomplish this with the following: set /files/etc/network/interfaces/iface[last()+1] bond1 set /files/etc/network/interfaces/iface[last()]/family inet set /files/etc/network/interfaces/iface[last()]/method dhcp set /files/etc/network/interfaces/iface[last()]/slaves eth2 I''ve been able to translate that to the following Puppet resource: augeas { "bond1": context => "/files/etc/network/interfaces", changes => [ "set iface[last()+1] bond1", "set iface[last()]/family inet", "set iface[last()]/method dhcp", "set iface[last()]/slaves eth2", ], } All good so far, except this will unconditionally create the interface stanza every time Puppet runs. That''s fine, this is what the "onlyif" directive is for, right? I just can''t make it work. I''m a bit hazy on how "match" works. From augtool, I can go match /files/etc/network/interfaces/iface[*] and sort of get back a list of interface names. I was thinking that maybe I could do something with that, but I''m not entirely sure what. I hear there''s some user-contributed Augeas examples in a Puppet wiki somewhere, but I haven''t been able to find them. Any pointers appreciated. regards Andrew -- 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-Oct-06 19:22 UTC
Re: [Puppet Users] Using Augeas to manage /etc/network/interfaces from Puppet
On Oct 6, 2010, at 2:31 PM, Andrew Pollock wrote:> I hear there''s some user-contributed Augeas examples in a Puppet wiki somewhere, but I haven''t been able to find them. Any pointers appreciated.There is (and even I have a hard time finding it). http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas You can usually avoid the ugly mess of using last() and onlyif, as shown in the wiki. -- 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.
Andrew Pollock
2010-Oct-06 22:46 UTC
[Puppet Users] Re: Using Augeas to manage /etc/network/interfaces from Puppet
On Oct 6, 12:22 pm, Rob McBroom <mailingli...@skurfer.com> wrote:> On Oct 6, 2010, at 2:31 PM, Andrew Pollock wrote: > > > I hear there''s some user-contributed Augeas examples in a Puppet wiki somewhere, but I haven''t been able to find them. Any pointers appreciated. > > There is (and even I have a hard time finding it). > > http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas > > You can usually avoid the ugly mess of using last() and onlyif, as shown in the wiki.Fabulous, thank you! For the record, I''m using augeas { "bond1": context => "/files/etc/network/interfaces", changes => [ "set iface[. = ''bond1''] bond1", "set iface[. = ''bond1'']/family inet", "set iface[. = ''bond1'']/method dhcp", "set iface[. = ''bond1'']/slaves eth2", ], } which appears to be working as desired. -- 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.
Ryan Y. Coleman
2010-Oct-06 23:06 UTC
Re: [Puppet Users] Using Augeas to manage /etc/network/interfaces from Puppet
Also see this blog post: http://www.puppetlabs.com/blog/puppets-google-summer-of-code/ which discusses this possibly useful module: http://github.com/blkperl/puppet-network ----- Original Message -----> From: "Andrew Pollock" <apollock@google.com> > To: augeas-devel@redhat.com, puppet-users@googlegroups.com > Cc: "Bryan Kearney" <bkearney@redhat.com>, "Free Ekanayaka" <free@64studio.com> > Sent: Wednesday, October 6, 2010 2:31:07 PM > Subject: [Puppet Users] Using Augeas to manage /etc/network/interfaces from Puppet > Hi, > > > Sorry for the broad distribution, I''m not sure who best can help me. > > > I''m trying to add a new interface stanza to /etc/network/interfaces. > > > With augtool, I can accomplish this with the following: > > > > set /files/etc/network/interfaces/iface[last()+1] bond1 > set /files/etc/network/interfaces/iface[last()]/family inet > set /files/etc/network/interfaces/iface[last()]/method dhcp > set /files/etc/network/interfaces/iface[last()]/slaves eth2 > > > I''ve been able to translate that to the following Puppet resource: > > > > augeas { "bond1": > context => "/files/etc/network/interfaces", > changes => [ > "set iface[last()+1] bond1", > "set iface[last()]/family inet", > "set iface[last()]/method dhcp", > "set iface[last()]/slaves eth2", > ], > } > > > All good so far, except this will unconditionally create the interface > stanza every time Puppet runs. That''s fine, this is what the "onlyif" > directive is for, right? I just can''t make it work. > > > I''m a bit hazy on how "match" works. From augtool, I can go > > > match /files/etc/network/interfaces/iface[*] > > > and sort of get back a list of interface names. I was thinking that > maybe I could do something with that, but I''m not entirely sure what. > > > I hear there''s some user-contributed Augeas examples in a Puppet wiki > somewhere, but I haven''t been able to find them. Any pointers > appreciated. > > > regards > > > Andrew > > -- > 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.