facter 4.7.0 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/facter/config.rb +4 -2
  3. data/lib/facter/custom_facts/core/aggregate.rb +5 -1
  4. data/lib/facter/custom_facts/util/confine.rb +4 -2
  5. data/lib/facter/facts/archlinux/os/release.rb +21 -0
  6. data/lib/facter/facts/azurelinux/os/release.rb +35 -0
  7. data/lib/facter/facts/linux/processors/extensions.rb +16 -0
  8. data/lib/facter/framework/core/file_loader.rb +8 -0
  9. data/lib/facter/framework/detector/os_detector.rb +1 -0
  10. data/lib/facter/framework/logging/logger.rb +3 -2
  11. data/lib/facter/resolvers/aix/mountpoints.rb +7 -2
  12. data/lib/facter/resolvers/az.rb +1 -1
  13. data/lib/facter/resolvers/base_resolver.rb +3 -2
  14. data/lib/facter/resolvers/bsd/processors.rb +0 -1
  15. data/lib/facter/resolvers/containers.rb +38 -18
  16. data/lib/facter/resolvers/disks.rb +0 -2
  17. data/lib/facter/resolvers/dmi.rb +0 -2
  18. data/lib/facter/resolvers/ec2.rb +1 -1
  19. data/lib/facter/resolvers/filesystems.rb +0 -2
  20. data/lib/facter/resolvers/fips_enabled.rb +0 -2
  21. data/lib/facter/resolvers/freebsd/processors.rb +0 -1
  22. data/lib/facter/resolvers/gce.rb +1 -1
  23. data/lib/facter/resolvers/hostname.rb +5 -0
  24. data/lib/facter/resolvers/identity.rb +0 -2
  25. data/lib/facter/resolvers/macosx/mountpoints.rb +0 -2
  26. data/lib/facter/resolvers/memory.rb +0 -2
  27. data/lib/facter/resolvers/mountpoints.rb +0 -2
  28. data/lib/facter/resolvers/os_release.rb +2 -0
  29. data/lib/facter/resolvers/processors.rb +22 -2
  30. data/lib/facter/resolvers/solaris/mountpoints.rb +0 -2
  31. data/lib/facter/resolvers/solaris/networking.rb +0 -1
  32. data/lib/facter/resolvers/ssh.rb +0 -2
  33. data/lib/facter/resolvers/windows/dmi_bios.rb +0 -1
  34. data/lib/facter/resolvers/windows/dmi_computersystem.rb +0 -1
  35. data/lib/facter/resolvers/windows/hardware_architecture.rb +0 -1
  36. data/lib/facter/resolvers/windows/identity.rb +0 -1
  37. data/lib/facter/resolvers/windows/kernel.rb +0 -2
  38. data/lib/facter/resolvers/windows/memory.rb +0 -2
  39. data/lib/facter/resolvers/windows/networking.rb +0 -1
  40. data/lib/facter/resolvers/windows/ssh.rb +0 -2
  41. data/lib/facter/resolvers/windows/system32.rb +0 -2
  42. data/lib/facter/resolvers/windows/timezone.rb +0 -1
  43. data/lib/facter/resolvers/windows/uptime.rb +0 -2
  44. data/lib/facter/resolvers/windows/virtualization.rb +9 -4
  45. data/lib/facter/resolvers/windows/win_os_description.rb +0 -2
  46. data/lib/facter/resolvers/xen.rb +2 -0
  47. data/lib/facter/templates/man.erb +5 -2
  48. data/lib/facter/util/facts/facts_utils.rb +1 -1
  49. data/lib/facter/util/file_helper.rb +4 -2
  50. data/lib/facter/util/linux/proc.rb +21 -0
  51. data/lib/facter/util/resolvers/http.rb +31 -20
  52. data/lib/facter/version.rb +1 -1
  53. metadata +32 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 101e10975c853baea839c1f0b5afc9d409f85df720a581d2987cf61cb50101af
4
- data.tar.gz: 828a50d3cf221d2bec58e90400684d25c9adff0b3fe93c39535e1136dc628e34
3
+ metadata.gz: a1b586ac7fd5ca2a0dbba3e314510199c246eeafcf3238d4450429c07662e2ac
4
+ data.tar.gz: a3dbb666fd7d0168042df86ba3f85bd5d487a85ed348bf71fc3e0ec2f397a347
5
5
  SHA512:
6
- metadata.gz: 4d367e6d5b5b248767d77464e02f99951219bdd99108990fb2b4af0724c769f9dba18073e382ba244b81413d486547a284ae949779f31a2a0a5299d1b7a448cf
7
- data.tar.gz: af8d6958c1cc05eb883fc5479c863c6613fb49737ea38c251cb7facd3c05ab6c57990334f419604b3102a05736182756daed55492c5644c849c3f71e1d7acd76
6
+ metadata.gz: 2580f1bb8294a6de8e89402244448362f1657d31db3d9d4d2dba551e103848a5285983fd9f57693d4afc2ea6fd6678d97889490e82c8542d125bddb917fd7c58
7
+ data.tar.gz: 8c26e42de115a8b5f3bef1b045b8aff8c18b3f28ab1ca431ea7225f71a97114f7bfaddbc9b9d5ebed7c92225a045d225582cd0d667740ab6beabdcad2c1613da
data/lib/facter/config.rb CHANGED
@@ -26,6 +26,8 @@ module Facter
26
26
  Meego
27
27
  Oel
28
28
  Ovs
29
+ Mariner
30
+ Azurelinux
29
31
  ]
30
32
  },
31
33
  {
@@ -34,13 +36,13 @@ module Facter
34
36
  Sled
35
37
  ]
36
38
  },
39
+ 'Archlinux',
37
40
  'Gentoo',
38
41
  'Alpine',
39
42
  'Photon',
40
43
  'Slackware',
41
44
  'Mageia',
42
- 'Openwrt',
43
- 'Mariner'
45
+ 'Openwrt'
44
46
  ]
45
47
  },
46
48
  {
@@ -109,7 +109,7 @@ module Facter
109
109
  # @api private
110
110
  def evaluate(&block)
111
111
  if @last_evaluated
112
- msg = "Already evaluated #{@name}"
112
+ msg = +"Already evaluated #{@name}"
113
113
  msg << " at #{@last_evaluated}" if msg.is_a? String
114
114
  msg << ', reevaluating anyways'
115
115
  log.warn msg
@@ -197,6 +197,10 @@ module Facter
197
197
 
198
198
  private
199
199
 
200
+ def log
201
+ @log ||= Facter::Log.new(self)
202
+ end
203
+
200
204
  def evaluate_params(name)
201
205
  raise ArgumentError, "#{self.class.name}#chunk requires a block" unless block_given?
202
206
  raise ArgumentError, "#{self.class.name}#expected chunk name to be a Symbol" unless name.is_a? Symbol
@@ -35,7 +35,7 @@ module LegacyFacter
35
35
  end
36
36
 
37
37
  # Evaluate the fact, returning true or false.
38
- # if we have a block paramter then we only evaluate that instead
38
+ # if we have a block parameter then we only evaluate that instead
39
39
  def true?
40
40
  if @block && !@fact
41
41
  begin
@@ -54,9 +54,11 @@ module LegacyFacter
54
54
 
55
55
  return false if value.nil?
56
56
 
57
+ # We call the block with both the downcased and raw fact value for
58
+ # backwards-compatibility.
57
59
  if @block
58
60
  begin
59
- return !!@block.call(value)
61
+ return !!@block.call(value) || !!@block.call(fact.value) # rubocop:disable Style/DoubleNegation
60
62
  rescue StandardError => e
61
63
  log.debug "Confine raised #{e.class} #{e}"
62
64
  return false
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Archlinux
5
+ module Os
6
+ class Release
7
+ FACT_NAME = 'os.release'
8
+
9
+ def call_the_resolver
10
+ # Arch Linux is rolling release and has no version numbers
11
+ # For historical reasons facter used the kernel version as OS version on Arch Linux
12
+ kernelrelease = Facter::Resolvers::Uname.resolve(:kernelrelease)
13
+ versions = kernelrelease.split('.')
14
+ hash = { full: kernelrelease, major: versions[0], minor: versions[1] }
15
+
16
+ Facter::ResolvedFact.new(FACT_NAME, hash)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Azurelinux
5
+ module Os
6
+ class Release
7
+ FACT_NAME = 'os.release'
8
+ ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
9
+
10
+ def call_the_resolver
11
+ version = from_specific_file || from_os_release
12
+
13
+ return Facter::ResolvedFact.new(FACT_NAME, nil) unless version
14
+
15
+ [Facter::ResolvedFact.new(FACT_NAME, version),
16
+ Facter::ResolvedFact.new(ALIASES.first, version['major'], :legacy),
17
+ Facter::ResolvedFact.new(ALIASES.last, version['full'], :legacy)]
18
+ end
19
+
20
+ def from_specific_file
21
+ version = Facter::Resolvers::SpecificReleaseFile.resolve(:release,
22
+ { release_file: '/etc/azurelinux-release',
23
+ regex: /AZURELINUX_BUILD_NUMBER=([0-9.]+)/ })
24
+ Facter::Util::Facts.release_hash_from_matchdata(version)
25
+ end
26
+
27
+ def from_os_release
28
+ version = Facter::Resolvers::OsRelease.resolve(:version_id)
29
+
30
+ Facter::Util::Facts.release_hash_from_string(version)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Linux
5
+ module Processors
6
+ class Extensions
7
+ FACT_NAME = 'processors.extensions'
8
+
9
+ def call_the_resolver
10
+ fact_value = Facter::Resolvers::Linux::Processors.resolve(:extensions)
11
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -246,6 +246,12 @@ os_hierarchy.each do |os|
246
246
 
247
247
  require_relative '../../resolvers/amzn/os_release_rpm'
248
248
 
249
+ when 'archlinux'
250
+ require_relative '../../facts/archlinux/os/release'
251
+
252
+ when 'azurelinux'
253
+ require_relative '../../facts/azurelinux/os/release'
254
+
249
255
  when 'bsd'
250
256
  require_relative '../../facts/bsd/kernelmajversion'
251
257
  require_relative '../../facts/bsd/kernelversion'
@@ -372,6 +378,7 @@ os_hierarchy.each do |os|
372
378
  when 'linux'
373
379
  require_relative '../../util/linux/dhcp'
374
380
  require_relative '../../util/linux/if_inet6'
381
+ require_relative '../../util/linux/proc'
375
382
  require_relative '../../util/linux/routing_table'
376
383
  require_relative '../../util/linux/socket_parser'
377
384
 
@@ -482,6 +489,7 @@ os_hierarchy.each do |os|
482
489
  require_relative '../../facts/linux/processor'
483
490
  require_relative '../../facts/linux/processors/cores'
484
491
  require_relative '../../facts/linux/processors/count'
492
+ require_relative '../../facts/linux/processors/extensions'
485
493
  require_relative '../../facts/linux/processors/isa'
486
494
  require_relative '../../facts/linux/processors/models'
487
495
  require_relative '../../facts/linux/processors/physicalcount'
@@ -68,6 +68,7 @@ class OsDetector
68
68
 
69
69
  def detect_based_on_release_file
70
70
  @identifier = :devuan if File.readable?('/etc/devuan_version')
71
+ @identifier = :archlinux if File.readable?('/etc/arch-release')
71
72
  end
72
73
 
73
74
  def detect_distro
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logger'
4
+ require 'set'
4
5
 
5
6
  module Facter
6
7
  RED = "\e[31m"
@@ -15,8 +16,8 @@ module Facter
15
16
  @@logger = nil
16
17
  @@message_callback = nil
17
18
  @@has_errors = false
18
- @@debug_messages = []
19
- @@warn_messages = []
19
+ @@debug_messages = Set.new
20
+ @@warn_messages = Set.new
20
21
  @@timing = false
21
22
 
22
23
  class << self
@@ -31,9 +31,14 @@ module Facter
31
31
  def add_mount_points_fact(line)
32
32
  elem = line.split("\s")
33
33
 
34
- elem.shift unless line[0] == ' '
34
+ if line[0] != ' '
35
+ server = elem.shift
36
+ device = "#{server}:#{elem[0]}"
37
+ else
38
+ device = elem[0]
39
+ end
35
40
 
36
- @fact_list[:mountpoints][elem[1]] = { device: elem[0], filesystem: elem[2],
41
+ @fact_list[:mountpoints][elem[1]] = { device: device, filesystem: elem[2],
37
42
  options: elem.last.include?(':') ? [] : elem.last.split(',') }
38
43
  end
39
44
 
@@ -26,7 +26,7 @@ module Facter
26
26
 
27
27
  def get_data_from(url)
28
28
  headers = { Metadata: 'true' }
29
- Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout })
29
+ Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout }, false)
30
30
  end
31
31
 
32
32
  def determine_session_timeout
@@ -3,8 +3,8 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class BaseResolver
6
- def self.log
7
- @log ||= Log.new(self)
6
+ class << self
7
+ attr_reader :log
8
8
  end
9
9
 
10
10
  def self.invalidate_cache
@@ -14,6 +14,7 @@ module Facter
14
14
  def self.init_resolver
15
15
  @fact_list = {}
16
16
  @semaphore = Mutex.new
17
+ @log = Log.new(self)
17
18
  end
18
19
 
19
20
  def self.subscribe_to_manager
@@ -5,7 +5,6 @@ module Facter
5
5
  module Bsd
6
6
  class Processors < BaseResolver
7
7
  init_resolver
8
- @log = Facter::Log.new(self)
9
8
 
10
9
  class << self
11
10
  private
@@ -14,45 +14,65 @@ module Facter
14
14
  private
15
15
 
16
16
  def post_resolve(fact_name, _options)
17
- @fact_list.fetch(fact_name) { read_cgroup(fact_name) }
17
+ @fact_list.fetch(fact_name) do
18
+ read_environ(fact_name) || read_cgroup(fact_name)
19
+ end
18
20
  end
19
21
 
20
22
  def read_cgroup(fact_name)
21
23
  output_cgroup = Facter::Util::FileHelper.safe_read('/proc/1/cgroup', nil)
22
- output_environ = Facter::Util::FileHelper.safe_read('/proc/1/environ', nil)
23
- return unless output_cgroup && output_environ
24
+ return unless output_cgroup
24
25
 
25
26
  output_docker = %r{docker/(.+)}.match(output_cgroup)
26
27
  output_lxc = %r{^/lxc/([^/]+)}.match(output_cgroup)
27
- lxc_from_environ = /container=lxc/ =~ output_environ
28
28
 
29
- info, vm = extract_vm_and_info(output_docker, output_lxc, lxc_from_environ)
30
- info, vm = extract_for_nspawn(output_environ) unless vm
29
+ info, vm = extract_vm_and_info(output_docker, output_lxc)
30
+ @fact_list[:vm] = vm
31
+ @fact_list[:hypervisor] = { vm.to_sym => info } if vm
32
+ @fact_list[fact_name]
33
+ end
34
+
35
+ def read_environ(fact_name)
36
+ begin
37
+ container = Facter::Util::Linux::Proc.getenv_for_pid(1, 'container')
38
+ rescue StandardError => e
39
+ log.warn("Unable to getenv for pid 1, '#{e}'")
40
+ return nil
41
+ end
42
+ return if container.nil? || container.empty?
43
+
44
+ info = {}
45
+ case container
46
+ when 'lxcroot'
47
+ vm = 'lxc'
48
+ when 'podman'
49
+ vm = 'podman'
50
+ when 'crio'
51
+ vm = 'crio'
52
+ when 'systemd-nspawn'
53
+ vm = 'systemd_nspawn'
54
+ info = { 'id' => Facter::Util::FileHelper.safe_read('/etc/machine-id', nil).strip }
55
+ else
56
+ vm = 'container_other'
57
+ log.warn("Container runtime, '#{container}', is unsupported, setting to, '#{vm}'")
58
+ end
31
59
  @fact_list[:vm] = vm
32
60
  @fact_list[:hypervisor] = { vm.to_sym => info } if vm
33
61
  @fact_list[fact_name]
34
62
  end
35
63
 
36
- def extract_vm_and_info(output_docker, output_lxc, lxc_from_environ)
64
+ def extract_vm_and_info(output_docker, output_lxc)
37
65
  vm = nil
38
66
  if output_docker
39
67
  vm = 'docker'
40
68
  info = output_docker[1]
69
+ elsif output_lxc
70
+ vm = 'lxc'
71
+ info = output_lxc[1]
41
72
  end
42
- vm = 'lxc' if output_lxc || lxc_from_environ
43
- info = output_lxc[1] if output_lxc
44
73
 
45
74
  [info ? { INFO[vm] => info } : {}, vm]
46
75
  end
47
-
48
- def extract_for_nspawn(output_environ)
49
- nspawn = /container=systemd-nspawn/ =~ output_environ
50
- if nspawn
51
- vm = 'systemd_nspawn'
52
- info = Facter::Util::FileHelper.safe_read('/etc/machine-id', nil)
53
- end
54
- [info ? { 'id' => info.strip } : {}, vm]
55
- end
56
76
  end
57
77
  end
58
78
  end
@@ -4,8 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Linux
6
6
  class Disks < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  DIR = '/sys/block'
@@ -4,8 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Linux
6
6
  class DmiBios < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  class << self
@@ -52,7 +52,7 @@ module Facter
52
52
  def get_data_from(url)
53
53
  headers = {}
54
54
  headers['X-aws-ec2-metadata-token'] = v2_token if v2_token
55
- Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout })
55
+ Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout }, false)
56
56
  end
57
57
 
58
58
  def determine_session_timeout
@@ -8,8 +8,6 @@ module Facter
8
8
 
9
9
  init_resolver
10
10
 
11
- @log = Facter::Log.new(self)
12
-
13
11
  class << self
14
12
  private
15
13
 
@@ -8,8 +8,6 @@ module Facter
8
8
 
9
9
  init_resolver
10
10
 
11
- @log = Facter::Log.new(self)
12
-
13
11
  class << self
14
12
  private
15
13
 
@@ -7,7 +7,6 @@ module Facter
7
7
  module Freebsd
8
8
  class Processors < BaseResolver
9
9
  init_resolver
10
- @log = Facter::Log.new(self)
11
10
 
12
11
  class << self
13
12
  private
@@ -22,7 +22,7 @@ module Facter
22
22
  end
23
23
 
24
24
  def query_for_metadata
25
- gce_data = extract_to_hash(Facter::Util::Resolvers::Http.get_request(METADATA_URL, HEADERS))
25
+ gce_data = extract_to_hash(Facter::Util::Resolvers::Http.get_request(METADATA_URL, HEADERS, {}, false))
26
26
  parse_instance(gce_data)
27
27
 
28
28
  gce_data.empty? ? nil : gce_data
@@ -19,6 +19,11 @@ module Facter
19
19
  def retrieve_info(fact_name)
20
20
  require 'socket'
21
21
  output = Socket.gethostname
22
+ unless output
23
+ log.debug('Socket.gethostname failed to return hostname')
24
+ return
25
+ end
26
+
22
27
  hostname, domain = retrieve_from_fqdn(output)
23
28
 
24
29
  fqdn = retrieve_with_addrinfo(hostname) if hostname_and_no_domain?(hostname, domain)
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class PosxIdentity < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -7,8 +7,6 @@ module Facter
7
7
  include Facter::Util::Resolvers::FilesystemHelper
8
8
  init_resolver
9
9
 
10
- @log = Facter::Log.new(self)
11
-
12
10
  class << self
13
11
  private
14
12
 
@@ -6,8 +6,6 @@ module Facter
6
6
  class Memory < BaseResolver
7
7
  init_resolver
8
8
 
9
- @log = Facter::Log.new(self)
10
-
11
9
  class << self
12
10
  private
13
11
 
@@ -7,8 +7,6 @@ module Facter
7
7
 
8
8
  init_resolver
9
9
 
10
- @log = Facter::Log.new(self)
11
-
12
10
  class << self
13
11
  private
14
12
 
@@ -96,6 +96,8 @@ module Facter
96
96
  @fact_list[:name] = if os_name.downcase.start_with?('red', 'oracle', 'arch', 'manjaro')
97
97
  os_name = os_name.split(' ')[0..1].join
98
98
  os_name
99
+ elsif os_name.downcase.end_with?('azure linux')
100
+ os_name.split(' ')[1..2].join
99
101
  elsif os_name.downcase.end_with?('mariner')
100
102
  os_name.split(' ')[-1].strip
101
103
  else
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'set'
4
+
3
5
  module Facter
4
6
  module Resolvers
5
7
  module Linux
6
8
  class Processors < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
9
  init_resolver
10
10
 
11
11
  MHZ_TO_HZ = 1_000_000
12
12
 
13
13
  class << self
14
14
  # :count
15
+ # :extensions
15
16
  # :models
16
17
  # :physical_count
17
18
  # :speed
@@ -34,6 +35,7 @@ module Facter
34
35
  end
35
36
 
36
37
  def read_processors(cpuinfo_output)
38
+ @fact_list[:extensions] = Set[Facter::Resolvers::Uname.resolve(:processor)]
37
39
  @fact_list[:processors] = 0
38
40
  @fact_list[:models] = []
39
41
  @fact_list[:physical_processors] = []
@@ -43,7 +45,10 @@ module Facter
43
45
  construct_models_list(tokens)
44
46
  count_physical_processors(tokens)
45
47
  build_speed(tokens)
48
+ check_extensions(tokens)
46
49
  end
50
+ @fact_list[:extensions] = @fact_list[:extensions].to_a
51
+ @fact_list[:extensions].sort!
47
52
  end
48
53
 
49
54
  def count_processors(tokens)
@@ -84,6 +89,21 @@ module Facter
84
89
  speed = tokens.last.strip.match(/^(\d+).*/)[1]
85
90
  @fact_list[:speed] = speed.to_i * MHZ_TO_HZ
86
91
  end
92
+
93
+ def check_extensions(tokens)
94
+ return unless tokens.first.strip == 'flags'
95
+
96
+ flags = tokens.last.split(' ')
97
+
98
+ # TODO: As we gain support for other arches, change the guard
99
+ # so we only check the flags for the corosponding arches
100
+ return unless @fact_list[:extensions].include?('x86_64')
101
+
102
+ @fact_list[:extensions].add('x86_64-v1') if (%w[cmov cx8 fpu fxsr lm mmx syscall sse2] - flags).empty?
103
+ @fact_list[:extensions].add('x86_64-v2') if (%w[cx16 lahf_lm popcnt sse4_1 sse4_2 ssse3] - flags).empty?
104
+ @fact_list[:extensions].add('x86_64-v3') if (%w[abm avx avx2 bmi1 bmi2 f16c fma movbe xsave] - flags).empty?
105
+ @fact_list[:extensions].add('x86_64-v4') if (%w[avx512f avx512bw avx512cd avx512dq avx512vl] - flags).empty?
106
+ end
87
107
  end
88
108
  end
89
109
  end
@@ -7,8 +7,6 @@ module Facter
7
7
  include Facter::Util::Resolvers::FilesystemHelper
8
8
  init_resolver
9
9
 
10
- @log = Facter::Log.new(self)
11
-
12
10
  class << self
13
11
  private
14
12
 
@@ -6,7 +6,6 @@ module Facter
6
6
  module Solaris
7
7
  class Networking < BaseResolver
8
8
  init_resolver
9
- @log = Facter::Log.new(self)
10
9
 
11
10
  class << self
12
11
  private
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class Ssh < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  FILE_NAMES = %w[ssh_host_rsa_key.pub ssh_host_dsa_key.pub ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub].freeze
@@ -3,7 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class DMIBios < BaseResolver
6
- @log = Facter::Log.new(self)
7
6
  init_resolver
8
7
 
9
8
  class << self
@@ -3,7 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class DMIComputerSystem < BaseResolver
6
- @log = Facter::Log.new(self)
7
6
  init_resolver
8
7
 
9
8
  class << self
@@ -24,7 +24,6 @@ module Facter
24
24
  build_facts_list(hardware: hard, architecture: arch)
25
25
  @fact_list[fact_name]
26
26
  rescue LoadError => e
27
- log = Facter::Log.new(self)
28
27
  log.debug("The ffi gem has not been installed: #{e}")
29
28
  end
30
29
 
@@ -4,7 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  class Identity < BaseResolver
6
6
  NAME_SAM_COMPATIBLE = 2
7
- @log = Facter::Log.new(self)
8
7
 
9
8
  init_resolver
10
9
 
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class Kernel < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class Memory < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -4,7 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Windows
6
6
  class Networking < BaseResolver
7
- @log = Facter::Log.new(self)
8
7
  init_resolver
9
8
 
10
9
  class << self
@@ -4,8 +4,6 @@ module Facter
4
4
  module Resolvers
5
5
  module Windows
6
6
  class Ssh < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  FILE_NAMES = %w[ssh_host_rsa_key.pub ssh_host_dsa_key.pub
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class System32 < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -34,7 +34,6 @@ module Facter
34
34
  require_relative '../../../facter/resolvers/windows/ffi/winnls_ffi'
35
35
  WinnlsFFI.GetACP.to_s
36
36
  rescue LoadError => e
37
- log = Facter::Log.new(self)
38
37
  log.debug("Could not retrieve codepage: #{e}")
39
38
  end
40
39
  end
@@ -6,8 +6,6 @@ module Facter
6
6
  module Resolvers
7
7
  module Windows
8
8
  class Uptime < BaseResolver
9
- @log = Facter::Log.new(self)
10
-
11
9
  init_resolver
12
10
 
13
11
  class << self
@@ -4,16 +4,21 @@ module Facter
4
4
  module Resolvers
5
5
  module Windows
6
6
  class Virtualization < BaseResolver
7
- @log = Facter::Log.new(self)
8
-
9
7
  init_resolver
10
8
 
11
9
  class << self
12
10
  # Virtual
13
11
  # Is_Virtual
14
12
 
15
- MODEL_HASH = { 'VirtualBox' => 'virtualbox', 'VMware' => 'vmware', 'KVM' => 'kvm',
16
- 'Bochs' => 'bochs', 'Google' => 'gce', 'OpenStack' => 'openstack' }.freeze
13
+ MODEL_HASH = {
14
+ 'VirtualBox' => 'virtualbox',
15
+ 'VMware' => 'vmware',
16
+ 'KVM' => 'kvm',
17
+ 'Bochs' => 'bochs',
18
+ 'Google' => 'gce',
19
+ 'OpenStack' => 'openstack',
20
+ 'AHV' => 'ahv'
21
+ }.freeze
17
22
 
18
23
  private
19
24
 
@@ -3,8 +3,6 @@
3
3
  module Facter
4
4
  module Resolvers
5
5
  class WinOsDescription < BaseResolver
6
- @log = Facter::Log.new(self)
7
-
8
6
  init_resolver
9
7
 
10
8
  class << self
@@ -66,6 +66,8 @@ module Facter
66
66
  return XEN_TOOLSTACK if num_stacks > 1 && File.exist?(XEN_TOOLSTACK)
67
67
 
68
68
  XEN_COMMANDS.each { |command| return command if File.exist?(command) }
69
+
70
+ nil
69
71
  end
70
72
  end
71
73
  end
@@ -1,11 +1,14 @@
1
1
  <%# encoding: UTF-8%>
2
+ facter - collect and display facts about the current system
3
+ ===========================================================
4
+
2
5
  SYNOPSIS
3
6
  --------
4
- facter [options] [query] [query] [...]
7
+ <b>facter</b> [options] [query] [query] [...]
5
8
 
6
9
  DESCRIPTION
7
10
  -----------
8
- Collect and display facts about the current system. The library behind Facter is easy to extend, making Facter an easy way to collect information about a system.
11
+ <b>facter</b> is a command-line tool that gathers basic facts about nodes (systems) such as hardware details, network settings, OS type and version, and more. These facts are made available as variables in your Puppet manifests and can be used to inform conditional expressions in Puppet.
9
12
 
10
13
  If no queries are given, then all facts will be returned.
11
14
 
@@ -10,7 +10,7 @@ module Facter
10
10
 
11
11
  PHYSICAL_HYPERVISORS = %w[physical xen0 vmware_server vmware_workstation openvzhn vserver_host].freeze
12
12
  REDHAT_FAMILY = %w[redhat rhel fedora centos scientific ascendos cloudlinux psbm
13
- oraclelinux ovs oel amazon xenserver xcp-ng virtuozzo photon mariner].freeze
13
+ oraclelinux ovs oel amazon xenserver xcp-ng virtuozzo photon mariner azurelinux].freeze
14
14
  DEBIAN_FAMILY = %w[debian ubuntu huaweios linuxmint devuan kde].freeze
15
15
  SUSE_FAMILY = %w[sles sled suse].freeze
16
16
  GENTOO_FAMILY = ['gentoo'].freeze
@@ -15,12 +15,14 @@ module Facter
15
15
  default_return
16
16
  end
17
17
 
18
- def safe_readlines(path, default_return = [])
19
- return File.readlines(path, encoding: Encoding::UTF_8) if File.readable?(path)
18
+ # rubocop:disable Style/SpecialGlobalVars
19
+ def safe_readlines(path, default_return = [], sep = $/, chomp: false)
20
+ return File.readlines(path, sep, chomp: chomp, encoding: Encoding::UTF_8) if File.readable?(path)
20
21
 
21
22
  log_failed_to_read(path)
22
23
  default_return
23
24
  end
25
+ # rubocop:enable Style/SpecialGlobalVars
24
26
 
25
27
  # This previously acted as a helper method for versions of Ruby older
26
28
  # than 2.5, before Dir.children was added. As it isn't a private
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Util
5
+ module Linux
6
+ class Proc
7
+ class << self
8
+ def getenv_for_pid(pid, field)
9
+ path = "/proc/#{pid}/environ"
10
+ lines = Facter::Util::FileHelper.safe_readlines(path, [], "\0", chomp: true)
11
+ lines.each do |line|
12
+ key, value = line.split('=', 2)
13
+ return value if key == field
14
+ end
15
+ nil
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -10,34 +10,37 @@ module Facter
10
10
  CONNECTION_TIMEOUT = 0.6
11
11
  SESSION_TIMEOUT = 5
12
12
 
13
- # Makes a GET http request and returns its response.
13
+ # Makes a GET HTTP request and returns its response.
14
14
  #
15
- # Params:
16
- # url: String which contains the address to which the request will be made
17
- # headers: Hash which contains the headers you need to add to your request.
18
- # Default headers is an empty hash
19
- # Example: { "Accept": 'application/json' }
20
- # timeouts: Hash that includes the values for the session and connection timeouts.
21
- # Example: { session: 2.4. connection: 5 }
22
- #
23
- # Return value:
24
- # is a string with the response body if the response code is 200.
25
- # If the response code is not 200, an empty string is returned.
26
- def get_request(url, headers = {}, timeouts = {})
27
- make_request(url, headers, timeouts, 'GET')
15
+ # @param url [String] the address to which the request will be made.
16
+ # @param headers [Hash] the headers you need to add to your request.
17
+ # Defaults to an empty hash.
18
+ # @param timeouts [Hash] Values for the session and connection
19
+ # timeouts.
20
+ # @param proxy [Boolean] Whether to use proxy settings when calling
21
+ # Net::HTTP.new. Defaults to true.
22
+ # @returns [String] the response body if the response code is 200.
23
+ # If the response code is not 200, an empty string is returned.
24
+ # @example
25
+ # get_request('https://example.com', { "Accept": 'application/json' }, { session: 2.4, connection: 5 })
26
+ def get_request(url, headers = {}, timeouts = {}, proxy = true)
27
+ make_request(url, headers, timeouts, 'GET', proxy)
28
28
  end
29
29
 
30
- def put_request(url, headers = {}, timeouts = {})
31
- make_request(url, headers, timeouts, 'PUT')
30
+ # Makes a PUT HTTP request and returns its response
31
+ # @param (see #get_request)
32
+ # @return (see #get_request)
33
+ def put_request(url, headers = {}, timeouts = {}, proxy = true)
34
+ make_request(url, headers, timeouts, 'PUT', proxy)
32
35
  end
33
36
 
34
37
  private
35
38
 
36
- def make_request(url, headers, timeouts, request_type)
39
+ def make_request(url, headers, timeouts, request_type, proxy)
37
40
  require 'net/http'
38
41
 
39
42
  uri = URI.parse(url)
40
- http = http_obj(uri, timeouts)
43
+ http = http_obj(uri, timeouts, proxy)
41
44
  request = request_obj(headers, uri, request_type)
42
45
 
43
46
  # The Windows implementation of sockets does not respect net/http
@@ -56,8 +59,16 @@ module Facter
56
59
  ''
57
60
  end
58
61
 
59
- def http_obj(parsed_url, timeouts)
60
- http = Net::HTTP.new(parsed_url.host)
62
+ def http_obj(parsed_url, timeouts, proxy)
63
+ # If get_request or put_request are called and set proxy to false,
64
+ # manually set Net::HTTP.new's p_addr (proxy address) positional
65
+ # argument to nil to override anywhere else a proxy may be set
66
+ # (e.g. the http_proxy environment variable).
67
+ http = if proxy
68
+ Net::HTTP.new(parsed_url.host)
69
+ else
70
+ Net::HTTP.new(parsed_url.host, 80, nil)
71
+ end
61
72
  http.read_timeout = timeouts[:session] || SESSION_TIMEOUT
62
73
  http.open_timeout = timeouts[:connection] || CONNECTION_TIMEOUT
63
74
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Facter
4
- VERSION = '4.7.0' unless defined?(VERSION)
4
+ VERSION = '4.8.0' unless defined?(VERSION)
5
5
  end
metadata CHANGED
@@ -1,29 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 4.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-09 00:00:00.000000000 Z
11
+ date: 2024-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.15.5
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 1.17.0
23
+ - - "!="
24
+ - !ruby/object:Gem::Version
25
+ version: 1.16.0
26
+ - - "!="
27
+ - !ruby/object:Gem::Version
28
+ version: 1.16.1
29
+ - - "!="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.16.2
20
32
  type: :development
21
33
  prerelease: false
22
34
  version_requirements: !ruby/object:Gem::Requirement
23
35
  requirements:
24
- - - '='
36
+ - - ">="
25
37
  - !ruby/object:Gem::Version
26
38
  version: 1.15.5
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: 1.17.0
42
+ - - "!="
43
+ - !ruby/object:Gem::Version
44
+ version: 1.16.0
45
+ - - "!="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.16.1
48
+ - - "!="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.16.2
27
51
  - !ruby/object:Gem::Dependency
28
52
  name: rake
29
53
  requirement: !ruby/object:Gem::Requirement
@@ -322,6 +346,8 @@ files:
322
346
  - lib/facter/facts/amzn/os/distro/id.rb
323
347
  - lib/facter/facts/amzn/os/distro/release.rb
324
348
  - lib/facter/facts/amzn/os/release.rb
349
+ - lib/facter/facts/archlinux/os/release.rb
350
+ - lib/facter/facts/azurelinux/os/release.rb
325
351
  - lib/facter/facts/bsd/kernelmajversion.rb
326
352
  - lib/facter/facts/bsd/kernelversion.rb
327
353
  - lib/facter/facts/bsd/load_averages.rb
@@ -532,6 +558,7 @@ files:
532
558
  - lib/facter/facts/linux/processor.rb
533
559
  - lib/facter/facts/linux/processors/cores.rb
534
560
  - lib/facter/facts/linux/processors/count.rb
561
+ - lib/facter/facts/linux/processors/extensions.rb
535
562
  - lib/facter/facts/linux/processors/isa.rb
536
563
  - lib/facter/facts/linux/processors/models.rb
537
564
  - lib/facter/facts/linux/processors/physicalcount.rb
@@ -1125,6 +1152,7 @@ files:
1125
1152
  - lib/facter/util/file_helper.rb
1126
1153
  - lib/facter/util/linux/dhcp.rb
1127
1154
  - lib/facter/util/linux/if_inet6.rb
1155
+ - lib/facter/util/linux/proc.rb
1128
1156
  - lib/facter/util/linux/routing_table.rb
1129
1157
  - lib/facter/util/linux/socket_parser.rb
1130
1158
  - lib/facter/util/macosx/system_profile_executor.rb