hi list, i''d guess the subject could cause some braindamage, i''m sorry for that, i did not find a better description for my problem. here my problem. i do have the following list of variables to work with: $service_listenif = "eth0" ## this is a variable that comes from the node definition $ipaddress_eth0 = "192.168.0.1" ## comes throught facter now i do want to set new variable called $listenip containing the ip of the interface that has been specified in $service_listenif. how would you solve that? since: $listenip = $ipaddress_$service_listenif ## does not work i''ve been testing around with generate using something similar to: $listenip = generate("/sbin/ifconfig", "$service_listenif | grep inet | sed ''s/^\s*inet addr://'' | sed ''s/ Bcast.*//''") did not work either, at least so far, it seems that generate wouldn''t let me pass multiple commands as shown above, no matter which combination i took. last but not least, if there is no chance of doing that the puppet way, i''ll write a shell script for that accepting $service_listenif as parameter and doing the "logic" inside the sheel script. would like to hear your thoughts. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
matt.adams@cypressinteractive.com
2009-Aug-11 10:14 UTC
[Puppet Users] Re: variable variable naming
Thank you for your message. I am out of the office until August 17th and will respond after I return. Thank you! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try: $listenip = "${ipaddress}_${service_listenif}" - Chad On Tue, Aug 11, 2009 at 6:14 AM, Jan Werner<rababerkuchen@tortenboxer.de> wrote:> > hi list, > > i''d guess the subject could cause some braindamage, i''m sorry for > that, i did not find a better description for my problem. > > here my problem. > i do have the following list of variables to work with: > > $service_listenif = "eth0" ## this is a variable that comes from the > node definition > $ipaddress_eth0 = "192.168.0.1" ## comes throught facter > > now i do want to set new variable called $listenip containing the ip > of the interface that has been specified in $service_listenif. > > how would you solve that? > since: > $listenip = $ipaddress_$service_listenif ## does not work > > i''ve been testing around with generate using something similar to: > $listenip = generate("/sbin/ifconfig", "$service_listenif | grep inet > | sed ''s/^\s*inet addr://'' | sed ''s/ Bcast.*//''") > > did not work either, at least so far, it seems that generate wouldn''t > let me pass multiple commands as shown above, no matter which > combination i took. > > > last but not least, if there is no chance of doing that the puppet > way, i''ll write a shell script for that > accepting $service_listenif as parameter and doing the "logic" inside > the sheel script. > > would like to hear your thoughts. > > > > >-- Chad M. Huneycutt --~--~---------~--~----~------------~-------~--~----~ 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 Aug., 17:10, Chad Huneycutt <chad.huneyc...@gmail.com> wrote:> Try: > > $listenip = "${ipaddress}_${service_listenif}" > > - Chadhey chad, thanks for your reply your example above would give me $listenip = "192.168.0.1_eth0" but instead i need $listenip = "%IP_OF_SOME_NETWORK_DEVICE%" , where the "device" is dynamic means, it could also be eth1, or even tun0 etc. since i do not want to set fixed ip''s in every single node definition lets explain some more, lets say you do have some servers on the cloud where eth0 is the "bad and evil" network interface, you do not want to have any of your services on this one even thought there could be a firewall etc. but that is not the point in here. and tun0 ist your "good and shiny" interface, where all your company traffic gets over a secured vpn link how would you tell every node that it''s services should just run on lets say tun0, without "hardconding" to a module or class eh. while writing the things above, i''d propably found a solution: node definitions says: $listenif = eth0 now the "magic" class comes to it''s action and has the following code: case $listenif { eth0: $listenip = $ipaddress_eth0 eth1: $listenip = $ipaddress_eth1 tun0: $listenip = $ipaddress_tun0 tun1: $listenip = $ipaddress_tun1 } eh, makes me feel a bit stupid that i haven''t got the idea earlier, anyway the best solutions come into our mind when we step back and take a look from further away ain''t they hopefully it''s working tomorrow when i try it out --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jan Werner wrote:> eh. while writing the things above, i''d propably found a solution: > node definitions says: $listenif = eth0 > > now the "magic" class comes to it''s action and has the following code: > case $listenif { > eth0: $listenip = $ipaddress_eth0 > eth1: $listenip = $ipaddress_eth1 > tun0: $listenip = $ipaddress_tun0 > tun1: $listenip = $ipaddress_tun1 > }You may want to add a default case, calling the fail() function: case $listenif { ''eth0'': $listenip = $ipaddress_eth0 ... default: fail("Bad value for \$listenif: ``$listenif''''") } That way you will get a clear error message instead of just strange behaviour when you, two years from now, happen to set $listenif to "eth7". /Bellman --~--~---------~--~----~------------~-------~--~----~ 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 12 Aug., 11:17, Thomas Bellman <bell...@nsc.liu.se> wrote:> Jan Werner wrote: > > eh. while writing the things above, i''d propably found a solution: > > node definitions says: $listenif = eth0 > > > now the "magic" class comes to it''s action and has the following code: > > case $listenif { > > eth0: $listenip = $ipaddress_eth0 > > eth1: $listenip = $ipaddress_eth1 > > tun0: $listenip = $ipaddress_tun0 > > tun1: $listenip = $ipaddress_tun1 > > } > > You may want to add a default case, calling the fail() function: > > case $listenif { > ''eth0'': $listenip = $ipaddress_eth0 > ... > default: fail("Bad value for \$listenif: ``$listenif''''") > } > > That way you will get a clear error message instead of just strange > behaviour when you, two years from now, happen to set $listenif to "eth7". > > /Bellmani did that now, thx for the hint, here is my complete listing for now: case $listenif { eth0: { $bindip = $ipaddress_eth0 } eth1: { $bindip = $ipaddress_eth1 } tun0: { $bindip = $ipaddress_tun0 } tun1: { $bindip = $ipaddress_tun1 } default: { notice("## no listenif parameter set for host $host. $fqdn, using loopack interface as bindport ##") $bindip "127.0.0.1" } } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---