I''m in a bit of a pickle and I can''t work out a safe way to do something. I currently have a define called ip that I use to define network interfaces. The built in method didn''t seem to work, so I designed this to write out the /etc/sysconfig/network-scripts/ifcfg- ethX file. However, I started thinking about what if I decide to define an eth0:0 for some purpose, and later wish to remove it. How could I write a tidy file stanza that would delete ifcfg-ethX, but skip over ones I had defined previously? My only other thought was to find a way to build all the ifcfg-eth files in one location and then delete the existing ones and move the newly generated ones into place. I''d have to stop using a define, because I''d only want to run the delete/move once at the end of all the generation. Can anyone suggest a method? --~--~---------~--~----~------------~-------~--~----~ 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 Otto
2008-Mar-19 16:41 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
Ha, I don''t have a solution to your problem, but I can''t get the interface resource to work for me either. Could you provide your define? Thanks! -Andrew Otto On Mar 19, 2008, at 10:59 PM, Ashley Penney wrote:> > I''m in a bit of a pickle and I can''t work out a safe way to do > something. I currently have a define called ip that I use to define > network interfaces. The built in method didn''t seem to work, so I > designed this to write out the /etc/sysconfig/network-scripts/ifcfg- > ethX file. > > However, I started thinking about what if I decide to define an eth0:0 > for some purpose, and later wish to remove it. How could I write a > tidy file stanza that would delete ifcfg-ethX, but skip over ones I > had defined previously? > > My only other thought was to find a way to build all the ifcfg-eth > files in one location and then delete the existing ones and move the > newly generated ones into place. I''d have to stop using a define, > because I''d only want to run the delete/move once at the end of all > the generation. Can anyone suggest a method? > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ashley Penney
2008-Mar-19 16:46 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
Sure, I have this as a module, so I have the files: network/manifests/init.pp network/manifests/service.pp It''s still kind of a work in progess, I am going to add a case statement to check for $enabled and use ensure => absent if it''s disabled. In addition I have to wrapper the service.pp part with a redhat check as well! -------- init.pp ## Setup static IP configuration for RHEL5 ## class network { include network::service } ## ## Define a network interface. ## define network::ip($ip, $netmask, $network = '''', $broadcast = '''', $gateway ='''', $onboot = ''yes'', $hostname = '''', $enabled = ''yes'') { $device = $name case $operatingsystem { RedHat: { file { "ifcfg-$device": path => "/etc/sysconfig/network-scripts/ifcfg-$device", owner => root, group => root, mode => 644, content => template("network/ifcfg.erb"), notify => Service[network], } if $gateway { file { "network": path => "/etc/sysconfig/network", owner => root, group => root, mode => 644, content => template("network/network.erb"), notify => Service[network], } } } } } ------- service.pp ## ## network::service ## class network::service { service { network: ensure => "running", hasrestart => "true", restart => "/etc/init.d/network restart", } } On Wed, Mar 19, 2008 at 12:41 PM, Andrew Otto <acotto@gmail.com> wrote:> > Ha, I don''t have a solution to your problem, but I can''t get the > interface resource to work for me either. Could you provide your > define? > > Thanks! > > -Andrew Otto > > > On Mar 19, 2008, at 10:59 PM, Ashley Penney wrote: > > > > > I''m in a bit of a pickle and I can''t work out a safe way to do > > something. I currently have a define called ip that I use to define > > network interfaces. The built in method didn''t seem to work, so I > > designed this to write out the /etc/sysconfig/network-scripts/ifcfg- > > ethX file. > > > > However, I started thinking about what if I decide to define an eth0:0 > > for some purpose, and later wish to remove it. How could I write a > > tidy file stanza that would delete ifcfg-ethX, but skip over ones I > > had defined previously? > > > > My only other thought was to find a way to build all the ifcfg-eth > > files in one location and then delete the existing ones and move the > > newly generated ones into place. I''d have to stop using a define, > > because I''d only want to run the delete/move once at the end of all > > the generation. Can anyone suggest a method? > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Otto
2008-Mar-19 17:01 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
Oo, nice, thank you. Do you think you could include your network/ifcfg.erb file as well? Thanks so much! -Andrew On Mar 19, 2008, at 11:46 PM, Ashley Penney wrote:> Sure, I have this as a module, so I have the files: > > network/manifests/init.pp > network/manifests/service.pp > > It''s still kind of a work in progess, I am going to add a case > statement to check for $enabled and use ensure => absent if it''s > disabled. In addition I have to wrapper the service.pp part with a > redhat check as well! > > -------- init.pp > ## Setup static IP configuration for RHEL5 > ## > > class network { > include network::service > } > > ## > ## Define a network interface. > ## > > define network::ip($ip, $netmask, $network = '''', $broadcast = '''', > $gateway ='''', $onboot = ''yes'', $hostname = '''', $enabled = ''yes'') { > $device = $name > > case $operatingsystem { > RedHat: { > file { "ifcfg-$device": > path => "/etc/sysconfig/network-scripts/ifcfg-$device", > owner => root, > group => root, > mode => 644, > content => template("network/ifcfg.erb"), > notify => Service[network], > } > > if $gateway { > file { "network": > path => "/etc/sysconfig/network", > owner => root, > group => root, > mode => 644, > content => template("network/network.erb"), > notify => Service[network], > } > } > > } > } > } > > ------- service.pp > > ## > ## network::service > ## > > class network::service { > service { network: > ensure => "running", > hasrestart => "true", > restart => "/etc/init.d/network restart", > } > } > > > > On Wed, Mar 19, 2008 at 12:41 PM, Andrew Otto <acotto@gmail.com> > wrote: > > Ha, I don''t have a solution to your problem, but I can''t get the > interface resource to work for me either. Could you provide your > define? > > Thanks! > > -Andrew Otto > > > On Mar 19, 2008, at 10:59 PM, Ashley Penney wrote: > > > > > I''m in a bit of a pickle and I can''t work out a safe way to do > > something. I currently have a define called ip that I use to define > > network interfaces. The built in method didn''t seem to work, so I > > designed this to write out the /etc/sysconfig/network-scripts/ifcfg- > > ethX file. > > > > However, I started thinking about what if I decide to define an > eth0:0 > > for some purpose, and later wish to remove it. How could I write a > > tidy file stanza that would delete ifcfg-ethX, but skip over ones I > > had defined previously? > > > > My only other thought was to find a way to build all the ifcfg-eth > > files in one location and then delete the existing ones and move the > > newly generated ones into place. I''d have to stop using a define, > > because I''d only want to run the delete/move once at the end of all > > the generation. Can anyone suggest a method? > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ashley Penney
2008-Mar-19 17:15 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
Oh, of course, I actually just changed the define so that if you call it with enable set to no, it''ll delete the ifcfg-ethX file so you don''t end up with a mess! # ## Define a network interface. ## define network::ip($ip, $netmask, $network = '''', $broadcast = '''', $gateway ='''', $onboot = ''yes'', $hostname = '''', $enabled = ''yes'') { $device = $name case $operatingsystem { RedHat: { case $enabled { ''yes'': { file { "ifcfg-$device": path => "/etc/sysconfig/network-scripts/ifcfg-$device", owner => root, group => root, mode => 644, content => template("network/ifcfg.erb"), ensure => present, notify => Service[network], } } ''no'': { file { "ifcfg-$device": path => "/etc/sysconfig/network-scripts/ifcfg-$device", ensure => absent, notify => Service[network], } } } if $gateway { file { "network": path => "/etc/sysconfig/network", owner => root, group => root, mode => 644, content => template("network/network.erb"), notify => Service[network], } } } } } ----- template [root@hlstestrhel01 manifests]# cat ../templates/ifcfg.erb DEVICE=<%= device %> BOOTPROTO=static BROADCAST=<%= broadcast %> IPADDR=<%= ip %> NETMASK=<%= netmask %> NETWORK=<%= network %> ONBOOT=yes TYPE=Ethernet On Wed, Mar 19, 2008 at 1:01 PM, Andrew Otto <acotto@gmail.com> wrote:> Oo, nice, thank you. > Do you think you could include your network/ifcfg.erb file as well? > > Thanks so much! > > -Andrew > > On Mar 19, 2008, at 11:46 PM, Ashley Penney wrote: > > Sure, I have this as a module, so I have the files: > network/manifests/init.pp > network/manifests/service.pp > > It''s still kind of a work in progess, I am going to add a case statement > to check for $enabled and use ensure => absent if it''s disabled. In > addition I have to wrapper the service.pp part with a redhat check as > well! > > -------- init.pp > ## Setup static IP configuration for RHEL5 > ## > > class network { > include network::service > } > > ## > ## Define a network interface. > ## > > define network::ip($ip, $netmask, $network = '''', $broadcast = '''', $gateway > ='''', $onboot = ''yes'', $hostname = '''', $enabled = ''yes'') { > $device = $name > > case $operatingsystem { > RedHat: { > file { "ifcfg-$device": > path => "/etc/sysconfig/network-scripts/ifcfg-$device", > owner => root, > group => root, > mode => 644, > content => template("network/ifcfg.erb"), > notify => Service[network], > } > if $gateway { > file { "network": > path => "/etc/sysconfig/network", > owner => root, > group => root, > mode => 644, > content => template("network/network.erb"), > notify => Service[network], > } > } > > } > } > } > > ------- service.pp > > ## > ## network::service > ## > > class network::service { > service { network: > ensure => "running", > hasrestart => "true", > restart => "/etc/init.d/network restart", > } > } > > > > On Wed, Mar 19, 2008 at 12:41 PM, Andrew Otto <acotto@gmail.com> wrote: > > > > > Ha, I don''t have a solution to your problem, but I can''t get the > > interface resource to work for me either. Could you provide your > > define? > > > > Thanks! > > > > -Andrew Otto > > > > > > On Mar 19, 2008, at 10:59 PM, Ashley Penney wrote: > > > > > > > > I''m in a bit of a pickle and I can''t work out a safe way to do > > > something. I currently have a define called ip that I use to define > > > network interfaces. The built in method didn''t seem to work, so I > > > designed this to write out the /etc/sysconfig/network-scripts/ifcfg- > > > ethX file. > > > > > > However, I started thinking about what if I decide to define an eth0:0 > > > for some purpose, and later wish to remove it. How could I write a > > > tidy file stanza that would delete ifcfg-ethX, but skip over ones I > > > had defined previously? > > > > > > My only other thought was to find a way to build all the ifcfg-eth > > > files in one location and then delete the existing ones and move the > > > newly generated ones into place. I''d have to stop using a define, > > > because I''d only want to run the delete/move once at the end of all > > > the generation. Can anyone suggest a method? > > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jtimberman
2008-Mar-20 19:23 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
On Mar 19, 10:41 am, Andrew Otto <aco...@gmail.com> wrote:> Ha, I don''t have a solution to your problem, but I can''t get the > interface resource to work for me either. Could you provide your > define?Hello Andrew. I also found the built in interface type to be insufficient, and I wrote my own. This was primarily to address some additional interface "types" we need - bonded interfaces, openbsd trunks and "up" interfaces that do not have an IP address. Unfortunately I can''t yet release the configuration we''re using, but once I have permission I plan to release the entire network module on the recipes page, which contains defined types and templates for CentOS / Red Hat and OpenBSD. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2008-Mar-20 19:24 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
On Mar 20, 2008, at 2:23 PM, jtimberman wrote:> I also found the built in interface type to be insufficient, and I > wrote my own. This was primarily to address some additional interface > "types" we need - bonded interfaces, openbsd trunks and "up" > interfaces that do not have an IP address. Unfortunately I can''t yet > release the configuration we''re using, but once I have permission I > plan to release the entire network module on the recipes page, which > contains defined types and templates for CentOS / Red Hat and OpenBSD.I don''t suppose any of you are interested in spending this development time fixing the built-in interface type, rather than creating new ones? Or even just replacing it with one all your own, I don''t really care. I just see a lot of people spending development effort replacing, rather than fixing, which seems wasteful. -- Humphrey''s Law of the Efficacy of Prayer: In a dangerous world there will always be more people around whose prayers for their own safety have been answered than those whose prayers have not. --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.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 -~----------~----~----~----~------~----~------~--~---
Ashley Penney
2008-Mar-21 16:04 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
I felt bad about our duplication of effort, so I started trying to get into resolving this, and I''ve made http://reductivelabs.com/trac/puppet/ticket/1152 to track the (limited) work I''ve done. What''s left is to figure out why name= is suddenly broken, and then perhaps extend the redhat.rb to build the other variables into the template file (I did this locally but it''s only two lines so I didn''t diff yet). On Thu, Mar 20, 2008 at 3:24 PM, Luke Kanies <luke@madstop.com> wrote:> > On Mar 20, 2008, at 2:23 PM, jtimberman wrote: > > > I also found the built in interface type to be insufficient, and I > > wrote my own. This was primarily to address some additional interface > > "types" we need - bonded interfaces, openbsd trunks and "up" > > interfaces that do not have an IP address. Unfortunately I can''t yet > > release the configuration we''re using, but once I have permission I > > plan to release the entire network module on the recipes page, which > > contains defined types and templates for CentOS / Red Hat and OpenBSD. > > > I don''t suppose any of you are interested in spending this development > time fixing the built-in interface type, rather than creating new > ones? Or even just replacing it with one all your own, I don''t really > care. > > I just see a lot of people spending development effort replacing, > rather than fixing, which seems wasteful. > > -- > Humphrey''s Law of the Efficacy of Prayer: > In a dangerous world there will always be more people around whose > prayers for their own safety have been answered than those whose > prayers have not. > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.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 -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2008-Mar-21 16:05 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
On Mar 21, 2008, at 11:04 AM, Ashley Penney wrote:> I felt bad about our duplication of effort, so I started trying to > get into resolving this, and I''ve made http://reductivelabs.com/trac/puppet/ticket/1152 > to track the (limited) work I''ve done. What''s left is to figure > out why name= is suddenly broken, and then perhaps extend the > redhat.rb to build the other variables into the template file (I did > this locally but it''s only two lines so I didn''t diff yet).Great; I''ll try to take a look at this over the weekend. See how nicely I respond to efforts to help fix the problems? :) -- What happens to the hole when the cheese is gone? -- Bertolt Brecht --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.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 -~----------~----~----~----~------~----~------~--~---
Ashley Penney
2008-Mar-21 16:17 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
I''m going to pick up a Ruby book this weekend (if I can) and start trying to get to grips with the syntax so that I can fix and extend the redhat.rb as well, (as well as any other redhat specific providers). You might even make a ruby convert out making me help myself! On Fri, Mar 21, 2008 at 12:05 PM, Luke Kanies <luke@madstop.com> wrote:> > On Mar 21, 2008, at 11:04 AM, Ashley Penney wrote: > > > I felt bad about our duplication of effort, so I started trying to > > get into resolving this, and I''ve made > http://reductivelabs.com/trac/puppet/ticket/1152 > > to track the (limited) work I''ve done. What''s left is to figure > > out why name= is suddenly broken, and then perhaps extend the > > redhat.rb to build the other variables into the template file (I did > > this locally but it''s only two lines so I didn''t diff yet). > > > Great; I''ll try to take a look at this over the weekend. See how > nicely I respond to efforts to help fix the problems? :) > > -- > What happens to the hole when the cheese is gone? -- Bertolt Brecht > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.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 -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2008-Mar-21 16:48 UTC
[Puppet Users] Re: Network interfaces (and deleting them)
On Mar 21, 2008, at 11:17 AM, Ashley Penney wrote:> I''m going to pick up a Ruby book this weekend (if I can) and start > trying to get to grips with the syntax so that I can fix and extend > the redhat.rb as well, (as well as any other redhat specific > providers). You might even make a ruby convert out making me help > myself!Welcome aboard. :) I''ve heard "The Ruby Way" is a great book to learn with (as opposed to just a reference, which is mostly what Programming Ruby is good for). I can also say that I''ve possibly been a bit lax in documenting the internals, mostly because of a lack of demand. As people want more of it, I''ll provide more (or, as I''ve been doing with James Turnbull recently, I''ll describe and someone else can document). -- Criminal: A person with predatory instincts who has not sufficient capital to form a corporation. --Howard Scott --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.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 -~----------~----~----~----~------~----~------~--~---