From: Ben H <[email protected]> Document all the builtin Facter facts in puppetdoc/rdoc format.
Signed-off-by: Ben Hughes <[email protected]> --- Local-branch: tickets/master/5394 lib/facter/Cfkey.rb | 11 +++++++++++ lib/facter/ipaddress.rb | 24 ++++++++++++++++++++++++ lib/facter/ipaddress6.rb | 27 ++++++++++++++++++--------- lib/facter/iphostnumber.rb | 11 +++++++++++ lib/facter/macosx.rb | 13 +++++++++++++ lib/facter/manufacturer.rb | 13 +++++++++++++ lib/facter/netmask.rb | 9 +++++++++ lib/facter/network.rb | 12 ++++++++++++ lib/facter/operatingsystem.rb | 13 +++++++++++++ lib/facter/operatingsystemrelease.rb | 17 +++++++++++++++++ lib/facter/path.rb | 9 +++++++++ lib/facter/physicalprocessorcount.rb | 11 +++++++++++ lib/facter/processor.rb | 15 ++++++++++++++- lib/facter/rubysitedir.rb | 10 ++++++++++ lib/facter/rubyversion.rb | 9 +++++++++ lib/facter/xendomains.rb | 11 +++++++++++ 16 files changed, 205 insertions(+), 10 deletions(-) diff --git a/lib/facter/Cfkey.rb b/lib/facter/Cfkey.rb index a4e0c11..8353392 100644 --- a/lib/facter/Cfkey.rb +++ b/lib/facter/Cfkey.rb @@ -1,3 +1,14 @@ +# Fact: Cfkey +# +# Purpose: Return the public key(s) for CFengine. +# +# Resolution: +# Tries each file of standard localhost.pub & cfkey.pub locations, +# checks if they appear to be a public key, and then join them all together. +# +# Caveats: +# + ## Cfkey.rb ## Facts related to cfengine ## diff --git a/lib/facter/ipaddress.rb b/lib/facter/ipaddress.rb index d563408..5260504 100644 --- a/lib/facter/ipaddress.rb +++ b/lib/facter/ipaddress.rb @@ -1,3 +1,27 @@ +# Fact: ipaddress +# +# Purpose: Return the main IP address for a host. +# +# Resolution: +# On the Unixes does an ifconfig, and returns the first non 127.0.0.0/8 +# subnetted IP it finds. +# On Windows, it attempts to use the socket library and resolve the machine's +# hostname via DNS. +# +# On LDAP based hosts it tries to use either the win32/resolv library to +# resolve the hostname to an IP address, or on Unix, it uses the resolv +# library. +# +# As a fall back for undefined systems, it tries to run the "host" command to +# resolve the machine's hostname using the system DNS. +# +# Caveats: +# DNS resolution relies on working DNS infrastructure and resolvers on the +# host system. +# The ifconfig parsing purely takes the first IP address it finds without any +# checking this is a useful IP address. +# + Facter.add(:ipaddress) do confine :kernel => :linux setcode do diff --git a/lib/facter/ipaddress6.rb b/lib/facter/ipaddress6.rb index 547d636..b494b9d 100644 --- a/lib/facter/ipaddress6.rb +++ b/lib/facter/ipaddress6.rb @@ -1,17 +1,26 @@ +# Fact: ipaddress6 +# +# Purpose: Returns the "main" IPv6 IP address of a system. +# +# Resolution: +# OS dependant code that parses the output of various networking +# tools and currently not very intelligent. Returns the first +# non-loopback and non-linklocal address found in the ouput unless +# a default route can be mapped to a routeable interface. Guessing +# an interface is currently only possible with BSD type systems +# to many assumptions have to be made on other platforms to make +# this work with the current code. Most code ported or modeled +# after the ipaddress fact for the sake of similar functionality +# and familiar mechanics. +# +# Caveats: +# + # Cody Herriges <[email protected]> # # Used the ipaddress fact that is already part of # Facter as a template. -# OS dependant code that parses the output of various networking -# tools and currently not very intelligent. Returns the first -# non-loopback and non-linklocal address found in the ouput unless -# a default route can be mapped to a routeable interface. Guessing -# an interface is currently only possible with BSD type systems -# to many assumptions have to be made on other platforms to make -# this work with the current code. Most code ported or modeled -# after the ipaddress fact for the sake of similar functionality -# and familiar mechanics. Facter.add(:ipaddress6) do confine :kernel => :linux setcode do diff --git a/lib/facter/iphostnumber.rb b/lib/facter/iphostnumber.rb index bc38432..cddaadd 100644 --- a/lib/facter/iphostnumber.rb +++ b/lib/facter/iphostnumber.rb @@ -1,3 +1,14 @@ +# Fact: iphostnumber +# +# Purpose: On selected versions of Darwin, returns the host's IP address. +# +# Resolution: +# Uses either the scutil program to get the localhost name, or parses output +# of ifconfig for a MAC address. +# +# Caveats: +# + Facter.add(:iphostnumber) do confine :kernel => :darwin, :kernelrelease => "R6" setcode do diff --git a/lib/facter/macosx.rb b/lib/facter/macosx.rb index 3841c50..f5289df 100644 --- a/lib/facter/macosx.rb +++ b/lib/facter/macosx.rb @@ -1,3 +1,16 @@ +# Fact: macosx +# +# Purpose: +# Returns a number of Mac specific facts, from system profiler and +# sw_vers. +# +# Resolution: +# Uses util/macosx.rb to do the fact reconnaissance, then outputs them +# preceded by 'sp_' +# +# Caveats: +# + # # macosx.rb # Additional Facts coming from Mac OS X system_profiler command diff --git a/lib/facter/manufacturer.rb b/lib/facter/manufacturer.rb index 4f2df98..26aef5f 100644 --- a/lib/facter/manufacturer.rb +++ b/lib/facter/manufacturer.rb @@ -1,3 +1,16 @@ +# Fact: manufacturer +# +# Purpose: Return the hardware manufacturer information about the hardware. +# +# Resolution: +# On OpenBSD, queries sysctl values, via a util class. +# On SunOS Sparc, uses prtdiag via a util class. +# On Windows, queries the system via a util class. +# Uses the 'util/manufacturer.rb' for fallback parsing. +# +# Caveats: +# + # manufacturer.rb # Facts related to hardware manufacturer # diff --git a/lib/facter/netmask.rb b/lib/facter/netmask.rb index d6d125e..fbb84f5 100644 --- a/lib/facter/netmask.rb +++ b/lib/facter/netmask.rb @@ -1,3 +1,12 @@ +# Fact: netmask +# +# Purpose: Returns the netmask for the main interfaces. +# +# Resolution: Uses the facter/util/netmask library routines. +# +# Caveats: +# + # netmask.rb # Find the netmask of the primary ipaddress # Copyright (C) 2007 David Schmitt <[email protected]> diff --git a/lib/facter/network.rb b/lib/facter/network.rb index df53ce4..d4faaac 100644 --- a/lib/facter/network.rb +++ b/lib/facter/network.rb @@ -1,3 +1,15 @@ +# Fact: network +# +# Purpose: +# Get IP, network and netmask information for available network +# interfacs. +# +# Resolution: +# Uses 'facter/util/ip' to enumerate interfaces and return their information. +# +# Caveats: +# + require 'facter/util/ip' Facter::Util::IP.get_interfaces.each do |interface| diff --git a/lib/facter/operatingsystem.rb b/lib/facter/operatingsystem.rb index c5a3dc1..0df4ce1 100644 --- a/lib/facter/operatingsystem.rb +++ b/lib/facter/operatingsystem.rb @@ -1,3 +1,16 @@ +# Fact: operatingsystem +# +# Purpose: Return the name of the operating system. +# +# Resolution: +# If the kernel is a Linux kernel, check for the existence of a selection of +# files in /etc/ to find the specific flavour. +# On SunOS based kernels, return Solaris. +# On systems other than Linux, use the kernel value. +# +# Caveats: +# + require 'facter/lsb' Facter.add(:operatingsystem) do diff --git a/lib/facter/operatingsystemrelease.rb b/lib/facter/operatingsystemrelease.rb index 280208b..6a1646b 100644 --- a/lib/facter/operatingsystemrelease.rb +++ b/lib/facter/operatingsystemrelease.rb @@ -1,3 +1,20 @@ +# Fact: operatingsystemrelease +# +# Purpose: Returns the release of the operating system. +# +# Resolution: +# On RedHat derivatives, returns their '/etc/<variant>-release' file. +# On Debian, returns '/etc/debian_version'. +# On Ubuntu, parses '/etc/issue' for the release version. +# On Suse, derivatives, parses '/etc/SuSE-release' for a selection of version +# information. +# On Slackware, parses '/etc/slackware-version'. +# +# On all remaining systems, returns the 'kernelrelease' value. +# +# Caveats: +# + Facter.add(:operatingsystemrelease) do confine :operatingsystem => %w{CentOS Fedora oel ovs RedHat MeeGo} setcode do diff --git a/lib/facter/path.rb b/lib/facter/path.rb index 03907c0..71df6cd 100644 --- a/lib/facter/path.rb +++ b/lib/facter/path.rb @@ -1,3 +1,12 @@ +# Fact: path +# +# Purpose: Returns the $PATH variable. +# +# Resolution: Gets $PATH from the environment. +# +# Caveats: +# + Facter.add(:path) do setcode do ENV['PATH'] diff --git a/lib/facter/physicalprocessorcount.rb b/lib/facter/physicalprocessorcount.rb index 8fe643e..9c59614 100644 --- a/lib/facter/physicalprocessorcount.rb +++ b/lib/facter/physicalprocessorcount.rb @@ -1,3 +1,14 @@ +# Fact: physicalprocessorcount +# +# Purpose: Return the number of physical processors. +# +# Resolution: +# On linux, parses the output of '/proc/cpuinfo' for the number of unique +# lines with "physical id" in them. +# +# Caveats: +# + Facter.add("physicalprocessorcount") do confine :kernel => :linux diff --git a/lib/facter/processor.rb b/lib/facter/processor.rb index ac75867..70cc433 100644 --- a/lib/facter/processor.rb +++ b/lib/facter/processor.rb @@ -1,5 +1,18 @@ +# Fact: processor +# +# Purpose: +# Additional Facts about the machine's CPUs. +# +# Resolution: +# On Linux and kFreeBSD, parse '/proc/cpuinfo' for each processor. +# On AIX, parse the output of 'lsdev' for it's processor section. +# On OpenBSD, use 'uname -p' and the sysctl variable for 'hw.ncpu' for CPU +# count. +# +# Caveats: +# + # processor.rb -# Additional Facts about the machine's CPUs # # Copyright (C) 2006 Mooter Media Ltd # Author: Matthew Palmer <[email protected]> diff --git a/lib/facter/rubysitedir.rb b/lib/facter/rubysitedir.rb index c205322..9973329 100644 --- a/lib/facter/rubysitedir.rb +++ b/lib/facter/rubysitedir.rb @@ -1,3 +1,13 @@ +# Fact: rubysitedir +# +# Purpose: Returns Ruby's site library directory. +# +# Resolution: Works out the version to major/minor (1.8, 1.9, etc), then joins +# that with all the $: library paths. +# +# Caveats: +# + Facter.add :rubysitedir do setcode do version = RUBY_VERSION.to_s.sub(/\.\d+$/, '') diff --git a/lib/facter/rubyversion.rb b/lib/facter/rubyversion.rb index 48f5cc8..e578400 100644 --- a/lib/facter/rubyversion.rb +++ b/lib/facter/rubyversion.rb @@ -1,3 +1,12 @@ +# Fact: rubyversion +# +# Purpose: Returns the version of Ruby facter is running under. +# +# Resolution: Returns RUBY_VERSION. +# +# Caveats: +# + Facter.add(:rubyversion) do setcode { RUBY_VERSION.to_s } end diff --git a/lib/facter/xendomains.rb b/lib/facter/xendomains.rb index 972ac90..5bcde05 100644 --- a/lib/facter/xendomains.rb +++ b/lib/facter/xendomains.rb @@ -1,3 +1,14 @@ +# Fact: xendomains +# +# Purpose: Return the list of Xen domains on the Dom0. +# +# Resolution: +# On a Xen Dom0 host, return a list of Xen domains using the 'util/xendomains' +# library. +# +# Caveats: +# + require 'facter/util/xendomains' Facter.add("xendomains") do -- 1.7.4.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
