Hi, I have a motd module (not mine) that rewrites /etc/motd with some useful host details. One particular piece of information is the IP address in motd.erb: FQDN: <%= fqdn %> IP: <%= ipaddress %> I have several hosts that have multiple IP addresses, and I need to display them as well. When I run facter | grep ipaddress, I get an array: ipaddress => 172.26.20.16 ipaddress_eth0 => 172.26.20.16 ipaddress_eth1 => 10.20.30.5 ipaddress_eth2 => 10.20.40.5 ipaddress_eth3 => 10.20.50.5 ipaddress_eth4 => 10.20.60.5 ipaddress_eth5 => 10.20.70.5 Is there a way to display eth{0-5} as well? -- 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.
Gonzalo Servat
2012-Feb-13 04:38 UTC
Re: [Puppet Users] Facter displaying multiple IP addresses?
On Mon, Feb 13, 2012 at 2:01 PM, Will S. G. <will@arw.in> wrote:> > Is there a way to display eth{0-5} as well? >You could do a for loop from 0 to N (5?) and check if the variable exists (if has_variable?("ipaddress_eth" + index)) then print it. I''m sure there''s probably a nicer way of doing this in Ruby :) - Gonzalo -- 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.
Torbjörn Norinder
2012-Feb-13 10:32 UTC
Re: [Puppet Users] Facter displaying multiple IP addresses?
You could do IP: <%= scope.to_hash.inject([]) { |acc, (k,v)| acc << v if k =~ /^ipaddress_/; acc }.join('', '') %> Regards, On Sun, Feb 12, 2012 at 07:01:01PM -0800, Will S. G. wrote:> Hi, > > I have a motd module (not mine) that rewrites /etc/motd with some > useful host details. One particular piece of information is the IP > address in motd.erb: > > FQDN: <%= fqdn %> > IP: <%= ipaddress %> > > I have several hosts that have multiple IP addresses, and I need to > display them as well. When I run facter | grep ipaddress, I get an > array: > > ipaddress => 172.26.20.16 > ipaddress_eth0 => 172.26.20.16 > ipaddress_eth1 => 10.20.30.5 > ipaddress_eth2 => 10.20.40.5 > ipaddress_eth3 => 10.20.50.5 > ipaddress_eth4 => 10.20.60.5 > ipaddress_eth5 => 10.20.70.5 > > Is there a way to display eth{0-5} as well? > > > -- > 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. >-- Torbjörn Norinder Campanja AB Kammakargatan 9A 11140 Stockholm Map: http://ow.ly/NUlS www.campanja.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.