facter 4.0.15 → 4.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +5 -7
- data/CHANGELOG.md +33 -0
- data/VERSION +1 -1
- data/lib/custom_facts/util/parser.rb +1 -1
- data/lib/custom_facts/version.rb +1 -1
- data/lib/facter.rb +13 -17
- data/lib/facts/aix/partitions.rb +15 -0
- data/lib/facts/windows/ssh.rb +27 -0
- data/lib/facts_utils/uptime_parser.rb +3 -3
- data/lib/framework/cli/cli.rb +1 -1
- data/lib/framework/config/block_list.rb +1 -4
- data/lib/framework/config/config_reader.rb +29 -26
- data/lib/framework/core/fact_filter.rb +2 -2
- data/lib/framework/core/file_loader.rb +3 -3
- data/lib/framework/core/options.rb +57 -64
- data/lib/framework/core/options/config_file_options.rb +58 -48
- data/lib/framework/core/options/option_store.rb +156 -0
- data/lib/framework/core/options/options_validator.rb +42 -2
- data/lib/framework/logging/logger.rb +2 -0
- data/lib/framework/parsers/query_parser.rb +1 -1
- data/lib/models/fact_collection.rb +1 -1
- data/lib/resolvers/aix/filesystem_resolver.rb +3 -2
- data/lib/resolvers/aix/partitions.rb +86 -0
- data/lib/resolvers/aix/utils/odm_query.rb +2 -2
- data/lib/resolvers/debian_version.rb +2 -5
- data/lib/resolvers/disk_resolver.rb +2 -3
- data/lib/resolvers/dmi_resolver.rb +3 -3
- data/lib/resolvers/filesystems_resolver.rb +3 -3
- data/lib/resolvers/fips_enabled_resolver.rb +1 -4
- data/lib/resolvers/hostname_resolver.rb +4 -4
- data/lib/resolvers/load_averages_resolver.rb +1 -3
- data/lib/resolvers/memory_resolver.rb +2 -2
- data/lib/resolvers/mountpoints_resolver.rb +1 -3
- data/lib/resolvers/os_release_resolver.rb +3 -6
- data/lib/resolvers/partitions.rb +11 -6
- data/lib/resolvers/processors_resolver.rb +3 -3
- data/lib/resolvers/selinux_resolver.rb +9 -9
- data/lib/resolvers/solaris/filesystems_resolver.rb +1 -1
- data/lib/resolvers/ssh_resolver.rb +4 -43
- data/lib/resolvers/utils/ssh_helper.rb +27 -0
- data/lib/resolvers/windows/ssh.rb +47 -0
- data/lib/util/file_helper.rb +24 -0
- metadata +9 -6
- data/lib/framework/core/options/default_options.rb +0 -35
- data/lib/framework/core/options/helper_options.rb +0 -52
- data/lib/framework/core/options/priority_options.rb +0 -12
- data/lib/framework/core/options/validate_options.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2152e5f7eabbae2f7ecbd79149167e8ec542c55f9dbda10c606bd4e4cdd6cf06
|
4
|
+
data.tar.gz: 25cbcb4a4d7ac89508041cc1e0c1833dac198dc2702c0ca3505cb77295f55da8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64ffad2e78106f6c15fc5712a32b3970ad67c2b44dd21e06192f61865c9a4b33fcca3f8ebc6c82810c6249b95b6e577dd9e975ef94c0edb55058e99e802ad6f4
|
7
|
+
data.tar.gz: 8f9efff21eb866000c71fe6bc4f481741248d39ddbfceda0d651d34612de38346a68818ebafcd89b22c5363444213bb6398d46960133a56a9cb5122b4fbdf193
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config --exclude-limit 1000`
|
3
|
-
# on 2020-04-
|
3
|
+
# on 2020-04-15 10:09:42 +0300 using RuboCop version 0.74.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 80
|
10
10
|
# Configuration parameters: CustomTransform, IgnoreMethods.
|
11
11
|
RSpec/FilePath:
|
12
12
|
Exclude:
|
@@ -80,6 +80,7 @@ RSpec/FilePath:
|
|
80
80
|
- 'spec/framework/core/fact_loaders/fact_loader_spec.rb'
|
81
81
|
- 'spec/framework/core/fact_loaders/internal_fact_loader_spec.rb'
|
82
82
|
- 'spec/framework/core/fact_manager_spec.rb'
|
83
|
+
- 'spec/framework/core/options/option_store_spec.rb'
|
83
84
|
- 'spec/framework/core/options/options_validator_spec.rb'
|
84
85
|
- 'spec/framework/core/options_spec.rb'
|
85
86
|
- 'spec/framework/core/session_cache_spec.rb'
|
@@ -108,7 +109,7 @@ RSpec/LeakyConstantDeclaration:
|
|
108
109
|
- 'spec/facter/resolvers/macosx/mountpoints_resolver_spec.rb'
|
109
110
|
- 'spec/facter/resolvers/utils/windows/network_utils_spec.rb'
|
110
111
|
|
111
|
-
# Offense count:
|
112
|
+
# Offense count: 118
|
112
113
|
# Configuration parameters: EnforcedStyle.
|
113
114
|
# SupportedStyles: have_received, receive
|
114
115
|
RSpec/MessageSpies:
|
@@ -176,7 +177,6 @@ RSpec/MessageSpies:
|
|
176
177
|
- 'spec/facter/facts/windows/ruby/sitedir_spec.rb'
|
177
178
|
- 'spec/facter/facts/windows/scope6_interfaces_spec.rb'
|
178
179
|
- 'spec/facter/resolvers/utils/aix/odm_query_spec.rb'
|
179
|
-
- 'spec/framework/config/config_reader_spec.rb'
|
180
180
|
- 'spec/framework/core/fact_loaders/external_fact_loader_spec.rb'
|
181
181
|
|
182
182
|
# Offense count: 26
|
@@ -190,7 +190,7 @@ RSpec/SubjectStub:
|
|
190
190
|
- 'spec/custom_facts/util/fact_spec.rb'
|
191
191
|
- 'spec/custom_facts/util/resolution_spec.rb'
|
192
192
|
|
193
|
-
# Offense count:
|
193
|
+
# Offense count: 179
|
194
194
|
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
195
195
|
RSpec/VerifiedDoubles:
|
196
196
|
Exclude:
|
@@ -233,7 +233,6 @@ RSpec/VerifiedDoubles:
|
|
233
233
|
- 'spec/facter/resolvers/solaris/zfs_resolver_spec.rb'
|
234
234
|
- 'spec/facter/resolvers/solaris/zone_resolver_spec.rb'
|
235
235
|
- 'spec/facter/resolvers/solaris/zpool_resolver_spec.rb'
|
236
|
-
- 'spec/facter/resolvers/ssh_resolver_spec.rb'
|
237
236
|
- 'spec/facter/resolvers/utils/windows/network_utils_spec.rb'
|
238
237
|
- 'spec/facter/resolvers/utils/windows/win32ole_spec.rb'
|
239
238
|
- 'spec/facter/resolvers/windows/dmi_bios_resolver_spec.rb'
|
@@ -252,7 +251,6 @@ RSpec/VerifiedDoubles:
|
|
252
251
|
- 'spec/framework/core/fact_loaders/external_fact_loader_spec.rb'
|
253
252
|
- 'spec/framework/core/fact_loaders/fact_loader_spec.rb'
|
254
253
|
- 'spec/framework/core/fact_manager_spec.rb'
|
255
|
-
- 'spec/framework/core/options_spec.rb'
|
256
254
|
- 'spec/framework/core/session_cache_spec.rb'
|
257
255
|
- 'spec/framework/formatters/hocon_fact_formatter_spec.rb'
|
258
256
|
- 'spec/framework/formatters/json_fact_formatter_spec.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,38 @@
|
|
1
1
|
|
2
2
|
|
3
|
+
## [4.0.16](https://github.com/puppetlabs/facter-ng/tree/4.0.16) (2020-04-15)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.15...4.0.16)
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- \(FACT-2233\) Add AIX partitons fact [\#433](https://github.com/puppetlabs/facter-ng/pull/433) ([oanatmaria](https://github.com/oanatmaria))
|
10
|
+
- \(FACT-2330\) Add ssh fact for Windows OpenSSH feature [\#424](https://github.com/puppetlabs/facter-ng/pull/424) ([oanatmaria](https://github.com/oanatmaria))
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
- \(FACT-2528\) Fix for tests/facts/ssh\_key.rb [\#442](https://github.com/puppetlabs/facter-ng/pull/442) ([oanatmaria](https://github.com/oanatmaria))
|
15
|
+
- \(FACT-2538\) Don't save core and legacy facts in collection if they have no value [\#441](https://github.com/puppetlabs/facter-ng/pull/441) ([IrimieBogdan](https://github.com/IrimieBogdan))
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
## [4.0.15](https://github.com/puppetlabs/facter-ng/tree/4.0.15) (2020-04-08)
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.14...4.0.15)
|
22
|
+
|
23
|
+
### Added
|
24
|
+
|
25
|
+
- \(FACT-2541\) Add TYPE for legacy facts [\#439](https://github.com/puppetlabs/facter-ng/pull/439) ([oanatmaria](https://github.com/oanatmaria))
|
26
|
+
- \(FACT-2535\) Allow interpolation of Facter.fact\('fact\_name'\) [\#435](https://github.com/puppetlabs/facter-ng/pull/435) ([sebastian-miclea](https://github.com/sebastian-miclea))
|
27
|
+
- \(FACT-2477\) Collect facts from alternative sources [\#422](https://github.com/puppetlabs/facter-ng/pull/422) ([oanatmaria](https://github.com/oanatmaria))
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
|
31
|
+
- \(FACT-2513\) Updated how option aliases are displayed [\#434](https://github.com/puppetlabs/facter-ng/pull/434) ([sebastian-miclea](https://github.com/sebastian-miclea))
|
32
|
+
- \(FACT-2499\) Facts with aliases are resolved only once [\#429](https://github.com/puppetlabs/facter-ng/pull/429) ([IrimieBogdan](https://github.com/IrimieBogdan))
|
33
|
+
|
34
|
+
|
35
|
+
|
3
36
|
## [4.0.14](https://github.com/puppetlabs/facter-ng/tree/4.0.14) (2020-04-01)
|
4
37
|
|
5
38
|
[Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.13...4.0.14)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0.
|
1
|
+
4.0.16
|
data/lib/custom_facts/version.rb
CHANGED
@@ -79,7 +79,7 @@ module LegacyFacter
|
|
79
79
|
# @return [String] the version -- for example: "1.6.14-6-gea42046" or nil if the VERSION
|
80
80
|
# file does not exist.
|
81
81
|
def self.read_version_file(path)
|
82
|
-
|
82
|
+
Util::FileHelper.safe_read(path).chomp
|
83
83
|
end
|
84
84
|
private_class_method :read_version_file
|
85
85
|
end
|
data/lib/facter.rb
CHANGED
@@ -11,7 +11,7 @@ require "#{ROOT_DIR}/lib/framework/core/options/options_validator"
|
|
11
11
|
module Facter
|
12
12
|
class ResolveCustomFactError < StandardError; end
|
13
13
|
|
14
|
-
|
14
|
+
Options.init
|
15
15
|
Log.add_legacy_logger(STDOUT)
|
16
16
|
@logger = Log.new(self)
|
17
17
|
@already_searched = {}
|
@@ -103,10 +103,7 @@ module Facter
|
|
103
103
|
#
|
104
104
|
# @api public
|
105
105
|
def debugging(debug_bool)
|
106
|
-
|
107
|
-
@options.refresh
|
108
|
-
|
109
|
-
debug_bool
|
106
|
+
Facter::Options[:debug] = debug_bool
|
110
107
|
end
|
111
108
|
|
112
109
|
# Returns a fact object by name. If you use this, you still have to
|
@@ -187,14 +184,12 @@ module Facter
|
|
187
184
|
#
|
188
185
|
# @api public
|
189
186
|
def to_hash
|
190
|
-
@options.priority_options[:to_hash] = true
|
191
|
-
@options.refresh
|
192
|
-
|
193
187
|
log_blocked_facts
|
194
188
|
|
189
|
+
reset
|
195
190
|
resolved_facts = Facter::FactManager.instance.resolve_facts
|
196
|
-
SessionCache.invalidate_all_caches
|
197
|
-
FactCollection.new.build_fact_collection!(resolved_facts)
|
191
|
+
Facter::SessionCache.invalidate_all_caches
|
192
|
+
Facter::FactCollection.new.build_fact_collection!(resolved_facts)
|
198
193
|
end
|
199
194
|
|
200
195
|
# Check whether printing stack trace is enabled
|
@@ -244,14 +239,14 @@ module Facter
|
|
244
239
|
#
|
245
240
|
# @api private
|
246
241
|
def to_user_output(cli_options, *args)
|
247
|
-
|
248
|
-
|
242
|
+
cli_options = cli_options.map { |(k, v)| [k.to_sym, v] }.to_h
|
243
|
+
Facter::Options.init_from_cli(cli_options, args)
|
249
244
|
@logger.info("executed with command line: #{ARGV.drop(1).join(' ')}")
|
250
245
|
log_blocked_facts
|
251
246
|
|
252
247
|
resolved_facts = Facter::FactManager.instance.resolve_facts(args)
|
253
248
|
SessionCache.invalidate_all_caches
|
254
|
-
fact_formatter = Facter::FormatterFactory.build(
|
249
|
+
fact_formatter = Facter::FormatterFactory.build(Facter::Options.get)
|
255
250
|
|
256
251
|
status = error_check(args, resolved_facts)
|
257
252
|
|
@@ -285,7 +280,6 @@ module Facter
|
|
285
280
|
#
|
286
281
|
# @return [ResolvedFact]
|
287
282
|
def resolve_fact(user_query)
|
288
|
-
@options.refresh([user_query])
|
289
283
|
user_query = user_query.to_s
|
290
284
|
resolved_facts = Facter::FactManager.instance.resolve_facts([user_query])
|
291
285
|
SessionCache.invalidate_all_caches
|
@@ -311,7 +305,7 @@ module Facter
|
|
311
305
|
#
|
312
306
|
# @api private
|
313
307
|
def error_check(args, resolved_facts)
|
314
|
-
if Options
|
308
|
+
if Options[:strict]
|
315
309
|
missing_names = args - resolved_facts.map(&:user_query).uniq
|
316
310
|
if missing_names.count.positive?
|
317
311
|
status = 1
|
@@ -330,8 +324,10 @@ module Facter
|
|
330
324
|
#
|
331
325
|
# @api private
|
332
326
|
def log_blocked_facts
|
333
|
-
block_list = BlockList.
|
334
|
-
|
327
|
+
block_list = Facter::BlockList.new(Facter::Options[:config]).block_list
|
328
|
+
return unless block_list.any? && Facter::Options[:block]
|
329
|
+
|
330
|
+
@logger.debug("blocking collection of #{block_list.join("\s")} facts")
|
335
331
|
end
|
336
332
|
|
337
333
|
# Used for printing errors regarding CLI user input validation
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Aix
|
5
|
+
class Partitions
|
6
|
+
FACT_NAME = 'partitions'
|
7
|
+
|
8
|
+
def call_the_resolver
|
9
|
+
partitions = Facter::Resolvers::Aix::Partitions.resolve(:partitions)
|
10
|
+
|
11
|
+
Facter::ResolvedFact.new(FACT_NAME, partitions.empty? ? nil : partitions)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facts
|
4
|
+
module Windows
|
5
|
+
class Ssh
|
6
|
+
FACT_NAME = 'ssh'
|
7
|
+
|
8
|
+
def call_the_resolver
|
9
|
+
privileged = Facter::Resolvers::Identity.resolve(:privileged)
|
10
|
+
ssh_info = Facter::Resolvers::Windows::Ssh.resolve(:ssh) if privileged
|
11
|
+
ssh_facts = {}
|
12
|
+
ssh_info&.each { |ssh| ssh_facts.merge!(create_ssh_fact(ssh)) }
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, ssh_facts.empty? ? nil : ssh_facts)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def create_ssh_fact(ssh)
|
19
|
+
{ ssh.name.to_sym =>
|
20
|
+
{ fingerprints: { sha1: ssh.fingerprint.sha1,
|
21
|
+
sha256: ssh.fingerprint.sha256 },
|
22
|
+
key: ssh.key,
|
23
|
+
type: ssh.type } }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -16,19 +16,19 @@ module Facter
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def uptime_proc_uptime
|
19
|
-
output, _status = Open3.
|
19
|
+
output, _stderr, _status = Open3.capture3("/bin/cat #{uptime_file} 2>/dev/null")
|
20
20
|
|
21
21
|
output.chomp.split(' ').first.to_i unless output.empty?
|
22
22
|
end
|
23
23
|
|
24
24
|
def uptime_sysctl
|
25
|
-
output, _status = Open3.
|
25
|
+
output, _stderr, _status = Open3.capture3("sysctl -n #{uptime_sysctl_variable} 2>/dev/null")
|
26
26
|
|
27
27
|
compute_uptime(Time.at(output.match(/\d+/)[0].to_i)) unless output.empty?
|
28
28
|
end
|
29
29
|
|
30
30
|
def uptime_executable
|
31
|
-
output, _status = Open3.
|
31
|
+
output, _stderr, _status = Open3.capture3(uptime_executable_cmd + ' 2>/dev/null')
|
32
32
|
return unless output
|
33
33
|
|
34
34
|
up = 0
|
data/lib/framework/cli/cli.rb
CHANGED
@@ -122,7 +122,7 @@ module Facter
|
|
122
122
|
desc '--list-block-groups', 'List block groups'
|
123
123
|
map ['--list-block-groups'] => :list_block_groups
|
124
124
|
def list_block_groups(*_args)
|
125
|
-
puts Facter::BlockList.
|
125
|
+
puts Facter::BlockList.new.block_groups.to_yaml.lines[1..-1].join
|
126
126
|
end
|
127
127
|
|
128
128
|
def self.exit_on_failure?
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module Facter
|
4
4
|
class BlockList
|
5
|
-
include Singleton
|
6
|
-
|
7
5
|
attr_reader :block_groups, :block_list
|
8
6
|
|
9
7
|
def initialize(block_list_path = nil)
|
@@ -28,8 +26,7 @@ module Facter
|
|
28
26
|
|
29
27
|
def load_block_groups
|
30
28
|
@block_groups = File.readable?(@block_groups_file_path) ? Hocon.load(@block_groups_file_path) : {}
|
31
|
-
|
32
|
-
@block_list = ConfigReader.new(options[:config]).block_list || {}
|
29
|
+
@block_list = ConfigReader.init(Options[:config]).block_list || {}
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
@@ -2,42 +2,45 @@
|
|
2
2
|
|
3
3
|
module Facter
|
4
4
|
class ConfigReader
|
5
|
-
|
5
|
+
class << self
|
6
|
+
attr_accessor :conf
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def init(config_path = nil)
|
9
|
+
config_path ||= default_path
|
10
|
+
refresh_config(config_path)
|
11
|
+
self
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
def block_list
|
15
|
+
@conf['facts'] && @conf['facts']['blocklist']
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
def ttls
|
19
|
+
@conf['facts'] && @conf['facts']['ttls']
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def global
|
23
|
+
@conf['global']
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
def cli
|
27
|
+
@conf['cli']
|
28
|
+
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
def refresh_config(config_path)
|
31
|
+
@conf = File.readable?(config_path) ? Hocon.load(config_path) : {}
|
32
|
+
end
|
31
33
|
|
32
|
-
|
34
|
+
private
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
def default_path
|
37
|
+
os = OsDetector.instance.identifier
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
windows_path = File.join('C:', 'ProgramData', 'PuppetLabs', 'facter', 'etc', 'facter.conf')
|
40
|
+
linux_path = File.join('/', 'etc', 'puppetlabs', 'facter', 'facter.conf')
|
39
41
|
|
40
|
-
|
42
|
+
os == :windows ? windows_path : linux_path
|
43
|
+
end
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -19,9 +19,9 @@ module Facter
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def filter_legacy_facts!(resolved_facts)
|
22
|
-
return
|
22
|
+
return unless !Options[:show_legacy] && Options[:user_query].empty?
|
23
23
|
|
24
|
-
resolved_facts.reject!(&:legacy?)
|
24
|
+
resolved_facts.reject!(&:legacy?)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -25,17 +25,17 @@ require "#{ROOT_DIR}/lib/framework/core/options"
|
|
25
25
|
require "#{ROOT_DIR}/lib/framework/logging/multilogger"
|
26
26
|
require "#{ROOT_DIR}/lib/framework/logging/logger"
|
27
27
|
|
28
|
+
require "#{ROOT_DIR}/lib/util/file_helper"
|
29
|
+
|
28
30
|
require "#{ROOT_DIR}/lib/resolvers/base_resolver"
|
29
31
|
require "#{ROOT_DIR}/lib/framework/detector/os_detector"
|
30
32
|
|
31
33
|
require "#{ROOT_DIR}/lib/framework/config/config_reader"
|
32
34
|
require "#{ROOT_DIR}/lib/framework/config/block_list"
|
33
|
-
require "#{ROOT_DIR}/lib/resolvers/utils/fingerprint.rb"
|
34
|
-
require "#{ROOT_DIR}/lib/resolvers/utils/ssh.rb"
|
35
|
-
require "#{ROOT_DIR}/lib/resolvers/utils/filesystem_helper.rb"
|
36
35
|
|
37
36
|
load_dir(['config'])
|
38
37
|
|
38
|
+
load_lib_dirs('resolvers', 'utils')
|
39
39
|
load_lib_dirs('resolvers')
|
40
40
|
load_lib_dirs('facts_utils')
|
41
41
|
load_lib_dirs('framework', 'core')
|
@@ -2,70 +2,63 @@
|
|
2
2
|
|
3
3
|
module Facter
|
4
4
|
class Options
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@options = { config: @priority_options[:config] }
|
63
|
-
augment_with_defaults!
|
64
|
-
augment_with_to_hash_defaults! if @priority_options[:to_hash]
|
65
|
-
augment_with_config_file_options!(@options[:config])
|
66
|
-
augment_with_priority_options!(@priority_options)
|
67
|
-
validate_configs
|
68
|
-
augment_with_helper_options!(@user_query)
|
5
|
+
class << self
|
6
|
+
def cli?
|
7
|
+
OptionStore.cli
|
8
|
+
end
|
9
|
+
|
10
|
+
def get
|
11
|
+
OptionStore.all
|
12
|
+
end
|
13
|
+
|
14
|
+
def [](key)
|
15
|
+
OptionStore.send(key.to_sym)
|
16
|
+
end
|
17
|
+
|
18
|
+
def []=(key, value)
|
19
|
+
OptionStore.send("#{key}=".to_sym, value)
|
20
|
+
end
|
21
|
+
|
22
|
+
def custom_dir?
|
23
|
+
OptionStore.custom_dir && OptionStore.custom_facts
|
24
|
+
end
|
25
|
+
|
26
|
+
def custom_dir
|
27
|
+
OptionStore.custom_dir.flatten
|
28
|
+
end
|
29
|
+
|
30
|
+
def external_dir?
|
31
|
+
OptionStore.external_dir && OptionStore.external_facts
|
32
|
+
end
|
33
|
+
|
34
|
+
def external_dir
|
35
|
+
OptionStore.external_dir
|
36
|
+
end
|
37
|
+
|
38
|
+
def init
|
39
|
+
OptionStore.cli = false
|
40
|
+
ConfigFileOptions.init
|
41
|
+
store(ConfigFileOptions.get)
|
42
|
+
end
|
43
|
+
|
44
|
+
def init_from_cli(cli_options = {}, user_query = nil)
|
45
|
+
Facter::OptionStore.cli = true
|
46
|
+
Facter::OptionStore.show_legacy = false
|
47
|
+
Facter::OptionStore.user_query = user_query
|
48
|
+
OptionStore.set(:config, cli_options[:config])
|
49
|
+
ConfigFileOptions.init(cli_options[:config])
|
50
|
+
store(ConfigFileOptions.get)
|
51
|
+
store(cli_options)
|
52
|
+
|
53
|
+
Facter::OptionsValidator.validate_configs(get)
|
54
|
+
end
|
55
|
+
|
56
|
+
def store(options)
|
57
|
+
options.each do |key, value|
|
58
|
+
value = '' if key == 'log_level' && value == 'log_level'
|
59
|
+
OptionStore.set(key, value)
|
60
|
+
end
|
61
|
+
end
|
69
62
|
end
|
70
63
|
end
|
71
64
|
end
|