facter 2.2.0-universal-darwin → 2.3.0-universal-darwin

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 (50) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +4 -0
  3. data/Gemfile +2 -1
  4. data/LICENSE +1 -1
  5. data/ext/project_data.yaml +2 -2
  6. data/lib/facter/ec2.rb +2 -2
  7. data/lib/facter/gid.rb +10 -1
  8. data/lib/facter/interfaces.rb +2 -0
  9. data/lib/facter/ipaddress6.rb +1 -1
  10. data/lib/facter/ldom.rb +4 -1
  11. data/lib/facter/macosx.rb +2 -2
  12. data/lib/facter/operatingsystem/linux.rb +13 -1
  13. data/lib/facter/operatingsystem/sunos.rb +1 -1
  14. data/lib/facter/operatingsystem/windows.rb +7 -0
  15. data/lib/facter/physicalprocessorcount.rb +1 -1
  16. data/lib/facter/processor.rb +3 -3
  17. data/lib/facter/processors/os.rb +11 -1
  18. data/lib/facter/rackspace.rb +8 -5
  19. data/lib/facter/rubyplatform.rb +12 -0
  20. data/lib/facter/selinux.rb +9 -9
  21. data/lib/facter/system32.rb +21 -0
  22. data/lib/facter/util/macosx.rb +1 -1
  23. data/lib/facter/util/parser.rb +12 -2
  24. data/lib/facter/util/uptime.rb +1 -1
  25. data/lib/facter/util/virtual.rb +13 -2
  26. data/lib/facter/version.rb +1 -1
  27. data/lib/facter/virtual.rb +5 -3
  28. data/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces_and_fe80 +19 -0
  29. data/spec/fixtures/ifconfig/linux_ifconfig_all_with_multiple_interfaces_and_no_public_ipv6 +18 -0
  30. data/spec/schema/validate_facter_schema.rb +18 -0
  31. data/spec/unit/ec2_spec.rb +18 -6
  32. data/spec/unit/gid_spec.rb +22 -2
  33. data/spec/unit/interfaces_spec.rb +2 -2
  34. data/spec/unit/ipaddress6_spec.rb +24 -6
  35. data/spec/unit/ldom_spec.rb +13 -0
  36. data/spec/unit/operatingsystem/linux_spec.rb +22 -10
  37. data/spec/unit/operatingsystem/sunos_spec.rb +3 -3
  38. data/spec/unit/operatingsystem/windows_spec.rb +21 -0
  39. data/spec/unit/physicalprocessorcount_spec.rb +1 -1
  40. data/spec/unit/processor_spec.rb +1 -1
  41. data/spec/unit/processors/os_spec.rb +15 -1
  42. data/spec/unit/rackspace_spec.rb +3 -3
  43. data/spec/unit/rubyplatform_spec.rb +7 -0
  44. data/spec/unit/selinux_spec.rb +5 -5
  45. data/spec/unit/system32_spec.rb +28 -0
  46. data/spec/unit/util/macosx_spec.rb +1 -1
  47. data/spec/unit/util/parser_spec.rb +36 -3
  48. data/spec/unit/util/uptime_spec.rb +2 -2
  49. data/spec/unit/virtual_spec.rb +52 -26
  50. metadata +645 -637
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b2c0985b323f31e0a1943587d1a9497faa7a842
4
+ data.tar.gz: a457fa67406bccc73cdcce5e2d07d34bbf13972c
5
+ SHA512:
6
+ metadata.gz: 73e5e44d1a95d360ba6084ca7c86bdc3f8dee3e5605ecb1bb1084e8e271c45acddc5553e8dc68286fd52cebbcd86a7d871a4a73073e54a3319427fe92bb3fa91
7
+ data.tar.gz: fa0b5aa29d8f3ab748b2585ba1d00dc691896c9557fae4ffc6d74026d7f8e8e18d2a560ae4b8593c4acb8c2c28b3620c037c690d0a09b56de9709856cbc26aa0
@@ -16,6 +16,10 @@ top of things.
16
16
  * Make sure you fill in the earliest version that you know has the issue.
17
17
  * Fork the repository on GitHub
18
18
 
19
+ ## New Facts
20
+
21
+ All new facts should also be included in `schema/facter.json`. Without this facts won't pass acceptance tests.
22
+
19
23
  ## Making Changes
20
24
 
21
25
  * Create a topic branch from where you want to base your work.
data/Gemfile CHANGED
@@ -13,6 +13,7 @@ group :development, :test do
13
13
  gem 'rspec', "~> 2.11.0"
14
14
  gem 'mocha', "~> 0.10.5"
15
15
  gem 'json', "~> 1.7", :platforms => :ruby
16
+ gem 'json-schema', :platforms => :ruby
16
17
  gem 'puppetlabs_spec_helper'
17
18
  end
18
19
 
@@ -39,7 +40,7 @@ mingw = [:mingw]
39
40
  mingw << :x64_mingw if Bundler::Dsl::VALID_PLATFORMS.include?(:x64_mingw)
40
41
 
41
42
  platform(*mingw) do
42
- gem 'ffi', '~> 1.9.3', :require => false
43
+ gem 'ffi', '~> 1.9.5', :require => false
43
44
  gem 'win32-dir', '~> 0.4.8', :require => false
44
45
  gem 'win32-security', '~> 0.2.5', :require => false
45
46
  end
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Facter - Host Fact Detection and Reporting
2
2
 
3
- Copyright 2005-2012 Puppet Labs Inc
3
+ Copyright 2005-2014 Puppet Labs Inc
4
4
 
5
5
  Licensed under the Apache License, Version 2.0 (the "License");
6
6
  you may not use this file except in compliance with the License.
@@ -19,13 +19,13 @@ gem_platform_dependencies:
19
19
  CFPropertyList: '~> 2.2.6'
20
20
  x86-mingw32:
21
21
  gem_runtime_dependencies:
22
- ffi: '~> 1.9.3'
22
+ ffi: '~> 1.9.5'
23
23
  win32-dir: '~> 0.4.8'
24
24
  win32-security: '~> 0.2.5'
25
25
  win32console: '~> 1.3.2'
26
26
  x64-mingw32:
27
27
  gem_runtime_dependencies:
28
- ffi: '~> 1.9.3'
28
+ ffi: '~> 1.9.5'
29
29
  win32-dir: '~> 0.4.8'
30
30
  win32-security: '~> 0.2.5'
31
31
  bundle_platforms:
@@ -20,7 +20,7 @@ require 'facter/ec2/rest'
20
20
  Facter.define_fact(:ec2_metadata) do
21
21
  define_resolution(:rest) do
22
22
  confine do
23
- Facter.value(:virtual).match /^xen/
23
+ Facter.value(:virtual).match /^(xen|kvm)/
24
24
  end
25
25
 
26
26
  @querier = Facter::EC2::Metadata.new
@@ -37,7 +37,7 @@ end
37
37
  Facter.define_fact(:ec2_userdata) do
38
38
  define_resolution(:rest) do
39
39
  confine do
40
- Facter.value(:virtual).match /^xen/
40
+ Facter.value(:virtual).match /^(xen|kvm)/
41
41
  end
42
42
 
43
43
  @querier = Facter::EC2::Userdata.new
@@ -10,7 +10,16 @@
10
10
 
11
11
  Facter.add(:gid) do
12
12
  confine do
13
- Facter::Core::Execution.which('id')
13
+ Facter::Core::Execution.which('id') && Facter.value(:kernel) != "SunOS"
14
14
  end
15
15
  setcode { Facter::Core::Execution.exec('id -ng') }
16
16
  end
17
+
18
+ Facter.add(:gid) do
19
+ confine :kernel => :SunOS
20
+ setcode do
21
+ if File.exist? '/usr/xpg4/bin/id'
22
+ Facter::Core::Execution.exec('/usr/xpg4/bin/id -ng')
23
+ end
24
+ end
25
+ end
@@ -41,6 +41,8 @@ Facter::Util::IP.get_interfaces.each do |interface|
41
41
  value = Facter::Util::IP.get_interface_value(interface, label)
42
42
  if label == "macaddress"
43
43
  value = Facter::Util::Macaddress.standardize(value)
44
+ elsif label == "mtu"
45
+ value = value.to_i
44
46
  end
45
47
  value
46
48
  end
@@ -28,7 +28,7 @@ def get_address_after_token(output, token, return_first=false)
28
28
 
29
29
  String(output).scan(/#{token}\s?((?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/).each do |match|
30
30
  match = match.first
31
- unless match =~ /fe80.*/ or match == "::1"
31
+ unless match =~ /^fe80.*/ or match == "::1"
32
32
  ip = match
33
33
  break if return_first
34
34
  end
@@ -9,7 +9,10 @@
9
9
  # Uses the output of `virtinfo -ap`.
10
10
  #
11
11
 
12
- if Facter.value(:kernel) == 'SunOS' and Facter::Core::Execution.which('virtinfo')
12
+ if Facter.value(:kernel) == 'SunOS' &&
13
+ Facter.value(:hardwareisa) == 'sparc' &&
14
+ Facter::Core::Execution.which('virtinfo')
15
+
13
16
  virtinfo = Facter::Core::Execution.exec('virtinfo -ap')
14
17
 
15
18
  # Convert virtinfo parseable output format to array of arrays.
@@ -31,7 +31,7 @@ if Facter.value(:kernel) == "Darwin"
31
31
  Facter.add("sp_#{fact}") do
32
32
  confine :kernel => :darwin
33
33
  setcode do
34
- value.to_s
34
+ value
35
35
  end
36
36
  end
37
37
  end
@@ -40,7 +40,7 @@ if Facter.value(:kernel) == "Darwin"
40
40
  Facter.add("sp_#{fact}") do
41
41
  confine :kernel => :darwin
42
42
  setcode do
43
- value.to_s
43
+ value
44
44
  end
45
45
  end
46
46
  end
@@ -31,7 +31,7 @@ module Facter
31
31
  "Suse"
32
32
  when "Gentoo"
33
33
  "Gentoo"
34
- when "Archlinux"
34
+ when "Archlinux", "Manjarolinux"
35
35
  "Archlinux"
36
36
  when "Mageia", "Mandriva", "Mandrake"
37
37
  "Mandrake"
@@ -46,6 +46,8 @@ module Facter
46
46
  get_alpine_release_with_release_file
47
47
  when "Amazon"
48
48
  get_amazon_release_with_lsb
49
+ when "AristaEOS"
50
+ get_arista_release_with_release_file
49
51
  when "BlueWhite64"
50
52
  get_bluewhite_release_with_release_file
51
53
  when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM",
@@ -239,6 +241,7 @@ module Facter
239
241
  def get_operatingsystem_with_release_files
240
242
  operatingsystem = nil
241
243
  release_files = {
244
+ "AristaEOS" => "/etc/Eos-release",
242
245
  "Debian" => "/etc/debian_version",
243
246
  "Gentoo" => "/etc/gentoo-release",
244
247
  "Fedora" => "/etc/fedora-release",
@@ -247,6 +250,7 @@ module Facter
247
250
  "Mandrake" => "/etc/mandrake-release",
248
251
  "MeeGo" => "/etc/meego-release",
249
252
  "Archlinux" => "/etc/arch-release",
253
+ "Manjarolinux"=> "/etc/manjaro-release",
250
254
  "OracleLinux" => "/etc/oracle-release",
251
255
  "OpenWrt" => "/etc/openwrt_release",
252
256
  "Alpine" => "/etc/alpine-release",
@@ -345,6 +349,14 @@ module Facter
345
349
  end
346
350
  end
347
351
 
352
+ def get_arista_release_with_release_file
353
+ if release = Facter::Util::FileRead.read('/etc/Eos-release')
354
+ if match = /\d+\.\d+(:?\.\d+)?[A-M]?$/.match(release)
355
+ match[0]
356
+ end
357
+ end
358
+ end
359
+
348
360
  def get_amazon_release_with_lsb
349
361
  if lsbdistrelease = get_lsbdistrelease
350
362
  lsbdistrelease
@@ -42,7 +42,7 @@ module Facter
42
42
  end
43
43
  end
44
44
 
45
- def get_operatingsystemmajrelease
45
+ def get_operatingsystemmajorrelease
46
46
  if get_operatingsystem == "Solaris"
47
47
  if match = get_operatingsystemrelease.match(/^(\d+)/)
48
48
  match.captures[0]
@@ -9,6 +9,13 @@ module Facter
9
9
  Facter::Util::WMI.execquery("SELECT version, producttype FROM Win32_OperatingSystem").each do |os|
10
10
  result =
11
11
  case os.version
12
+ when /^6\.4/
13
+ # As of October 2014, there are no Win server releases with kernel 6.4.x.
14
+ # This case prevents future releases from resolving to nil before we
15
+ # can update the fact regexes.
16
+ os.producttype == 1 ? "10" : Facter[:kernelrelease].value
17
+ when /^6\.3/
18
+ os.producttype == 1 ? "8.1" : "2012 R2"
12
19
  when /^6\.2/
13
20
  os.producttype == 1 ? "8" : "2012"
14
21
  when /^6\.1/
@@ -19,7 +19,7 @@ Facter.add('physicalprocessorcount') do
19
19
  setcode do
20
20
  processors = Facter.value(:processors)
21
21
  if (physicalprocessorcount = processors["physicalcount"])
22
- physicalprocessorcount.to_s
22
+ physicalprocessorcount
23
23
  else
24
24
  nil
25
25
  end
@@ -4,8 +4,8 @@
4
4
  # Additional Facts about the machine's CPUs.
5
5
  #
6
6
  # Resolution:
7
- # Utilizes values from the processors structured fact, which itself
8
- # uses various methods to collect CPU information, with implementation
7
+ # Utilizes values from the processors structured fact, which itself
8
+ # uses various methods to collect CPU information, with implementation
9
9
  # dependent upon the OS of the system in question.
10
10
  #
11
11
  # Caveats:
@@ -37,7 +37,7 @@ Facter.add("ProcessorCount") do
37
37
 
38
38
  setcode do
39
39
  if (processorcount = processors["count"])
40
- processorcount.to_s
40
+ processorcount
41
41
  else
42
42
  nil
43
43
  end
@@ -159,7 +159,7 @@ module Facter
159
159
  private
160
160
 
161
161
  def query_system_profiler
162
- output = Facter::Core::Execution.exec("/usr/sbin/system_profiler -xml SPHardwareDataType")
162
+ output = Facter::Core::Execution.exec("/usr/sbin/system_profiler -xml SPHardwareDataType 2>/dev/null")
163
163
  plist = CFPropertyList::List.new
164
164
  plist.load_str(output)
165
165
  parsed_xml = CFPropertyList.native_types(plist.value)
@@ -177,6 +177,16 @@ module Facter
177
177
  def get_physical_processor_count
178
178
  Facter::Util::POSIX.sysctl("hw.ncpufound").to_i
179
179
  end
180
+
181
+ def get_processor_speed
182
+ speed = Facter::Util::POSIX.sysctl("hw.cpuspeed").to_i
183
+ if speed < 1000
184
+ "#{speed} MHz"
185
+ else
186
+ speed = speed.to_f / 1000
187
+ "#{(speed * 100).round.to_f / 100.0} GHz"
188
+ end
189
+ end
180
190
  end
181
191
 
182
192
  class SunOS < Base
@@ -1,15 +1,18 @@
1
- # Purpose: Determine information about Rackspace cloud instances
1
+ # Fact: rsc_<RACKSPACE INSTANCE DATA>
2
+ #
3
+ # Purpose: Determine information about Rackspace cloud instances.
2
4
  #
3
5
  # Resolution:
4
- # If this is a Rackspace Cloud instance, populates rsc_ facts
6
+ # If this is a Rackspace Cloud instance, populates `rsc_` facts: `is_rsc`, `rsc_region`,
7
+ # and `rsc_instance_id`.
5
8
  #
6
9
  # Caveats:
7
- # Depends on Xenstore
10
+ # Depends on Xenstore.
8
11
  #
9
12
 
10
13
  Facter.add(:is_rsc) do
11
14
  setcode do
12
- result = Facter::Util::Resolution.exec("/usr/bin/xenstore-read vm-data/provider_data/provider")
15
+ result = Facter::Util::Resolution.exec("/usr/bin/xenstore-read vm-data/provider_data/provider 2> /dev/null")
13
16
  if result == "Rackspace"
14
17
  "true"
15
18
  end
@@ -19,7 +22,7 @@ end
19
22
  Facter.add(:rsc_region) do
20
23
  confine :is_rsc => "true"
21
24
  setcode do
22
- Facter::Util::Resolution.exec("/usr/bin/xenstore-read vm-data/provider_data/region")
25
+ Facter::Util::Resolution.exec("/usr/bin/xenstore-read vm-data/provider_data/region 2> /dev/null")
23
26
  end
24
27
  end
25
28
 
@@ -0,0 +1,12 @@
1
+ # Fact: rubyplatform
2
+ #
3
+ # Purpose: Returns the platform of Ruby that facter is running under.
4
+ #
5
+ # Resolution: Returns the value of the `RUBY_PLATFORM` constant.
6
+ #
7
+ # Caveats:
8
+ #
9
+
10
+ Facter.add(:rubyplatform) do
11
+ setcode { RUBY_PLATFORM.to_s }
12
+ end
@@ -85,12 +85,12 @@ end
85
85
  Facter.add("selinux") do
86
86
  confine :kernel => :linux
87
87
  setcode do
88
- result = "false"
88
+ result = false
89
89
  if FileTest.exists?("#{selinux_mount_point}/enforce")
90
90
  if FileTest.exists?("/proc/self/attr/current")
91
91
  begin
92
92
  if (File.read("/proc/self/attr/current") != "kernel\0")
93
- result = "true"
93
+ result = true
94
94
  end
95
95
  rescue
96
96
  end
@@ -101,19 +101,19 @@ Facter.add("selinux") do
101
101
  end
102
102
 
103
103
  Facter.add("selinux_enforced") do
104
- confine :selinux => :true
104
+ confine :selinux => true
105
105
  setcode do
106
- result = "false"
106
+ result = false
107
107
  if FileTest.exists?("#{selinux_mount_point}/enforce") and
108
108
  File.read("#{selinux_mount_point}/enforce") =~ /1/i
109
- result = "true"
109
+ result = true
110
110
  end
111
111
  result
112
112
  end
113
113
  end
114
114
 
115
115
  Facter.add("selinux_policyversion") do
116
- confine :selinux => :true
116
+ confine :selinux => true
117
117
  setcode do
118
118
  result = 'unknown'
119
119
  if FileTest.exists?("#{selinux_mount_point}/policyvers")
@@ -124,7 +124,7 @@ Facter.add("selinux_policyversion") do
124
124
  end
125
125
 
126
126
  Facter.add("selinux_current_mode") do
127
- confine :selinux => :true
127
+ confine :selinux => true
128
128
  setcode do
129
129
  result = 'unknown'
130
130
  mode = Facter::Core::Execution.exec(sestatus_cmd)
@@ -134,7 +134,7 @@ Facter.add("selinux_current_mode") do
134
134
  end
135
135
 
136
136
  Facter.add("selinux_config_mode") do
137
- confine :selinux => :true
137
+ confine :selinux => true
138
138
  setcode do
139
139
  result = 'unknown'
140
140
  mode = Facter::Core::Execution.exec(sestatus_cmd)
@@ -144,7 +144,7 @@ Facter.add("selinux_config_mode") do
144
144
  end
145
145
 
146
146
  Facter.add("selinux_config_policy") do
147
- confine :selinux => :true
147
+ confine :selinux => true
148
148
  setcode do
149
149
  result = 'unknown'
150
150
  mode = Facter::Core::Execution.exec(sestatus_cmd)
@@ -0,0 +1,21 @@
1
+ # Fact: system32
2
+ #
3
+ # Purpose: Returns the directory of the native system32 directory.
4
+ # For 32-bit ruby on 32-bit Windows, typically: 'C:\Windows\system32'.
5
+ # For 32-bit ruby on 64-bit Windows, typically: 'C:\Windows\sysnative'.
6
+ # For 64-bit ruby on 64-bit Windows, typically: 'C:\Windows\system32'.
7
+ #
8
+ # Resolution: Checks for the existence of the `sysnative` directory, otherwise
9
+ # uses `system32`
10
+ #
11
+
12
+ Facter.add(:system32) do
13
+ confine :kernel => :windows
14
+ setcode do
15
+ if File.exists?("#{ENV['SYSTEMROOT']}\\sysnative")
16
+ "#{ENV['SYSTEMROOT']}\\sysnative"
17
+ else
18
+ "#{ENV['SYSTEMROOT']}\\system32"
19
+ end
20
+ end
21
+ end
@@ -15,7 +15,7 @@ module Facter::Util::Macosx
15
15
  # by looking at the _name key of the _items dict for each _dataType
16
16
 
17
17
  def self.profiler_xml(data_field)
18
- Facter::Core::Execution.exec("/usr/sbin/system_profiler -xml #{data_field}")
18
+ Facter::Core::Execution.exec("/usr/sbin/system_profiler -xml #{data_field} 2>/dev/null")
19
19
  end
20
20
 
21
21
  def self.intern_xml(xml)
@@ -139,8 +139,18 @@ module Facter::Util::Parser
139
139
  class PowershellParser < Base
140
140
  # Returns a hash of facts from powershell output
141
141
  def parse_results
142
- shell_command = "powershell -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File \"#{filename}\""
143
- KeyValuePairOutputFormat.parse Facter::Core::Execution.exec(shell_command)
142
+ powershell =
143
+ if File.exists?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe")
144
+ "#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe"
145
+ elsif File.exists?("#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe")
146
+ "#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe"
147
+ else
148
+ 'powershell.exe'
149
+ end
150
+
151
+ shell_command = "\"#{powershell}\" -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File \"#{filename}\""
152
+ output = Facter::Core::Execution.exec(shell_command)
153
+ KeyValuePairOutputFormat.parse(output)
144
154
  end
145
155
  end
146
156
 
@@ -77,6 +77,6 @@ module Facter::Util::Uptime
77
77
  end
78
78
 
79
79
  def self.uptime_executable_cmd
80
- "uptime"
80
+ "/usr/bin/uptime"
81
81
  end
82
82
  end