openfact 6.1.0 → 6.2.1
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 +4 -4
- data/lib/facter/resolvers/ec2.rb +23 -5
- data/lib/facter/resolvers/hostname.rb +22 -4
- data/lib/facter/resolvers/linux/hostname.rb +27 -3
- data/lib/facter/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ec1e87aeff5006c3da9300d30a0a0afeed9091c895d8062ce4afe1c52755303
|
|
4
|
+
data.tar.gz: 169e48d951c9cde33b143897b4553d78f1617a2102c5d8d562c22b9b788bb125
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 714c4becbbc91916e4158e510029509df78092d5ea1ac2dbff9bda114fb4be2cd4bb2c72bb37f8d402188412d176567bd8e502d608bc445df61f4141493e3f1d
|
|
7
|
+
data.tar.gz: 7a7bfc29a6a408334203f3c45fddf959e62208bea87f8a7c9e3c76ad08e41ad1ca8a0eec812336bbdffc8ba93e246a8ba03b7b9301252d779ede5691cf494d43
|
data/lib/facter/resolvers/ec2.rb
CHANGED
|
@@ -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
|
-
|
|
34
|
-
|
|
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)
|
|
@@ -9,6 +9,11 @@ module Facter
|
|
|
9
9
|
|
|
10
10
|
init_resolver
|
|
11
11
|
|
|
12
|
+
# Upper bound, in seconds, for the fqdn lookup. A hung name service
|
|
13
|
+
# otherwise stalls fact collection until the agent's runtimeout fires
|
|
14
|
+
# (OpenVoxProject/openvox#485). Only applied on Rubies that honour it.
|
|
15
|
+
FQDN_LOOKUP_TIMEOUT = 10
|
|
16
|
+
|
|
12
17
|
class << self
|
|
13
18
|
private
|
|
14
19
|
|
|
@@ -48,14 +53,27 @@ module Facter
|
|
|
48
53
|
|
|
49
54
|
def retrieve_with_addrinfo(host)
|
|
50
55
|
begin
|
|
51
|
-
|
|
56
|
+
addr = Addrinfo.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME,
|
|
57
|
+
**addrinfo_options)[0]
|
|
52
58
|
rescue StandardError => e
|
|
53
|
-
@log.debug("
|
|
59
|
+
@log.debug("Addrinfo.getaddrinfo failed to retrieve fqdn for hostname #{host} with: #{e}")
|
|
54
60
|
return
|
|
55
61
|
end
|
|
56
|
-
return if name.nil? || name.empty? || host == name[2] || name[2] == name[3]
|
|
57
62
|
|
|
58
|
-
name
|
|
63
|
+
name = addr&.canonname
|
|
64
|
+
return if name.nil? || name.empty? || host == name || name == addr.ip_address
|
|
65
|
+
|
|
66
|
+
name
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Addrinfo.getaddrinfo only honours the timeout keyword from Ruby 4.0
|
|
70
|
+
# on. Older MRI accepts and ignores it; JRuby does not accept it.
|
|
71
|
+
def addrinfo_options
|
|
72
|
+
addrinfo_timeout_supported? ? { timeout: FQDN_LOOKUP_TIMEOUT } : {}
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def addrinfo_timeout_supported?
|
|
76
|
+
RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0')
|
|
59
77
|
end
|
|
60
78
|
|
|
61
79
|
def exists_and_valid_fqdn?(fqdn, hostname)
|
|
@@ -10,6 +10,11 @@ module Facter
|
|
|
10
10
|
|
|
11
11
|
init_resolver
|
|
12
12
|
|
|
13
|
+
# Upper bound, in seconds, for the fqdn lookup. A hung name service
|
|
14
|
+
# otherwise stalls fact collection until the agent's runtimeout fires
|
|
15
|
+
# (OpenVoxProject/openvox#485). Only applied on Rubies that honour it.
|
|
16
|
+
FQDN_LOOKUP_TIMEOUT = 10
|
|
17
|
+
|
|
13
18
|
class << self
|
|
14
19
|
private
|
|
15
20
|
|
|
@@ -65,16 +70,35 @@ module Facter
|
|
|
65
70
|
|
|
66
71
|
def retrieve_fqdn_for_host(host)
|
|
67
72
|
begin
|
|
68
|
-
|
|
73
|
+
addr = Addrinfo.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME,
|
|
74
|
+
**addrinfo_options)[0]
|
|
69
75
|
rescue StandardError => e
|
|
70
|
-
log.debug("
|
|
76
|
+
log.debug("Addrinfo.getaddrinfo failed to retrieve fqdn for hostname #{host} with: #{e}")
|
|
77
|
+
# The name service is not answering. The FFI lookup below has no
|
|
78
|
+
# timeout and holds the GVL while it waits, so do not try it.
|
|
79
|
+
return if lookup_timed_out?(e)
|
|
71
80
|
end
|
|
72
81
|
|
|
73
|
-
|
|
82
|
+
name = addr&.canonname
|
|
83
|
+
return name if exists_and_not_empty?(name) && host != name && name != addr.ip_address
|
|
74
84
|
|
|
75
85
|
retrieve_fqdn_for_host_with_ffi(host)
|
|
76
86
|
end
|
|
77
87
|
|
|
88
|
+
def lookup_timed_out?(error)
|
|
89
|
+
error.is_a?(Errno::ETIMEDOUT) || (defined?(IO::TimeoutError) && error.is_a?(IO::TimeoutError))
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Addrinfo.getaddrinfo only honours the timeout keyword from Ruby 4.0
|
|
93
|
+
# on. Older MRI accepts and ignores it; JRuby does not accept it.
|
|
94
|
+
def addrinfo_options
|
|
95
|
+
addrinfo_timeout_supported? ? { timeout: FQDN_LOOKUP_TIMEOUT } : {}
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def addrinfo_timeout_supported?
|
|
99
|
+
RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0')
|
|
100
|
+
end
|
|
101
|
+
|
|
78
102
|
def retrieve_fqdn_for_host_with_ffi(host)
|
|
79
103
|
require_relative '../../../facter/util/resolvers/ffi/hostname'
|
|
80
104
|
|
data/lib/facter/version.rb
CHANGED
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.1
|
|
4
|
+
version: 6.2.1
|
|
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.
|
|
90
|
+
version: 1.91.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.
|
|
97
|
+
version: 1.91.0
|
|
98
98
|
- !ruby/object:Gem::Dependency
|
|
99
99
|
name: rubocop-performance
|
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -1287,7 +1287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1287
1287
|
- !ruby/object:Gem::Version
|
|
1288
1288
|
version: '0'
|
|
1289
1289
|
requirements: []
|
|
1290
|
-
rubygems_version: 4.0.
|
|
1290
|
+
rubygems_version: 4.0.20
|
|
1291
1291
|
specification_version: 4
|
|
1292
1292
|
summary: OpenFact, a system inventory tool
|
|
1293
1293
|
test_files: []
|