~gandelman-a/ubuntu/precise/facter/merge922788

« back to all changes in this revision

Viewing changes to lib/facter/ipaddress.rb

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2011-10-18 10:32:42 UTC
  • mfrom: (1.3.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: package-import@ubuntu.com-20111018103242-ag8i8vejfp8v7b1b
Tags: upstream-1.6.1
ImportĀ upstreamĀ versionĀ 1.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Fact: ipaddress
 
2
#
 
3
# Purpose: Return the main IP address for a host.
 
4
#
 
5
# Resolution:
 
6
#   On the Unixes does an ifconfig, and returns the first non 127.0.0.0/8
 
7
#   subnetted IP it finds.
 
8
#   On Windows, it attempts to use the socket library and resolve the machine's
 
9
#   hostname via DNS.
 
10
#
 
11
#   On LDAP based hosts it tries to use either the win32/resolv library to
 
12
#   resolve the hostname to an IP address, or on Unix, it uses the resolv
 
13
#   library.
 
14
#
 
15
#   As a fall back for undefined systems, it tries to run the "host" command to
 
16
#   resolve the machine's hostname using the system DNS.
 
17
#
 
18
# Caveats:
 
19
#   DNS resolution relies on working DNS infrastructure and resolvers on the
 
20
#   host system.
 
21
#   The ifconfig parsing purely takes the first IP address it finds without any
 
22
#   checking this is a useful IP address.
 
23
#
 
24
 
1
25
Facter.add(:ipaddress) do
2
26
    confine :kernel => :linux
3
27
    setcode do