openfact 6.2.0 → 6.2.2

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: 3bad8912857bdd63fa3c31cacf9e6e5d6113e85216f1a57662c0b0101c20f2f9
4
- data.tar.gz: 16f3de88eecfd77e0f67d7d85c48d07b228fbad61d020a7998841d184ee327a5
3
+ metadata.gz: d6abc7bb997faa4bef38adcfe94b44215a33c7c90abef73364980446765c8aa5
4
+ data.tar.gz: 627301bef10445b49b513b8ed60e175fa1f7d62a39763edd899d9d61d9e95a59
5
5
  SHA512:
6
- metadata.gz: 0d7c6eda30361358651330ccd7a1a2dc6ffab30530e6a67806f5e65249128870bd2faf75553176c829e26fb9850e805b6f581733efe5714b06873ae5c5c60e56
7
- data.tar.gz: 1fc5de3dc1cfafc7039fae02c708fc6baa8d36d2cb56bdabdf85fe2be43d0eac82bc24b7643e8f9921e28addea138778453ea2176bc38314ddafdc26c8e93382
6
+ metadata.gz: '03408be381d6f7ebe5371d866e167af5056e81393bddea1d942db8c57ce6d87af962569857546387e6af424806dd6a95cbfd703cdf98a5cb4d6a66b8f3fb9459'
7
+ data.tar.gz: 5346ddb96b985b96cef97b8945515e8768b3db1982e66290e81ee667e33ca4a6b07e5e9f1ed4f60956b3d87bf86263b80963fbcabbf773d9d79436ede3c842aa
@@ -44,8 +44,13 @@ module Facter
44
44
  def execute(command, options = {})
45
45
  on_fail, expand, logger, timeout = extract_options(options)
46
46
 
47
- expanded_command = if (!expand && builtin_command?(command)) || logger
47
+ expanded_command = if !expand && builtin_command?(command)
48
48
  command
49
+ elsif logger
50
+ # Internal resolvers rely on search_paths to find commands
51
+ # outside of PATH (e.g. /usr/sbin/zpool on Solaris). Fall back
52
+ # to the command as given so failures are logged, not raised.
53
+ expand_command(command) || command
49
54
  else
50
55
  expand_command(command)
51
56
  end
@@ -19,9 +19,7 @@ module Facter
19
19
 
20
20
  def read_facts(fact_name)
21
21
  if fact_name == :metadata
22
- metadata = {}
23
- query_for_metadata(EC2_METADATA_ROOT_URL, metadata)
24
- @fact_list[:metadata] = metadata
22
+ @fact_list[:metadata] = read_metadata
25
23
  else
26
24
  @fact_list[:userdata] = get_data_from(EC2_USERDATA_ROOT_URL).strip.force_encoding('UTF-8')
27
25
  end
@@ -29,9 +27,29 @@ module Facter
29
27
  @fact_list[fact_name]
30
28
  end
31
29
 
30
+ # A failed root listing means no EC2-compatible metadata service is
31
+ # available, so there is no metadata to report. Once the root listing
32
+ # succeeds, any failed child request rejects the whole result.
33
+ def read_metadata
34
+ root_listing = root_metadata_listing
35
+ return {} unless root_listing
36
+
37
+ add_metadata_entries(EC2_METADATA_ROOT_URL, root_listing, {})
38
+ end
39
+
40
+ def root_metadata_listing
41
+ get_metadata_from(EC2_METADATA_ROOT_URL)
42
+ rescue StandardError => e
43
+ log.debug("EC2 metadata is not available: #{e.message}")
44
+ nil
45
+ end
46
+
32
47
  def query_for_metadata(url, container)
33
- metadata = get_metadata_from(url)
34
- metadata.each_line do |line|
48
+ add_metadata_entries(url, get_metadata_from(url), container)
49
+ end
50
+
51
+ def add_metadata_entries(url, listing, container)
52
+ listing.each_line do |line|
35
53
  next if line.empty?
36
54
 
37
55
  http_path_component = build_path_component(line)
@@ -14,13 +14,12 @@ module Facter
14
14
  end
15
15
 
16
16
  def read_ipaddress(fact_name)
17
- ip = nil
18
17
  primary_interface = read_primary_interface
19
18
  unless primary_interface.nil?
20
19
  output = Facter::Core::Execution.execute("ifconfig #{primary_interface}", logger: log)
21
20
  output.each_line do |str|
22
21
  if str.strip =~ /inet\s(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}) .+/
23
- @fact_list[:ip] = ip = Regexp.last_match(1)
22
+ @fact_list[:ip] = Regexp.last_match(1)
24
23
  break
25
24
  end
26
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Facter
4
- VERSION = '6.2.0' unless defined?(VERSION)
4
+ VERSION = '6.2.2' unless defined?(VERSION)
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openfact
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0
4
+ version: 6.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenVox Project
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 1.91.0
90
+ version: 1.92.0
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 1.91.0
97
+ version: 1.92.0
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rubocop-performance
100
100
  requirement: !ruby/object:Gem::Requirement