facter 1.5.9 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/CHANGELOG +39 -0
- data/LICENSE +11 -13
- data/README.md +24 -0
- data/bin/facter +2 -2
- data/conf/redhat/facter.spec +5 -2
- data/conf/solaris/pkginfo +1 -1
- data/install.rb +1 -1
- data/lib/facter.rb +12 -15
- data/lib/facter/Cfkey.rb +11 -11
- data/lib/facter/application.rb +3 -4
- data/lib/facter/architecture.rb +13 -0
- data/lib/facter/domain.rb +20 -0
- data/lib/facter/facterversion.rb +9 -0
- data/lib/facter/fqdn.rb +11 -0
- data/lib/facter/hardwareisa.rb +12 -0
- data/lib/facter/hardwaremodel.rb +13 -0
- data/lib/facter/hostname.rb +13 -0
- data/lib/facter/id.rb +13 -0
- data/lib/facter/interfaces.rb +9 -0
- data/lib/facter/ipaddress.rb +24 -0
- data/lib/facter/ipaddress6.rb +35 -40
- data/lib/facter/iphostnumber.rb +11 -0
- data/lib/facter/kernel.rb +11 -0
- data/lib/facter/kernelmajversion.rb +10 -0
- data/lib/facter/kernelrelease.rb +13 -0
- data/lib/facter/kernelversion.rb +12 -0
- data/lib/facter/lsb.rb +13 -12
- data/lib/facter/lsbmajdistrelease.rb +12 -0
- data/lib/facter/macaddress.rb +21 -0
- data/lib/facter/macosx.rb +13 -11
- data/lib/facter/manufacturer.rb +13 -0
- data/lib/facter/memory.rb +35 -18
- data/lib/facter/netmask.rb +9 -0
- data/lib/facter/network.rb +12 -0
- data/lib/facter/operatingsystem.rb +13 -0
- data/lib/facter/operatingsystemrelease.rb +17 -0
- data/lib/facter/path.rb +9 -0
- data/lib/facter/physicalprocessorcount.rb +53 -4
- data/lib/facter/processor.rb +14 -1
- data/lib/facter/ps.rb +12 -0
- data/lib/facter/puppetversion.rb +10 -0
- data/lib/facter/rubysitedir.rb +10 -0
- data/lib/facter/rubyversion.rb +9 -0
- data/lib/facter/selinux.rb +9 -0
- data/lib/facter/ssh.rb +9 -11
- data/lib/facter/timezone.rb +9 -0
- data/lib/facter/uptime.rb +11 -0
- data/lib/facter/uptime_days.rb +9 -0
- data/lib/facter/uptime_hours.rb +9 -0
- data/lib/facter/uptime_seconds.rb +14 -0
- data/lib/facter/util/collection.rb +5 -1
- data/lib/facter/util/fact.rb +1 -3
- data/lib/facter/util/loader.rb +1 -0
- data/lib/facter/util/macosx.rb +0 -11
- data/lib/facter/util/memory.rb +1 -13
- data/lib/facter/util/resolution.rb +12 -3
- data/lib/facter/util/virtual.rb +1 -1
- data/lib/facter/virtual.rb +49 -3
- data/lib/facter/vlans.rb +10 -0
- data/lib/facter/xendomains.rb +11 -0
- data/spec/fixtures/uptime/sysctl_kern_boottime_big_endian +0 -0
- data/spec/fixtures/uptime/{sysctl_kern_boottime → sysctl_kern_boottime_little_endian} +0 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/interfaces_spec.rb +2 -5
- data/spec/unit/memory_spec.rb +3 -1
- data/spec/unit/operatingsystem_spec.rb +2 -0
- data/spec/unit/physicalprocessorcount_spec.rb +40 -0
- data/spec/unit/util/fact_spec.rb +11 -11
- data/spec/unit/util/loader_spec.rb +4 -0
- data/spec/unit/util/resolution_spec.rb +20 -2
- data/spec/unit/util/uptime_spec.rb +6 -1
- data/spec/unit/util/virtual_spec.rb +1 -0
- data/spec/unit/virtual_spec.rb +34 -4
- metadata +133 -135
- data/COPYING +0 -339
- data/README +0 -8
- data/README.rst +0 -26
- data/TODO +0 -4
- data/lib/facter/util/#uptime.rb# +0 -64
data/lib/facter/processor.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
+
# Fact: processor
|
2
|
+
#
|
3
|
+
# Purpose:
|
4
|
+
# Additional Facts about the machine's CPUs.
|
5
|
+
#
|
6
|
+
# Resolution:
|
7
|
+
# On Linux and kFreeBSD, parse '/proc/cpuinfo' for each processor.
|
8
|
+
# On AIX, parse the output of 'lsdev' for it's processor section.
|
9
|
+
# On OpenBSD, use 'uname -p' and the sysctl variable for 'hw.ncpu' for CPU
|
10
|
+
# count.
|
11
|
+
#
|
12
|
+
# Caveats:
|
13
|
+
#
|
14
|
+
|
1
15
|
# processor.rb
|
2
|
-
# Additional Facts about the machine's CPUs
|
3
16
|
#
|
4
17
|
# Copyright (C) 2006 Mooter Media Ltd
|
5
18
|
# Author: Matthew Palmer <matt@solutionsfirst.com.au>
|
data/lib/facter/ps.rb
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# Fact: ps
|
2
|
+
#
|
3
|
+
# Purpose: Internal fact for what to use to list all processes. Used by
|
4
|
+
# Service{} type in Puppet.
|
5
|
+
#
|
6
|
+
# Resolution:
|
7
|
+
# Assumes "ps -ef" for all operating systems other than BSD derivatives, where
|
8
|
+
# it uses "ps auxwww"
|
9
|
+
#
|
10
|
+
# Caveats:
|
11
|
+
#
|
12
|
+
|
1
13
|
Facter.add(:ps) do
|
2
14
|
setcode do 'ps -ef' end
|
3
15
|
end
|
data/lib/facter/puppetversion.rb
CHANGED
data/lib/facter/rubysitedir.rb
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# Fact: rubysitedir
|
2
|
+
#
|
3
|
+
# Purpose: Returns Ruby's site library directory.
|
4
|
+
#
|
5
|
+
# Resolution: Works out the version to major/minor (1.8, 1.9, etc), then joins
|
6
|
+
# that with all the $: library paths.
|
7
|
+
#
|
8
|
+
# Caveats:
|
9
|
+
#
|
10
|
+
|
1
11
|
Facter.add :rubysitedir do
|
2
12
|
setcode do
|
3
13
|
version = RUBY_VERSION.to_s.sub(/\.\d+$/, '')
|
data/lib/facter/rubyversion.rb
CHANGED
data/lib/facter/selinux.rb
CHANGED
data/lib/facter/ssh.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
|
+
# Fact: ssh
|
2
|
+
#
|
3
|
+
# Purpose:
|
4
|
+
#
|
5
|
+
# Resolution:
|
6
|
+
#
|
7
|
+
# Caveats:
|
8
|
+
#
|
9
|
+
|
1
10
|
## ssh.rb
|
2
11
|
## Facts related to SSH
|
3
12
|
##
|
4
|
-
## This program is free software; you can redistribute it and/or
|
5
|
-
## modify it under the terms of the GNU General Public License
|
6
|
-
## as published by the Free Software Foundation (version 2 of the License)
|
7
|
-
## This program is distributed in the hope that it will be useful,
|
8
|
-
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
-
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
-
## GNU General Public License for more details.
|
11
|
-
## You should have received a copy of the GNU General Public License
|
12
|
-
## along with this program; if not, write to the Free Software
|
13
|
-
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
|
14
|
-
##
|
15
13
|
|
16
14
|
["/etc/ssh","/usr/local/etc/ssh","/etc","/usr/local/etc"].each do |dir|
|
17
15
|
{"SSHDSAKey" => "ssh_host_dsa_key.pub", "SSHRSAKey" => "ssh_host_rsa_key.pub"}.each do |name,file|
|
data/lib/facter/timezone.rb
CHANGED
data/lib/facter/uptime.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# Fact: uptime
|
2
|
+
#
|
3
|
+
# Purpose: return the system uptime in a human readable format.
|
4
|
+
#
|
5
|
+
# Resolution:
|
6
|
+
# Does basic maths on the "uptime_seconds" fact to return a count of
|
7
|
+
# days, hours and minutes of uptime
|
8
|
+
#
|
9
|
+
# Caveats:
|
10
|
+
#
|
11
|
+
|
1
12
|
require 'facter/util/uptime'
|
2
13
|
|
3
14
|
Facter.add(:uptime) do
|
data/lib/facter/uptime_days.rb
CHANGED
data/lib/facter/uptime_hours.rb
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# Fact: uptime_seconds
|
2
|
+
#
|
3
|
+
# Purpose: Return purely number of seconds of uptime.
|
4
|
+
#
|
5
|
+
# Resolution:
|
6
|
+
# Using the 'facter/util/uptime.rb' module, try a verity of methods to acquire
|
7
|
+
# the uptime on Unix.
|
8
|
+
#
|
9
|
+
# On Windows, the module calculates the uptime by the "LastBootupTime" Windows
|
10
|
+
# management value.
|
11
|
+
#
|
12
|
+
# Caveats:
|
13
|
+
#
|
14
|
+
|
1
15
|
require 'facter/util/uptime'
|
2
16
|
|
3
17
|
Facter.add(:uptime_seconds) do
|
@@ -66,9 +66,13 @@ class Facter::Util::Collection
|
|
66
66
|
def fact(name)
|
67
67
|
name = canonize(name)
|
68
68
|
|
69
|
+
# Try to load the fact if necessary
|
69
70
|
loader.load(name) unless @facts[name]
|
70
71
|
|
71
|
-
|
72
|
+
# Try HARDER
|
73
|
+
loader.load_all unless @facts[name]
|
74
|
+
|
75
|
+
@facts[name]
|
72
76
|
end
|
73
77
|
|
74
78
|
# Flush all cached values.
|
data/lib/facter/util/fact.rb
CHANGED
@@ -41,9 +41,7 @@ class Facter::Util::Fact
|
|
41
41
|
|
42
42
|
# Immediately sort the resolutions, so that we always have
|
43
43
|
# a sorted list for looking up values.
|
44
|
-
|
45
|
-
# confines, so the most restricted resolution always wins.
|
46
|
-
@resolves.sort! { |a, b| b.length <=> a.length }
|
44
|
+
@resolves.sort! { |a, b| b.weight <=> a.weight }
|
47
45
|
|
48
46
|
return resolve
|
49
47
|
end
|
data/lib/facter/util/loader.rb
CHANGED
data/lib/facter/util/macosx.rb
CHANGED
@@ -4,17 +4,6 @@
|
|
4
4
|
## Copyright (C) 2007 Jeff McCune
|
5
5
|
## Author: Jeff McCune <jeff.mccune@northstarlabs.net>
|
6
6
|
##
|
7
|
-
## This program is free software; you can redistribute it and/or
|
8
|
-
## modify it under the terms of the GNU General Public License
|
9
|
-
## as published by the Free Software Foundation (version 2 of the License)
|
10
|
-
## This program is distributed in the hope that it will be useful,
|
11
|
-
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
## GNU General Public License for more details.
|
14
|
-
## You should have received a copy of the GNU General Public License
|
15
|
-
## along with this program; if not, write to the Free Software
|
16
|
-
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
|
17
|
-
##
|
18
7
|
|
19
8
|
module Facter::Util::Macosx
|
20
9
|
require 'thread'
|
data/lib/facter/util/memory.rb
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
## memory.rb
|
2
2
|
## Support module for memory related facts
|
3
3
|
##
|
4
|
-
## This program is free software; you can redistribute it and/or
|
5
|
-
## modify it under the terms of the GNU General Public License
|
6
|
-
## as published by the Free Software Foundation (version 2 of the License)
|
7
|
-
## This program is distributed in the hope that it will be useful,
|
8
|
-
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
-
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
-
## GNU General Public License for more details.
|
11
|
-
## You should have received a copy of the GNU General Public License
|
12
|
-
## along with this program; if not, write to the Free Software
|
13
|
-
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
|
14
|
-
##
|
15
4
|
|
16
5
|
module Facter::Memory
|
17
6
|
require 'thread'
|
@@ -75,7 +64,7 @@ module Facter::Memory
|
|
75
64
|
memspecfree = 0
|
76
65
|
|
77
66
|
vmstats = Facter::Util::Resolution.exec('vm_stat')
|
78
|
-
vmstats.
|
67
|
+
vmstats.each_line do |vmline|
|
79
68
|
case
|
80
69
|
when vmline =~ /page\ssize\sof\s(\d+)\sbytes/
|
81
70
|
pagesize = $1.to_i
|
@@ -94,4 +83,3 @@ module Facter::Memory
|
|
94
83
|
end
|
95
84
|
end
|
96
85
|
end
|
97
|
-
|
@@ -85,17 +85,26 @@ class Facter::Util::Resolution
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
def has_weight(weight)
|
89
|
+
@weight = weight
|
90
|
+
end
|
91
|
+
|
88
92
|
# Create a new resolution mechanism.
|
89
93
|
def initialize(name)
|
90
94
|
@name = name
|
91
95
|
@confines = []
|
92
96
|
@value = nil
|
93
97
|
@timeout = 0
|
98
|
+
@weight = nil
|
94
99
|
end
|
95
100
|
|
96
|
-
# Return the
|
97
|
-
def
|
98
|
-
@
|
101
|
+
# Return the importance of this resolution.
|
102
|
+
def weight
|
103
|
+
if @weight
|
104
|
+
@weight
|
105
|
+
else
|
106
|
+
@confines.length
|
107
|
+
end
|
99
108
|
end
|
100
109
|
|
101
110
|
# We need this as a getter for 'timeout', because some versions
|
data/lib/facter/util/virtual.rb
CHANGED
data/lib/facter/virtual.rb
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
# Fact: virtual
|
2
|
+
#
|
3
|
+
# Purpose: Determine if the system's hardware is real or virtualised.
|
4
|
+
#
|
5
|
+
# Resolution:
|
6
|
+
# Assumes physical unless proven otherwise.
|
7
|
+
#
|
8
|
+
# On Darwin, use the macosx util module to acquire the SPDisplaysDataType,
|
9
|
+
# from that parse it to see if it's VMWare or Parallels pretending to be the
|
10
|
+
# display.
|
11
|
+
#
|
12
|
+
# On Linux, BSD, Solaris and HPUX:
|
13
|
+
# Much of the logic here is obscured behind util/virtual.rb, which rather
|
14
|
+
# than document here, which would encourage drift, just refer to it.
|
15
|
+
# The Xen tests in here rely on /sys and /proc, and check for the presence and
|
16
|
+
# contents of files in there.
|
17
|
+
# If after all the other tests, it's still seen as physical, then it tries to
|
18
|
+
# parse the output of the "lspci", "dmidecode" and "prtdiag" and parses them
|
19
|
+
# for obvious signs of being under VMWare or Parallels.
|
20
|
+
# Finally it checks for the existence of vmware-vmx, which would hint it's
|
21
|
+
# VMWare.
|
22
|
+
#
|
23
|
+
# Caveats:
|
24
|
+
# Virtualbox detection isn't implemented.
|
25
|
+
# Many checks rely purely on existence of files.
|
26
|
+
#
|
27
|
+
|
1
28
|
require 'facter/util/virtual'
|
2
29
|
|
3
30
|
Facter.add("virtual") do
|
@@ -25,7 +52,7 @@ Facter.add("virtual") do
|
|
25
52
|
|
26
53
|
setcode do
|
27
54
|
|
28
|
-
if Facter
|
55
|
+
if Facter.value(:operatingsystem) == "Solaris" and Facter::Util::Virtual.zone?
|
29
56
|
result = "zone"
|
30
57
|
end
|
31
58
|
|
@@ -77,6 +104,9 @@ Facter.add("virtual") do
|
|
77
104
|
# --- look for the vmware video card to determine if it is virtual => vmware.
|
78
105
|
# --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
|
79
106
|
result = "vmware" if p =~ /VM[wW]are/
|
107
|
+
# --- look for virtualbox video card to determine if it is virtual => virtualbox.
|
108
|
+
# --- 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
|
109
|
+
result = "virtualbox" if p =~ /VirtualBox/
|
80
110
|
# --- look for pci vendor id used by Parallels video card
|
81
111
|
# --- 01:00.0 VGA compatible controller: Unknown device 1ab8:4005
|
82
112
|
result = "parallels" if p =~ /1ab8:|[Pp]arallels/
|
@@ -87,13 +117,18 @@ Facter.add("virtual") do
|
|
87
117
|
output.each_line do |pd|
|
88
118
|
result = "parallels" if pd =~ /Parallels/
|
89
119
|
result = "vmware" if pd =~ /VMware/
|
120
|
+
result = "virtualbox" if pd =~ /VirtualBox/
|
90
121
|
end
|
91
|
-
|
92
|
-
|
122
|
+
elsif Facter.value(:kernel) == 'SunOS'
|
123
|
+
res = Facter::Util::Resolution.new('prtdiag')
|
124
|
+
res.timeout = 6
|
125
|
+
res.setcode('prtdiag')
|
126
|
+
output = res.value
|
93
127
|
if not output.nil?
|
94
128
|
output.each_line do |pd|
|
95
129
|
result = "parallels" if pd =~ /Parallels/
|
96
130
|
result = "vmware" if pd =~ /VMware/
|
131
|
+
result = "virtualbox" if pd =~ /VirtualBox/
|
97
132
|
end
|
98
133
|
end
|
99
134
|
end
|
@@ -108,6 +143,17 @@ Facter.add("virtual") do
|
|
108
143
|
end
|
109
144
|
end
|
110
145
|
|
146
|
+
# Fact: is_virtual
|
147
|
+
#
|
148
|
+
# Purpose: returning true or false for if a machine is virtualised or not.
|
149
|
+
#
|
150
|
+
# Resolution: The Xen domain 0 machine is virtualised to a degree, but is generally
|
151
|
+
# not viewed as being a virtual machine. This checks that the machine is not
|
152
|
+
# physical nor xen0, if that is the case, it is virtual.
|
153
|
+
#
|
154
|
+
# Caveats:
|
155
|
+
#
|
156
|
+
|
111
157
|
Facter.add("is_virtual") do
|
112
158
|
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS HP-UX Darwin GNU/kFreeBSD}
|
113
159
|
|
data/lib/facter/vlans.rb
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# Fact: vlans
|
2
|
+
#
|
3
|
+
# Purpose: On Linux, return a list of all the VLANs on the system.
|
4
|
+
#
|
5
|
+
# Resolution: On Linux only, checks for and reads /proc/net/vlan/config and
|
6
|
+
# parses it.
|
7
|
+
#
|
8
|
+
# Caveats:
|
9
|
+
#
|
10
|
+
|
1
11
|
require 'facter/util/vlans'
|
2
12
|
|
3
13
|
Facter.add("vlans") do
|
data/lib/facter/xendomains.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# Fact: xendomains
|
2
|
+
#
|
3
|
+
# Purpose: Return the list of Xen domains on the Dom0.
|
4
|
+
#
|
5
|
+
# Resolution:
|
6
|
+
# On a Xen Dom0 host, return a list of Xen domains using the 'util/xendomains'
|
7
|
+
# library.
|
8
|
+
#
|
9
|
+
# Caveats:
|
10
|
+
#
|
11
|
+
|
1
12
|
require 'facter/util/xendomains'
|
2
13
|
|
3
14
|
Facter.add("xendomains") do
|
Binary file
|
File without changes
|