facter 4.0.21 → 4.0.22

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f98a392ad6a05f9c7ad8d5ea4b1f95792ccd133c4d4069b737710cb40d5f4bc
4
- data.tar.gz: 61d8fb70c31865da5ea20b4e96e8331756cb1babca66dfcb89a369aa7d684326
3
+ metadata.gz: bac8104b3cb1089d8ec98cb6ce258acd13dd1278893c51a57726b25d2767f9dd
4
+ data.tar.gz: 93bf171d4bdc05edeca4fb79d8797af52404ce08da575cae8786fb40cd3534dc
5
5
  SHA512:
6
- metadata.gz: 03a6701d831ba8442ef9680a059781eb1b86f5b8ebd93ec7487b1b556345674d13cf37905fcad3da7f4aede956d82a69c4f3abd8facc0eea9961652e325c6a24
7
- data.tar.gz: 7c04baac0acfe2b148e7a0a12adf935e5bc06770f7711f22aa35078c901f18ed0cd5096b403a16071c5150954db8175b521d254c170fc215327e11cb435db6fa
6
+ metadata.gz: 0e155dd9dd597c9de0a223b45fc6dbe269fcda89d79b80be6527debd407cd22a2dd05c5bd788941fb4e15ef5794a41638da602cdce295495ef513865258d2bd6
7
+ data.tar.gz: 306c94ffbee046cba1e4dbd351b81f45df23b79383375ec969b1ef72df6f946b1e175758f467eaedc2d5e6bca33f0e6c884827eefb28562a81e88e8017d03c09
@@ -57,5 +57,11 @@ jobs:
57
57
  sudo chmod a-w /home/runner /usr/share &&
58
58
  sudo chmod -R a-w /usr/share/rust /home/runner/.config /home/linuxbrew
59
59
 
60
+ - name: Instal dhclient
61
+ if: runner.os == 'Linux'
62
+ run: |
63
+ sudo apt install dhcpcd5
64
+ sudo dhclient
65
+
60
66
  - name: Run acceptance tests
61
67
  run: sudo -E "PATH=$PATH" ruby facter_4/.github/actions/presuite.rb
@@ -1,5 +1,27 @@
1
1
 
2
2
 
3
+ ## [4.0.22](https://github.com/puppetlabs/facter-ng/tree/4.0.22) (2020-05-20)
4
+
5
+ [Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.21...4.0.22)
6
+
7
+ ### Added
8
+
9
+ - \(FACT-2603\) Detect virtual on GCE vms [\#521](https://github.com/puppetlabs/facter-ng/pull/521) ([oanatmaria](https://github.com/oanatmaria))
10
+ - \(FACT-2602\) Add docker/Lxc resolver for Linux [\#520](https://github.com/puppetlabs/facter-ng/pull/520) ([oanatmaria](https://github.com/oanatmaria))
11
+ - \(FACT-2615\) Add Solaris mountpoints fact [\#515](https://github.com/puppetlabs/facter-ng/pull/515) ([oanatmaria](https://github.com/oanatmaria))
12
+ - \(FACT-2532\) Add Aix nim\_type fact [\#513](https://github.com/puppetlabs/facter-ng/pull/513) ([oanatmaria](https://github.com/oanatmaria))
13
+ - \(FACT-2183\) Add Solaris's uptime legacy facts [\#511](https://github.com/puppetlabs/facter-ng/pull/511) ([oanatmaria](https://github.com/oanatmaria))
14
+
15
+ ### Fixed
16
+
17
+ - \(FACT-2617\) Fix for tests/external\_facts/external\_fact\_stderr\_messages\_output\_to\_stderr.rb [\#522](https://github.com/puppetlabs/facter-ng/pull/522) ([IrimieBogdan](https://github.com/IrimieBogdan))
18
+ - \(FACT-2523\) Fix for tests/external\_facts/non\_root\_users\_default\_external\_fact\_directory.rb [\#518](https://github.com/puppetlabs/facter-ng/pull/518) ([IrimieBogdan](https://github.com/IrimieBogdan))
19
+ - \(FACT-2522\) Fix for tests/external\_facts/fact\_directory\_precedence.rb [\#517](https://github.com/puppetlabs/facter-ng/pull/517) ([IrimieBogdan](https://github.com/IrimieBogdan))
20
+ - \(FACT-2521\) Fix for tests/external\_facts/external\_fact\_overrides\_custom\_fact\_with\_10000\_weight\_or\_less.rb [\#514](https://github.com/puppetlabs/facter-ng/pull/514) ([IrimieBogdan](https://github.com/IrimieBogdan))
21
+ - \(FACT-2525\) Fix for tests/options/color.rb [\#512](https://github.com/puppetlabs/facter-ng/pull/512) ([IrimieBogdan](https://github.com/IrimieBogdan))
22
+
23
+
24
+
3
25
  ## [4.0.21](https://github.com/puppetlabs/facter-ng/tree/4.0.21) (2020-05-13)
4
26
 
5
27
  [Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.20...4.0.21)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.21
1
+ 4.0.22
@@ -95,7 +95,7 @@ module LegacyFacter
95
95
  return @external_facts unless @external_facts.nil?
96
96
 
97
97
  load_external_facts
98
- external_facts = @facts.reject { |_k, v| v.options[:fact_type] }
98
+ external_facts = @facts.select { |_k, v| v.options[:fact_type] == :external }
99
99
  @external_facts = Facter::Utils.deep_copy(external_facts.keys)
100
100
  end
101
101
 
@@ -42,11 +42,16 @@ module LegacyFacter
42
42
  Facter::Options[:default_external_dir] = if windows_dir
43
43
  [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
44
44
  else
45
- ['/opt/puppetlabs/facter/facts.d']
45
+ [
46
+ '/etc/puppetlabs/facter/facts.d',
47
+ '/etc/facter/facts.d/',
48
+ '/opt/puppetlabs/facter/facts.d'
49
+ ]
46
50
  end
47
51
  elsif ENV['HOME']
48
52
  Facter::Options[:default_external_dir] =
49
- [File.expand_path(File.join(ENV['HOME'], '.puppetlabs', 'opt', 'facter', 'facts.d'))]
53
+ [File.join(ENV['HOME'], '.facter', 'facts.d'),
54
+ File.join(ENV['HOME'], '.puppetlabs', 'opt', 'facter', 'facts.d')]
50
55
  else
51
56
  Facter::Options[:default_external_dir] = []
52
57
  end
@@ -64,7 +64,7 @@ module LegacyFacter
64
64
  elsif (data == {}) || data.nil?
65
65
  LegacyFacter.warn "Fact file #{file} was parsed but returned an empty data set"
66
66
  else
67
- data.each { |p, v| collection.add(p, value: v) { has_weight(weight) } }
67
+ data.each { |p, v| collection.add(p, value: v, fact_type: :external) { has_weight(weight) } }
68
68
  end
69
69
  end
70
70
  end
@@ -161,7 +161,7 @@ module Facter
161
161
  end
162
162
 
163
163
  def sort_by_weight(resolutions)
164
- resolutions.sort { |a, b| b.weight <=> a.weight }
164
+ resolutions.sort { |a, b| b <=> a }
165
165
  end
166
166
 
167
167
  def find_first_real_value(resolutions)
@@ -13,7 +13,7 @@ module Facter
13
13
  module Util
14
14
  class Resolution
15
15
  # @api private
16
- attr_accessor :code
16
+ attr_accessor :code, :fact_type
17
17
  attr_writer :value
18
18
 
19
19
  extend Facter::Core::Execution
@@ -129,8 +129,29 @@ module Facter
129
129
  end
130
130
  end
131
131
 
132
+ # Comparation is done based on weight and fact type.
133
+ # The greatter the weight, the higher the priority.
134
+ # If weights are equal, we consider external facts greater than custom facts
135
+ def <=>(other)
136
+ return compare_equal_weights(other) if weight == other.weight
137
+ return 1 if weight > other.weight
138
+ return -1 if weight < other.weight
139
+ end
140
+
132
141
  private
133
142
 
143
+ # If the weights are equal, we consider external facts greater tan custom facts
144
+ def compare_equal_weights(other)
145
+ # Other is considered greater because self is custom fact and other is external
146
+ return -1 if fact_type == :custom && other.fact_type == :external
147
+
148
+ # Self is considered greater, because it is external fact and other is custom
149
+ return 1 if fact_type == :external && other.fact_type == :custom
150
+
151
+ # They are considered equal
152
+ 0
153
+ end
154
+
134
155
  def resolve_value
135
156
  if @value
136
157
  @value
@@ -12,7 +12,7 @@ module Facter
12
12
  class ResolveCustomFactError < StandardError; end
13
13
 
14
14
  Options.init
15
- Log.add_legacy_logger(STDOUT)
15
+ Log.output(STDOUT)
16
16
  @already_searched = {}
17
17
  @trace = false
18
18
 
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Aix
5
+ class NimType
6
+ FACT_NAME = 'nim_type'
7
+
8
+ def call_the_resolver
9
+ fact_value = Facter::Resolvers::Aix::Nim.resolve(:type)
10
+
11
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Linux
5
+ class Hypervisors
6
+ FACT_NAME = 'hypervisors'
7
+
8
+ def call_the_resolver
9
+ fact_value = check_docker_lxc
10
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
11
+ end
12
+
13
+ def check_docker_lxc
14
+ Facter::Resolvers::DockerLxc.resolve(:hypervisor)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Linux
5
+ class Virtual
6
+ FACT_NAME = 'virtual'
7
+
8
+ def call_the_resolver
9
+ fact_value = check_docker_lxc || check_gce
10
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
11
+ end
12
+
13
+ def check_gce
14
+ bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
15
+ 'gce' if bios_vendor&.include?('Google')
16
+ end
17
+
18
+ def check_docker_lxc
19
+ Facter::Resolvers::DockerLxc.resolve(:vm)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Solaris
5
+ class Mountpoints
6
+ FACT_NAME = 'mountpoints'
7
+
8
+ def call_the_resolver
9
+ mountpoints = Facter::Resolvers::Linux::Mountpoints.resolve(FACT_NAME.to_sym)
10
+ return Facter::ResolvedFact.new(FACT_NAME, nil) unless mountpoints
11
+
12
+ fact = {}
13
+ mountpoints.each do |mnt|
14
+ fact[mnt[:path].to_sym] = mnt.reject { |k| k == :path }
15
+ end
16
+
17
+ Facter::ResolvedFact.new(FACT_NAME, fact)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -5,11 +5,12 @@ module Facts
5
5
  module SystemUptime
6
6
  class Days
7
7
  FACT_NAME = 'system_uptime.days'
8
+ ALIASES = 'uptime_days'
8
9
 
9
10
  def call_the_resolver
10
11
  fact_value = Facter::Resolvers::Uptime.resolve(:days)
11
12
 
12
- Facter::ResolvedFact.new(FACT_NAME, fact_value)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
13
14
  end
14
15
  end
15
16
  end
@@ -5,11 +5,12 @@ module Facts
5
5
  module SystemUptime
6
6
  class Hours
7
7
  FACT_NAME = 'system_uptime.hours'
8
+ ALIASES = 'uptime_hours'
8
9
 
9
10
  def call_the_resolver
10
11
  fact_value = Facter::Resolvers::Uptime.resolve(:hours)
11
12
 
12
- Facter::ResolvedFact.new(FACT_NAME, fact_value)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
13
14
  end
14
15
  end
15
16
  end
@@ -5,11 +5,12 @@ module Facts
5
5
  module SystemUptime
6
6
  class Seconds
7
7
  FACT_NAME = 'system_uptime.seconds'
8
+ ALIASES = 'uptime_seconds'
8
9
 
9
10
  def call_the_resolver
10
11
  fact_value = Facter::Resolvers::Uptime.resolve(:seconds)
11
12
 
12
- Facter::ResolvedFact.new(FACT_NAME, fact_value)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
13
14
  end
14
15
  end
15
16
  end
@@ -5,11 +5,12 @@ module Facts
5
5
  module SystemUptime
6
6
  class Uptime
7
7
  FACT_NAME = 'system_uptime.uptime'
8
+ ALIASES = 'uptime'
8
9
 
9
10
  def call_the_resolver
10
11
  fact_value = Facter::Resolvers::Uptime.resolve(:uptime)
11
12
 
12
- Facter::ResolvedFact.new(FACT_NAME, fact_value)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
13
14
  end
14
15
  end
15
16
  end
@@ -2,9 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'thor'
5
- require "#{ROOT_DIR}/lib/framework/logging/multilogger.rb"
6
5
  require "#{ROOT_DIR}/lib/framework/logging/logger.rb"
7
- Facter::Log.add_legacy_logger(STDERR)
6
+ Facter::Log.output(STDERR)
8
7
  require "#{ROOT_DIR}/lib/facter"
9
8
  require "#{ROOT_DIR}/lib/framework/cli/cli"
10
9
 
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  load_lib_dirs('framework', 'core', 'options')
24
24
  require "#{ROOT_DIR}/lib/framework/core/options"
25
- require "#{ROOT_DIR}/lib/framework/logging/multilogger"
25
+ require "#{ROOT_DIR}/lib/framework/logging/logger_helper"
26
26
  require "#{ROOT_DIR}/lib/framework/logging/logger"
27
27
 
28
28
  require "#{ROOT_DIR}/lib/util/file_helper"
@@ -23,6 +23,7 @@ module Facter
23
23
  @user_query = []
24
24
  @block_list = {}
25
25
  @fact_groups = {}
26
+ @color = false
26
27
 
27
28
  class << self
28
29
  attr_reader :debug, :verbose, :log_level, :show_legacy, :trace, :ruby,
@@ -31,7 +32,7 @@ module Facter
31
32
  attr_accessor :config, :user_query, :strict, :json, :haml, :external_facts,
32
33
  :cache, :yaml, :puppet, :ttls, :block, :cli, :config_file_custom_dir,
33
34
  :config_file_external_dir, :default_external_dir, :fact_groups,
34
- :block_list
35
+ :block_list, :color
35
36
 
36
37
  attr_writer :external_dir
37
38
 
@@ -4,12 +4,14 @@ require 'logger'
4
4
 
5
5
  module Facter
6
6
  RED = 31
7
+ GREEN = 32
8
+ YELLOW = 33
9
+ CYAN = 36
10
+
7
11
  DEFAULT_LOG_LEVEL = :warn
8
12
 
9
13
  class Log
10
- @@legacy_logger = nil
11
- @@logger = MultiLogger.new([])
12
- @@logger.level = :warn
14
+ @@logger = nil
13
15
  @@message_callback = nil
14
16
  @@has_errors = false
15
17
 
@@ -29,78 +31,96 @@ module Facter
29
31
  def errors?
30
32
  @@has_errors
31
33
  end
32
- end
33
34
 
34
- def initialize(logged_class)
35
- determine_callers_name(logged_class)
36
- end
35
+ def output(output)
36
+ return if @@logger
37
37
 
38
- def self.add_legacy_logger(output)
39
- return if @@legacy_logger
38
+ @@logger = Logger.new(output)
39
+ set_logger_format
40
+ @@logger.level = DEFAULT_LOG_LEVEL
41
+ end
40
42
 
41
- @@legacy_logger = Logger.new(output)
42
- @@legacy_logger.level = DEFAULT_LOG_LEVEL
43
- set_format_for_legacy_logger
44
- @@logger.add_logger(@@legacy_logger)
43
+ def set_logger_format
44
+ @@logger.formatter = proc do |severity, datetime, _progname, msg|
45
+ datetime = datetime.strftime(@datetime_format || '%Y-%m-%d %H:%M:%S.%6N ')
46
+ "[#{datetime}] #{severity} #{msg} \n"
47
+ end
48
+ end
45
49
  end
46
50
 
47
- def determine_callers_name(sender_self)
48
- @class_name = case sender_self
49
- when String
50
- sender_self
51
- when Class
52
- sender_self.name
53
- when Module
54
- sender_self.name
55
- else # when class is singleton
56
- sender_self.class.name
57
- end
58
- end
51
+ def initialize(logged_class)
52
+ @class_name = LoggerHelper.determine_callers_name(logged_class)
53
+ return unless @@logger.nil?
59
54
 
60
- def self.set_format_for_legacy_logger
61
- @@legacy_logger.formatter = proc do |severity, datetime, _progname, msg|
62
- datetime = datetime.strftime(@datetime_format || '%Y-%m-%d %H:%M:%S.%6N ')
63
- "[#{datetime}] #{severity} #{msg} \n"
64
- end
55
+ @@logger = Logger.new(STDOUT)
56
+ @@logger.level = DEFAULT_LOG_LEVEL
65
57
  end
66
58
 
67
59
  def debug(msg)
68
60
  return unless debugging_active?
69
61
 
70
62
  if msg.nil? || msg.empty?
71
- invoker = caller(1..1).first.slice(/.*:\d+/)
72
- self.warn "#{self.class}#debug invoked with invalid message #{msg.inspect}:#{msg.class} at #{invoker}"
63
+ empty_message_error(msg)
73
64
  elsif @@message_callback
74
65
  @@message_callback.call(:debug, msg)
75
66
  else
67
+ msg = colorize(msg, CYAN) if Options[:color]
76
68
  @@logger.debug(@class_name + ' - ' + msg)
77
69
  end
78
70
  end
79
71
 
80
72
  def info(msg)
81
- @@logger.info(@class_name + ' - ' + msg)
73
+ if msg.nil? || msg.empty?
74
+ empty_message_error(msg)
75
+ elsif @@message_callback
76
+ @@message_callback.call(:info, msg)
77
+ else
78
+ msg = colorize(msg, GREEN) if Options[:color]
79
+ @@logger.info(@class_name + ' - ' + msg)
80
+ end
82
81
  end
83
82
 
84
83
  def warn(msg)
85
- @@logger.warn(@class_name + ' - ' + msg)
84
+ if msg.nil? || msg.empty?
85
+ empty_message_error(msg)
86
+ elsif @@message_callback
87
+ @@message_callback.call(:warn, msg)
88
+ else
89
+ msg = colorize(msg, YELLOW) if Options[:color]
90
+ @@logger.warn(@class_name + ' - ' + msg)
91
+ end
86
92
  end
87
93
 
88
94
  def error(msg, colorize = false)
89
95
  @@has_errors = true
90
- msg = colorize(msg, RED) if colorize && !OsDetector.instance.identifier.eql?(:windows)
91
- @@logger.error(@class_name + ' - ' + msg)
92
- end
93
96
 
94
- def colorize(msg, color)
95
- "\e[#{color}m#{msg}\e[0m"
97
+ if msg.nil? || msg.empty?
98
+ empty_message_error(msg)
99
+ elsif @@message_callback
100
+ @@message_callback.call(:error, msg)
101
+ else
102
+ msg = colorize(msg, RED) if colorize || Options[:color]
103
+ @@logger.error(@class_name + ' - ' + msg)
104
+ end
96
105
  end
97
106
 
98
107
  private
99
108
 
109
+ def colorize(msg, color)
110
+ return msg if OsDetector.instance.identifier.eql?(:windows)
111
+
112
+ "\e[0;#{color}m#{msg}\e[0m"
113
+ end
114
+
100
115
  def debugging_active?
101
116
  return true unless Facter.respond_to?(:debugging?)
102
117
 
103
118
  Facter.debugging?
104
119
  end
120
+
121
+ def empty_message_error(msg)
122
+ invoker = caller(1..1).first.slice(/.*:\d+/)
123
+ @@logger.warn "#{self.class}#debug invoked with invalid message #{msg.inspect}:#{msg.class} at #{invoker}"
124
+ end
105
125
  end
106
126
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class LoggerHelper
4
+ class << self
5
+ def determine_callers_name(sender_self)
6
+ class_name = case sender_self
7
+ when String
8
+ sender_self
9
+ when Class
10
+ sender_self.name
11
+ when Module
12
+ sender_self.name
13
+ else # when class is singleton
14
+ sender_self.class.name
15
+ end
16
+ class_name
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Resolvers
5
+ module Aix
6
+ class Nim < BaseResolver
7
+ @semaphore = Mutex.new
8
+ @fact_list ||= {}
9
+
10
+ class << self
11
+ private
12
+
13
+ def post_resolve(fact_name)
14
+ @fact_list.fetch(fact_name) { read_niminfo(fact_name) }
15
+ end
16
+
17
+ def read_niminfo(fact_name)
18
+ output = Facter::Util::FileHelper.safe_read('/etc/niminfo', nil)
19
+
20
+ return unless output
21
+
22
+ type = /NIM_CONFIGURATION=(.*)/.match(output)
23
+ @fact_list[:type] = type[1] if type[1] && /master|standalone/.match?(type[1])
24
+
25
+ @fact_list[fact_name]
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Resolvers
5
+ class DockerLxc < BaseResolver
6
+ # :virtual
7
+ # :hypervisor
8
+
9
+ @semaphore = Mutex.new
10
+ @fact_list ||= {}
11
+ INFO = { 'docker' => 'id', 'lxc' => 'name' }.freeze
12
+
13
+ class << self
14
+ private
15
+
16
+ def post_resolve(fact_name)
17
+ @fact_list.fetch(fact_name) { read_cgroup(fact_name) }
18
+ end
19
+
20
+ def read_cgroup(fact_name)
21
+ output_cgroup = Util::FileHelper.safe_read('/proc/1/cgroup', nil)
22
+ output_environ = Util::FileHelper.safe_read('/proc/1/environ', nil)
23
+ return if output_cgroup.nil? || output_environ.nil?
24
+
25
+ output_docker = %r{docker/(.+)}.match(output_cgroup)
26
+ output_lxc = %r{^/lxc/([^/]+)}.match(output_cgroup)
27
+ lxc_from_environ = /container=lxc/ =~ output_environ
28
+
29
+ info, vm = extract_vm_and_info(output_docker, output_lxc, lxc_from_environ)
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 extract_vm_and_info(output_docker, output_lxc, lxc_from_environ)
36
+ vm = nil
37
+ if output_docker
38
+ vm = 'docker'
39
+ info = output_docker[1]
40
+ end
41
+ vm = 'lxc' if output_lxc || lxc_from_environ
42
+ info = output_lxc[1] if output_lxc
43
+
44
+ [info ? { INFO[vm] => info } : {}, vm]
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.21
4
+ version: 4.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-13 00:00:00.000000000 Z
11
+ date: 2020-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -257,6 +257,7 @@ files:
257
257
  - lib/facts/aix/networking/hostname.rb
258
258
  - lib/facts/aix/networking/ip.rb
259
259
  - lib/facts/aix/networking/primary.rb
260
+ - lib/facts/aix/nim_type.rb
260
261
  - lib/facts/aix/os/architecture.rb
261
262
  - lib/facts/aix/os/family.rb
262
263
  - lib/facts/aix/os/hardware.rb
@@ -311,6 +312,7 @@ files:
311
312
  - lib/facts/linux/facterversion.rb
312
313
  - lib/facts/linux/filesystems.rb
313
314
  - lib/facts/linux/fips_enabled.rb
315
+ - lib/facts/linux/hypervisors.rb
314
316
  - lib/facts/linux/identity/gid.rb
315
317
  - lib/facts/linux/identity/group.rb
316
318
  - lib/facts/linux/identity/privileged.rb
@@ -397,6 +399,7 @@ files:
397
399
  - lib/facts/linux/system_uptime/seconds.rb
398
400
  - lib/facts/linux/system_uptime/uptime.rb
399
401
  - lib/facts/linux/timezone.rb
402
+ - lib/facts/linux/virtual.rb
400
403
  - lib/facts/macosx/augeas/version.rb
401
404
  - lib/facts/macosx/dmi/product/name.rb
402
405
  - lib/facts/macosx/facterversion.rb
@@ -506,6 +509,7 @@ files:
506
509
  - lib/facts/solaris/kernelmajversion.rb
507
510
  - lib/facts/solaris/kernelrelease.rb
508
511
  - lib/facts/solaris/kernelversion.rb
512
+ - lib/facts/solaris/mountpoints.rb
509
513
  - lib/facts/solaris/networking/domain.rb
510
514
  - lib/facts/solaris/networking/fqdn.rb
511
515
  - lib/facts/solaris/networking/hostname.rb
@@ -652,7 +656,7 @@ files:
652
656
  - lib/framework/formatters/legacy_fact_formatter.rb
653
657
  - lib/framework/formatters/yaml_fact_formatter.rb
654
658
  - lib/framework/logging/logger.rb
655
- - lib/framework/logging/multilogger.rb
659
+ - lib/framework/logging/logger_helper.rb
656
660
  - lib/framework/parsers/query_parser.rb
657
661
  - lib/framework/utils/utils.rb
658
662
  - lib/models/fact_collection.rb
@@ -667,6 +671,7 @@ files:
667
671
  - lib/resolvers/aix/load_averages_resolver.rb
668
672
  - lib/resolvers/aix/mountpoints.rb
669
673
  - lib/resolvers/aix/networking_resolver.rb
674
+ - lib/resolvers/aix/nim.rb
670
675
  - lib/resolvers/aix/os_level_resolver.rb
671
676
  - lib/resolvers/aix/partitions.rb
672
677
  - lib/resolvers/aix/processors.rb
@@ -678,6 +683,7 @@ files:
678
683
  - lib/resolvers/debian_version.rb
679
684
  - lib/resolvers/disk_resolver.rb
680
685
  - lib/resolvers/dmi_resolver.rb
686
+ - lib/resolvers/docker_lxc.rb
681
687
  - lib/resolvers/eos_release_resolver.rb
682
688
  - lib/resolvers/facterversion_resolver.rb
683
689
  - lib/resolvers/filesystems_resolver.rb
@@ -1,119 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Facter
4
- require 'logger'
5
- # MultiLogger is an implementation of Ruby logging which can tee the log to
6
- # multiple endpoints.
7
- # This class reeks of :reek:TooManyMethods.
8
- class MultiLogger < Logger
9
- # Array of loggers to be logged to. These can be anything that acts reasonably
10
- # like a Logger.
11
- attr_reader :loggers
12
-
13
- # For things like level and progname, retrieve from the first active logging.
14
- # There's an implicit assumption that these will be the same across all
15
- # contained loggers.
16
-
17
- # Logging severity threshold (e.g. <tt>Logger::INFO</tt>).
18
- def level
19
- loggers.first.level
20
- end
21
-
22
- def level=(value)
23
- loggers.each { |logger| logger.level = value }
24
- end
25
-
26
- # Program name to include in log messages.
27
- def progname
28
- loggers.first.progname
29
- end
30
-
31
- def progname=(value)
32
- loggers.each { |logger| logger.progname = value }
33
- end
34
-
35
- # Set date-time format.
36
- # +datetime_format+:: A string suitable for passing to +strftime+.
37
- def datetime_format=(datetime_format)
38
- loggers.each { |logger| logger.datetime_format = datetime_format }
39
- end
40
-
41
- # Returns the date format being used. See #datetime_format=
42
- def datetime_format
43
- loggers.first.datetime_format
44
- end
45
-
46
- # Returns +true+ if the current severity level allows for the printing of
47
- # +DEBUG+ messages.
48
- def debug?
49
- loggers.first.level <= DEBUG
50
- end
51
-
52
- # Returns +true+ iff the current severity level allows for the printing of
53
- # +INFO+ messages.
54
- def info?
55
- loggers.first.level <= INFO
56
- end
57
-
58
- # Returns +true+ iff the current severity level allows for the printing of
59
- # +WARN+ messages.
60
- def warn?
61
- loggers.first.level <= WARN
62
- end
63
-
64
- # Returns +true+ iff the current severity level allows for the printing of
65
- # +ERROR+ messages.
66
- def error?
67
- loggers.first.level <= ERROR
68
- end
69
-
70
- #
71
- # === Synopsis
72
- #
73
- # MultiLogger.new([logger1, logger2])
74
- #
75
- # === Args
76
- #
77
- # +loggers+::
78
- # An array of loggers. Each one gets every message that is sent to the
79
- # MultiLogger instance.
80
- #
81
- # === Description
82
- #
83
- # Create an instance.
84
- #
85
- def initialize(loggers)
86
- @loggers = loggers
87
- end
88
-
89
- def add_logger(logger)
90
- @loggers << logger
91
- end
92
-
93
- # Methods that write to logs just write to each contained logging in turn
94
- def add(severity, message = nil, progname = nil, &block)
95
- loggers.each { |logger| logger.add(severity, message, progname, &block) }
96
- end
97
- alias log add
98
-
99
- def debug(progname = nil, &block)
100
- loggers.each { |logger| logger.debug(progname, &block) }
101
- end
102
-
103
- def info(progname = nil, &block)
104
- loggers.each { |logger| logger.info(progname, &block) }
105
- end
106
-
107
- def warn(progname = nil, &block)
108
- loggers.each { |logger| logger.warn(progname, &block) }
109
- end
110
-
111
- def error(progname = nil, &block)
112
- loggers.each { |logger| logger.error(progname, &block) }
113
- end
114
-
115
- def close
116
- loggers.each(&:close)
117
- end
118
- end
119
- end