facter 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of facter might be problematic. Click here for more details.

Files changed (88) hide show
  1. data/CHANGELOG +31 -0
  2. data/Rakefile +41 -36
  3. data/conf/redhat/facter.spec +11 -4
  4. data/conf/solaris/pkginfo +1 -1
  5. data/install.rb +286 -286
  6. data/lib/facter.rb +211 -211
  7. data/lib/facter/Cfkey.rb +24 -24
  8. data/lib/facter/application.rb +1 -0
  9. data/lib/facter/architecture.rb +21 -29
  10. data/lib/facter/domain.rb +34 -34
  11. data/lib/facter/facterversion.rb +1 -1
  12. data/lib/facter/fqdn.rb +8 -8
  13. data/lib/facter/hardwareisa.rb +2 -2
  14. data/lib/facter/hardwaremodel.rb +12 -12
  15. data/lib/facter/hostname.rb +14 -14
  16. data/lib/facter/id.rb +3 -3
  17. data/lib/facter/interfaces.rb +13 -13
  18. data/lib/facter/ipaddress.rb +101 -101
  19. data/lib/facter/iphostnumber.rb +12 -12
  20. data/lib/facter/kernel.rb +7 -7
  21. data/lib/facter/kernelmajversion.rb +3 -3
  22. data/lib/facter/kernelrelease.rb +12 -12
  23. data/lib/facter/kernelversion.rb +5 -5
  24. data/lib/facter/lsb.rb +14 -14
  25. data/lib/facter/lsbmajdistrelease.rb +8 -8
  26. data/lib/facter/macaddress.rb +44 -44
  27. data/lib/facter/macosx.rb +21 -21
  28. data/lib/facter/manufacturer.rb +28 -28
  29. data/lib/facter/memory.rb +143 -115
  30. data/lib/facter/netmask.rb +4 -4
  31. data/lib/facter/network.rb +4 -4
  32. data/lib/facter/operatingsystem.rb +73 -69
  33. data/lib/facter/operatingsystemrelease.rb +85 -79
  34. data/lib/facter/osfamily.rb +31 -0
  35. data/lib/facter/path.rb +3 -3
  36. data/lib/facter/physicalprocessorcount.rb +8 -0
  37. data/lib/facter/processor.rb +91 -72
  38. data/lib/facter/ps.rb +3 -3
  39. data/lib/facter/puppetversion.rb +7 -7
  40. data/lib/facter/rubysitedir.rb +5 -5
  41. data/lib/facter/rubyversion.rb +1 -1
  42. data/lib/facter/ssh.rb +16 -16
  43. data/lib/facter/timezone.rb +3 -3
  44. data/lib/facter/uniqueid.rb +2 -2
  45. data/lib/facter/util/collection.rb +96 -96
  46. data/lib/facter/util/confine.rb +30 -30
  47. data/lib/facter/util/fact.rb +95 -95
  48. data/lib/facter/util/ip.rb +173 -173
  49. data/lib/facter/util/loader.rb +88 -88
  50. data/lib/facter/util/macosx.rb +46 -46
  51. data/lib/facter/util/manufacturer.rb +78 -78
  52. data/lib/facter/util/memory.rb +63 -63
  53. data/lib/facter/util/netmask.rb +34 -34
  54. data/lib/facter/util/plist.rb +1 -1
  55. data/lib/facter/util/plist/generator.rb +177 -177
  56. data/lib/facter/util/plist/parser.rb +166 -166
  57. data/lib/facter/util/processor.rb +88 -0
  58. data/lib/facter/util/resolution.rb +154 -154
  59. data/lib/facter/util/uptime.rb +42 -42
  60. data/lib/facter/util/values.rb +9 -9
  61. data/lib/facter/util/virtual.rb +68 -58
  62. data/lib/facter/util/vlans.rb +17 -17
  63. data/lib/facter/virtual.rb +105 -110
  64. data/lib/facter/vlans.rb +6 -6
  65. data/spec/fixtures/cpuinfo/amd64dual +57 -0
  66. data/spec/fixtures/cpuinfo/amd64quad +79 -0
  67. data/spec/fixtures/cpuinfo/amd64solo +23 -0
  68. data/spec/fixtures/cpuinfo/amd64tri +86 -0
  69. data/spec/fixtures/cpuinfo/bbg3-armel +12 -0
  70. data/spec/fixtures/cpuinfo/beaglexm-armel +12 -0
  71. data/spec/fixtures/cpuinfo/panda-armel +17 -0
  72. data/spec/fixtures/cpuinfo/ppc64 +19 -0
  73. data/spec/fixtures/cpuinfo/sparc +10 -0
  74. data/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info +1216 -0
  75. data/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info +225 -0
  76. data/spec/integration/facter_spec.rb +18 -18
  77. data/spec/spec_helper.rb +10 -1
  78. data/spec/unit/architecture_spec.rb +54 -0
  79. data/spec/unit/domain_spec.rb +23 -0
  80. data/spec/unit/memory_spec.rb +78 -1
  81. data/spec/unit/physicalprocessorcount_spec.rb +41 -35
  82. data/spec/unit/processor_spec.rb +183 -2
  83. data/spec/unit/util/processor_spec.rb +62 -0
  84. data/spec/unit/util/uptime_spec.rb +4 -4
  85. data/spec/unit/util/virtual_spec.rb +26 -5
  86. data/spec/unit/virtual_spec.rb +47 -2
  87. data/spec/watchr.rb +125 -0
  88. metadata +20 -4
@@ -18,9 +18,9 @@
18
18
  require 'facter/util/netmask'
19
19
 
20
20
  Facter.add("netmask") do
21
- confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd" ]
22
- setcode do
23
- Facter::NetMask.get_netmask
24
- end
21
+ confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd", :dragonfly ]
22
+ setcode do
23
+ Facter::NetMask.get_netmask
24
+ end
25
25
  end
26
26
 
@@ -13,9 +13,9 @@
13
13
  require 'facter/util/ip'
14
14
 
15
15
  Facter::Util::IP.get_interfaces.each do |interface|
16
- Facter.add("network_" + Facter::Util::IP.alphafy(interface)) do
17
- setcode do
18
- Facter::Util::IP.get_network_value(interface)
19
- end
16
+ Facter.add("network_" + Facter::Util::IP.alphafy(interface)) do
17
+ setcode do
18
+ Facter::Util::IP.get_network_value(interface)
20
19
  end
20
+ end
21
21
  end
@@ -14,83 +14,87 @@
14
14
  require 'facter/lsb'
15
15
 
16
16
  Facter.add(:operatingsystem) do
17
- confine :kernel => :sunos
18
- setcode do "Solaris" end
17
+ confine :kernel => :sunos
18
+ setcode do "Solaris" end
19
19
  end
20
20
 
21
21
  Facter.add(:operatingsystem) do
22
- confine :kernel => :linux
23
- setcode do
24
- if Facter.value(:lsbdistid) == "Ubuntu"
25
- "Ubuntu"
26
- elsif FileTest.exists?("/etc/debian_version")
27
- "Debian"
28
- elsif FileTest.exists?("/etc/gentoo-release")
29
- "Gentoo"
30
- elsif FileTest.exists?("/etc/fedora-release")
31
- "Fedora"
32
- elsif FileTest.exists?("/etc/mandriva-release")
33
- "Mandriva"
34
- elsif FileTest.exists?("/etc/mandrake-release")
35
- "Mandrake"
36
- elsif FileTest.exists?("/etc/meego-release")
37
- "MeeGo"
38
- elsif FileTest.exists?("/etc/arch-release")
39
- "Archlinux"
40
- elsif FileTest.exists?("/etc/oracle-release")
41
- "OracleLinux"
42
- elsif FileTest.exists?("/etc/enterprise-release")
43
- if FileTest.exists?("/etc/ovs-release")
44
- "OVS"
45
- else
46
- "OEL"
47
- end
48
- elsif FileTest.exists?("/etc/arch-release")
49
- "Arch"
50
- elsif FileTest.exists?("/etc/vmware-release")
51
- "VMWareESX"
52
- elsif FileTest.exists?("/etc/redhat-release")
53
- txt = File.read("/etc/redhat-release")
54
- if txt =~ /centos/i
55
- "CentOS"
56
- elsif txt =~ /CERN/
57
- "SLC"
58
- elsif txt =~ /scientific/i
59
- "Scientific"
60
- else
61
- "RedHat"
62
- end
63
- elsif FileTest.exists?("/etc/SuSE-release")
64
- txt = File.read("/etc/SuSE-release")
65
- if txt =~ /^SUSE LINUX Enterprise Server/i
66
- "SLES"
67
- elsif txt =~ /^SUSE LINUX Enterprise Desktop/i
68
- "SLED"
69
- elsif txt =~ /^openSUSE/i
70
- "OpenSuSE"
71
- else
72
- "SuSE"
73
- end
74
- elsif FileTest.exists?("/etc/bluewhite64-version")
75
- "Bluewhite64"
76
- elsif FileTest.exists?("/etc/slamd64-version")
77
- "Slamd64"
78
- elsif FileTest.exists?("/etc/slackware-version")
79
- "Slackware"
80
- elsif FileTest.exists?("/etc/alpine-release")
81
- "Alpine"
82
- end
22
+ confine :kernel => :linux
23
+ setcode do
24
+ if Facter.value(:lsbdistid) == "Ubuntu"
25
+ "Ubuntu"
26
+ elsif FileTest.exists?("/etc/debian_version")
27
+ "Debian"
28
+ elsif FileTest.exists?("/etc/gentoo-release")
29
+ "Gentoo"
30
+ elsif FileTest.exists?("/etc/fedora-release")
31
+ "Fedora"
32
+ elsif FileTest.exists?("/etc/mandriva-release")
33
+ "Mandriva"
34
+ elsif FileTest.exists?("/etc/mandrake-release")
35
+ "Mandrake"
36
+ elsif FileTest.exists?("/etc/meego-release")
37
+ "MeeGo"
38
+ elsif FileTest.exists?("/etc/arch-release")
39
+ "Archlinux"
40
+ elsif FileTest.exists?("/etc/oracle-release")
41
+ "OracleLinux"
42
+ elsif FileTest.exists?("/etc/enterprise-release")
43
+ if FileTest.exists?("/etc/ovs-release")
44
+ "OVS"
45
+ else
46
+ "OEL"
47
+ end
48
+ elsif FileTest.exists?("/etc/arch-release")
49
+ "Arch"
50
+ elsif FileTest.exists?("/etc/vmware-release")
51
+ "VMWareESX"
52
+ elsif FileTest.exists?("/etc/redhat-release")
53
+ txt = File.read("/etc/redhat-release")
54
+ if txt =~ /centos/i
55
+ "CentOS"
56
+ elsif txt =~ /CERN/
57
+ "SLC"
58
+ elsif txt =~ /scientific/i
59
+ "Scientific"
60
+ elsif txt =~ /^cloudlinux/i
61
+ "CloudLinux"
62
+ else
63
+ "RedHat"
64
+ end
65
+ elsif FileTest.exists?("/etc/SuSE-release")
66
+ txt = File.read("/etc/SuSE-release")
67
+ if txt =~ /^SUSE LINUX Enterprise Server/i
68
+ "SLES"
69
+ elsif txt =~ /^SUSE LINUX Enterprise Desktop/i
70
+ "SLED"
71
+ elsif txt =~ /^openSUSE/i
72
+ "OpenSuSE"
73
+ else
74
+ "SuSE"
75
+ end
76
+ elsif FileTest.exists?("/etc/bluewhite64-version")
77
+ "Bluewhite64"
78
+ elsif FileTest.exists?("/etc/slamd64-version")
79
+ "Slamd64"
80
+ elsif FileTest.exists?("/etc/slackware-version")
81
+ "Slackware"
82
+ elsif FileTest.exists?("/etc/alpine-release")
83
+ "Alpine"
84
+ elsif Facter.value(:lsbdistdescription) =~ /Amazon Linux/
85
+ "Amazon"
83
86
  end
87
+ end
84
88
  end
85
89
 
86
90
  Facter.add(:operatingsystem) do
87
- confine :kernel => "VMkernel"
88
- setcode do
89
- "ESXi"
90
- end
91
+ confine :kernel => "VMkernel"
92
+ setcode do
93
+ "ESXi"
94
+ end
91
95
  end
92
96
 
93
97
  Facter.add(:operatingsystem) do
94
- # Default to just returning the kernel as the operating system
95
- setcode do Facter[:kernel].value end
98
+ # Default to just returning the kernel as the operating system
99
+ setcode do Facter[:kernel].value end
96
100
  end
@@ -9,6 +9,7 @@
9
9
  # On Suse, derivatives, parses '/etc/SuSE-release' for a selection of version
10
10
  # information.
11
11
  # On Slackware, parses '/etc/slackware-version'.
12
+ # On Amazon Linux, returns the 'lsbdistrelease' value.
12
13
  #
13
14
  # On all remaining systems, returns the 'kernelrelease' value.
14
15
  #
@@ -16,112 +17,112 @@
16
17
  #
17
18
 
18
19
  Facter.add(:operatingsystemrelease) do
19
- confine :operatingsystem => %w{CentOS Fedora oel ovs OracleLinux RedHat MeeGo Scientific SLC}
20
- setcode do
21
- case Facter.value(:operatingsystem)
22
- when "CentOS", "RedHat", "Scientific", "SLC"
23
- releasefile = "/etc/redhat-release"
24
- when "Fedora"
25
- releasefile = "/etc/fedora-release"
26
- when "MeeGo"
27
- releasefile = "/etc/meego-release"
28
- when "OracleLinux"
29
- releasefile = "/etc/oracle-release"
30
- when "OEL", "oel"
31
- releasefile = "/etc/enterprise-release"
32
- when "OVS", "ovs"
33
- releasefile = "/etc/ovs-release"
34
- end
35
- File::open(releasefile, "r") do |f|
36
- line = f.readline.chomp
37
- if line =~ /\(Rawhide\)$/
38
- "Rawhide"
39
- elsif line =~ /release (\d[\d.]*)/
40
- $1
41
- end
42
- end
20
+ confine :operatingsystem => %w{CentOS Fedora oel ovs OracleLinux RedHat MeeGo Scientific SLC CloudLinux}
21
+ setcode do
22
+ case Facter.value(:operatingsystem)
23
+ when "CentOS", "RedHat", "Scientific", "SLC", "CloudLinux"
24
+ releasefile = "/etc/redhat-release"
25
+ when "Fedora"
26
+ releasefile = "/etc/fedora-release"
27
+ when "MeeGo"
28
+ releasefile = "/etc/meego-release"
29
+ when "OracleLinux"
30
+ releasefile = "/etc/oracle-release"
31
+ when "OEL", "oel"
32
+ releasefile = "/etc/enterprise-release"
33
+ when "OVS", "ovs"
34
+ releasefile = "/etc/ovs-release"
35
+ end
36
+ File::open(releasefile, "r") do |f|
37
+ line = f.readline.chomp
38
+ if line =~ /\(Rawhide\)$/
39
+ "Rawhide"
40
+ elsif line =~ /release (\d[\d.]*)/
41
+ $1
42
+ end
43
43
  end
44
+ end
44
45
  end
45
46
 
46
47
  Facter.add(:operatingsystemrelease) do
47
- confine :operatingsystem => %w{Debian}
48
- setcode do
49
- release = Facter::Util::Resolution.exec('cat /etc/debian_version')
50
- end
48
+ confine :operatingsystem => %w{Debian}
49
+ setcode do
50
+ release = Facter::Util::Resolution.exec('cat /etc/debian_version')
51
+ end
51
52
  end
52
53
 
53
54
  Facter.add(:operatingsystemrelease) do
54
- confine :operatingsystem => %w{Ubuntu}
55
- setcode do
56
- release = Facter::Util::Resolution.exec('cat /etc/issue')
57
- if release =~ /Ubuntu (\d+.\d+)/
58
- $1
59
- end
55
+ confine :operatingsystem => %w{Ubuntu}
56
+ setcode do
57
+ release = Facter::Util::Resolution.exec('cat /etc/issue')
58
+ if release =~ /Ubuntu (\d+.\d+)/
59
+ $1
60
60
  end
61
+ end
61
62
  end
62
63
 
63
64
  Facter.add(:operatingsystemrelease) do
64
- confine :operatingsystem => %w{SLES SLED OpenSuSE}
65
- setcode do
66
- releasefile = Facter::Util::Resolution.exec('cat /etc/SuSE-release')
67
- if releasefile =~ /^VERSION\s*=\s*(\d+)/
68
- releasemajor = $1
69
- if releasefile =~ /^PATCHLEVEL\s*=\s*(\d+)/
70
- releaseminor = $1
71
- elsif releasefile =~ /^VERSION\s=.*.(\d+)/
72
- releaseminor = $1
73
- else
74
- releaseminor = "0"
75
- end
76
- releasemajor + "." + releaseminor
77
- else
78
- "unknown"
79
- end
65
+ confine :operatingsystem => %w{SLES SLED OpenSuSE}
66
+ setcode do
67
+ releasefile = Facter::Util::Resolution.exec('cat /etc/SuSE-release')
68
+ if releasefile =~ /^VERSION\s*=\s*(\d+)/
69
+ releasemajor = $1
70
+ if releasefile =~ /^PATCHLEVEL\s*=\s*(\d+)/
71
+ releaseminor = $1
72
+ elsif releasefile =~ /^VERSION\s=.*.(\d+)/
73
+ releaseminor = $1
74
+ else
75
+ releaseminor = "0"
76
+ end
77
+ releasemajor + "." + releaseminor
78
+ else
79
+ "unknown"
80
80
  end
81
+ end
81
82
  end
82
83
 
83
84
  Facter.add(:operatingsystemrelease) do
84
- confine :operatingsystem => %w{Slackware}
85
- setcode do
86
- release = Facter::Util::Resolution.exec('cat /etc/slackware-version')
87
- if release =~ /Slackware ([0-9.]+)/
88
- $1
89
- end
85
+ confine :operatingsystem => %w{Slackware}
86
+ setcode do
87
+ release = Facter::Util::Resolution.exec('cat /etc/slackware-version')
88
+ if release =~ /Slackware ([0-9.]+)/
89
+ $1
90
90
  end
91
+ end
91
92
  end
92
93
 
93
94
  Facter.add(:operatingsystemrelease) do
94
- confine :operatingsystem => %w{Bluewhite64}
95
- setcode do
96
- releasefile = Facter::Util::Resolution.exec('cat /etc/bluewhite64-version')
97
- if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/
98
- $1 + "." + $2
99
- else
100
- "unknown"
101
- end
95
+ confine :operatingsystem => %w{Bluewhite64}
96
+ setcode do
97
+ releasefile = Facter::Util::Resolution.exec('cat /etc/bluewhite64-version')
98
+ if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/
99
+ $1 + "." + $2
100
+ else
101
+ "unknown"
102
102
  end
103
+ end
103
104
  end
104
105
 
105
106
  Facter.add(:operatingsystemrelease) do
106
- confine :operatingsystem => %w{VMwareESX}
107
- setcode do
108
- release = Facter::Util::Resolution.exec('vmware -v')
109
- if release =~ /VMware ESX .*?(\d.*)/
110
- $1
111
- end
107
+ confine :operatingsystem => %w{VMwareESX}
108
+ setcode do
109
+ release = Facter::Util::Resolution.exec('vmware -v')
110
+ if release =~ /VMware ESX .*?(\d.*)/
111
+ $1
112
112
  end
113
+ end
113
114
  end
114
115
 
115
116
  Facter.add(:operatingsystemrelease) do
116
- confine :operatingsystem => %w{Slamd64}
117
- setcode do
118
- releasefile = Facter::Util::Resolution.exec('cat /etc/slamd64-version')
119
- if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/
120
- $1 + "." + $2
121
- else
122
- "unknown"
123
- end
117
+ confine :operatingsystem => %w{Slamd64}
118
+ setcode do
119
+ releasefile = Facter::Util::Resolution.exec('cat /etc/slamd64-version')
120
+ if releasefile =~ /^\s*\w+\s+(\d+)\.(\d+)/
121
+ $1 + "." + $2
122
+ else
123
+ "unknown"
124
124
  end
125
+ end
125
126
  end
126
127
 
127
128
  Facter.add(:operatingsystemrelease) do
@@ -132,5 +133,10 @@ Facter.add(:operatingsystemrelease) do
132
133
  end
133
134
 
134
135
  Facter.add(:operatingsystemrelease) do
135
- setcode do Facter[:kernelrelease].value end
136
+ confine :operatingsystem => %W{Amazon}
137
+ setcode do Facter[:lsbdistrelease].value end
138
+ end
139
+
140
+ Facter.add(:operatingsystemrelease) do
141
+ setcode do Facter[:kernelrelease].value end
136
142
  end
@@ -0,0 +1,31 @@
1
+ # Fact: osfamily
2
+ #
3
+ # Purpose: Returns the operating system
4
+ #
5
+ # Resolution:
6
+ # Maps operating systems to operating system families, such as linux
7
+ # distribution derivatives. Adds mappings from specific operating systems
8
+ # to kernels in the case that it is relevant.
9
+ #
10
+ # Caveats:
11
+ # This fact is completely reliant on the operatingsystem fact, and no
12
+ # heuristics are used
13
+ #
14
+
15
+ Facter.add(:osfamily) do
16
+
17
+ setcode do
18
+ case Facter.value(:operatingsystem)
19
+ when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "CloudLinux", "OracleLinux", "OVS", "OEL"
20
+ "RedHat"
21
+ when "Ubuntu", "Debian"
22
+ "Debian"
23
+ when "SLES", "SLED", "OpenSuSE", "SuSE"
24
+ "Suse"
25
+ when "Solaris"
26
+ "Solaris"
27
+ else
28
+ Facter.value("kernel")
29
+ end
30
+ end
31
+ end
@@ -8,7 +8,7 @@
8
8
  #
9
9
 
10
10
  Facter.add(:path) do
11
- setcode do
12
- ENV['PATH']
13
- end
11
+ setcode do
12
+ ENV['PATH']
13
+ end
14
14
  end
@@ -62,3 +62,11 @@ Facter.add('physicalprocessorcount') do
62
62
  Facter::Util::WMI.execquery("select Name from Win32_Processor").Count
63
63
  end
64
64
  end
65
+
66
+ Facter.add('physicalprocessorcount') do
67
+ confine :kernel => :sunos
68
+
69
+ setcode do
70
+ Facter::Util::Resolution.exec("/usr/sbin/psrinfo -p")
71
+ end
72
+ end