Re: [Puppet Users] can we choose which inteface defines the $ipaddress fact?
On Feb 7, 2011, at 6:14 PM, Gabriel Filion wrote: > Hi, > > I've run into some bug today with nagios checks that are exported in a > client's puppet setup. > > The problem is that some host definitions are exported with an internal > address (10.x or 192.168.x) even though the servers do have an external > IP on another interface. > > One of those uses a tap inteface to bridge traffic, and another has a > virtual interface that is used for a vlan. > > In all cases, the interface with an internal IP comes up higher in the > output of ifconfig, and this makes the fact "ipaddress" take it as its > value. > > Is there a way to force facter to chose a specific interface for the > ipaddress value? Yes and no. Try running "facter | grep ipaddress" on the client. This will give you the names of variables you should be using instead that are listed by interface. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Re: [Puppet Users] can we choose which inteface defines the $ipaddress fact?
On 11-02-08 12:05 AM, Patrick wrote: > Yes and no. > > Try running "facter | grep ipaddress" on the client. This will give you the > names of variables you should be using instead that are listed by interface. hmm, well thanks for confirming this. I'll have to put some effort on my nagios module to provide for an override for the ip address, then. -- Gabriel Filion -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Re: [Puppet Users] can we choose which inteface defines the $ipaddress fact?
On 8 February 2011 07:44, Gabriel Filion wrote: [...] > Is there a way to force facter to chose a specific interface for the > ipaddress value? Hi, I was wondering *when* would this part of the ipaddress.rb fact code would be used: --(0)> tail -20 /usr/lib/ruby/site_ruby/1.8/facter/ipaddress.rb Facter.add(:ipaddress, :timeout => 2) do setcode do if hostname = Facter.value(:hostname) # we need Hostname to exist for this to work host = nil if host = Facter::Util::Resolution.exec("host #{hostname}") list = host.chomp.split(/\s/) if defined? list[-1] and list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ list[-1] end else nil end else nil end end end --(naresh.ve@puppet)-(~)-- --(0)> irb -rfacter irb(main):001:0> Facter::Util::Resolution.exec("host puppet.domain.com") => "puppet.directi.com has address a.b.c.d" irb(main):002:0> host = Facter::Util::Resolution.exec("host puppet.domain.com") => "puppet.directi.com has address a.b.c.d" irb(main):003:0> list = host.chomp.split(/\s/) => ["puppet.directi.com", "has", "address", "a.b.c.d"] irb(main):004:0> if defined? list[-1] and list [-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ irb(main):005:1> list[-1] irb(main):006:1> end => "a.b.c.d" irb(main):007:0> (masked my IP with a.b.c.d) If this part were the default/first piece of code that'd be used to produce the ipaddress fact, setting the right A record for the fqdn should solve the problem? -Naresh -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Re: [Puppet Users] can we choose which inteface defines the $ipaddress fact?
On 11-02-09 01:01 AM, Naresh V wrote: > Facter.add(:ipaddress, :timeout => 2) do > setcode do > if hostname = Facter.value(:hostname) > # we need Hostname to exist for this to work > host = nil > if host = Facter::Util::Resolution.exec("host #{hostname}") > list = host.chomp.split(/\s/) > if defined? list[-1] and > list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ > list[-1] > end > else > nil > end > else > nil > end > end > end > If this part were the default/first piece of code that'd be used to > produce the ipaddress fact, setting the right A record for the fqdn > should solve the problem? hmm this fact looks like it won't work for any host that doesn't resolve, which would be problematic for something like a test setup with virtual machines. -- Gabriel Filion -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.