facter 4.8.0 → 4.9.0
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/containers.rb +2 -2
- data/lib/facter/resolvers/partitions.rb +38 -16
- data/lib/facter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97c091ad872480f9a35f8c56682e89b65cd221d2b7da74b6bab229e37e27dda0
|
4
|
+
data.tar.gz: c55e4ec6c3e39148ca2c8ce0819eecc4dcf33eddd1ece53442d293eddb405955
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d87380c0d913de5c09f664a5b9a7a35a26434ff806b5788c4712b70cfa6bb85e9fa6670e9bd05dbd275a6f87cd20001d620596e97f732b351d05afe9c5a47d7
|
7
|
+
data.tar.gz: 5900798a818340f42464fff9eec375d2810157f1b73a143fb0191c342149f92634344a4077589af2c19597d3c984aff673bfcb611b14f59a6438c1f2f27eb232
|
@@ -43,7 +43,7 @@ module Facter
|
|
43
43
|
|
44
44
|
info = {}
|
45
45
|
case container
|
46
|
-
when '
|
46
|
+
when 'lxc'
|
47
47
|
vm = 'lxc'
|
48
48
|
when 'podman'
|
49
49
|
vm = 'podman'
|
@@ -54,7 +54,7 @@ module Facter
|
|
54
54
|
info = { 'id' => Facter::Util::FileHelper.safe_read('/etc/machine-id', nil).strip }
|
55
55
|
else
|
56
56
|
vm = 'container_other'
|
57
|
-
log.warn("Container runtime, '#{container}', is unsupported, setting to
|
57
|
+
log.warn("Container runtime, '#{container}', is unsupported, setting to '#{vm}'")
|
58
58
|
end
|
59
59
|
@fact_list[:vm] = vm
|
60
60
|
@fact_list[:hypervisor] = { vm.to_sym => info } if vm
|
@@ -69,13 +69,14 @@ module Facter
|
|
69
69
|
size: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(size_bytes),
|
70
70
|
backing_file: backing_file }
|
71
71
|
info_hash.merge!(populate_from_syscalls(partition_name, blkid_and_lsblk))
|
72
|
-
@fact_list[:partitions][partition_name] = info_hash.
|
72
|
+
@fact_list[:partitions][partition_name] = info_hash.compact
|
73
73
|
end
|
74
74
|
|
75
75
|
def populate_from_syscalls(partition_name, blkid_and_lsblk)
|
76
|
-
|
76
|
+
# Prefer lsblk over blkid since lsblk does not require root, returns more information, and is recommended by blkid
|
77
|
+
part_info = populate_from_lsblk(partition_name, blkid_and_lsblk)
|
77
78
|
|
78
|
-
return
|
79
|
+
return populate_from_blkid(partition_name, blkid_and_lsblk) if part_info.empty?
|
79
80
|
|
80
81
|
part_info
|
81
82
|
end
|
@@ -121,26 +122,47 @@ module Facter
|
|
121
122
|
def populate_from_lsblk(partition_name, blkid_and_lsblk)
|
122
123
|
return {} unless available?('lsblk', blkid_and_lsblk)
|
123
124
|
|
124
|
-
|
125
|
+
lsblk_version_raw = Facter::Core::Execution.execute('lsblk --version 2>&1', logger: log)
|
126
|
+
# Return if the version of lsblk is too old (< 2.22) to support the --version flag
|
127
|
+
lsblk_version_raw.match?(/ \d\.\d+/) ? lsblk_version = lsblk_version_raw.match(/ \d\.\d+/)[0].to_f : (return {})
|
125
128
|
|
126
|
-
|
127
|
-
return {} if
|
129
|
+
# The -p/--paths option was added in lsblk 2.23, return early and fall back to blkid with earlier versions
|
130
|
+
return {} if lsblk_version < 2.23
|
128
131
|
|
129
|
-
|
130
|
-
end
|
132
|
+
blkid_and_lsblk[:lsblk] ||= execute_and_extract_lsblk_info(lsblk_version)
|
131
133
|
|
132
|
-
|
133
|
-
|
134
|
+
partition_data = blkid_and_lsblk[:lsblk][partition_name]
|
135
|
+
return {} unless partition_data
|
134
136
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
137
|
+
filesys = partition_data['FSTYPE']
|
138
|
+
uuid = partition_data['UUID']
|
139
|
+
label = partition_data['LABEL']
|
140
|
+
part_uuid = partition_data['PARTUUID']
|
141
|
+
part_label = partition_data['PARTLABEL']
|
142
|
+
part_type = partition_data['PARTTYPE']
|
143
|
+
|
144
|
+
result = { filesystem: filesys, uuid: uuid, label: label, partuuid: part_uuid, partlabel: part_label }
|
145
|
+
result[:parttype] = part_type if part_type
|
141
146
|
|
142
147
|
result
|
143
148
|
end
|
149
|
+
|
150
|
+
def execute_and_extract_lsblk_info(lsblk_version)
|
151
|
+
# lsblk 2.25 added support for GPT partition type GUIDs
|
152
|
+
stdout = if lsblk_version >= 2.25
|
153
|
+
Facter::Core::Execution.execute('lsblk -p -P -o NAME,FSTYPE,UUID,LABEL,PARTUUID,PARTLABEL,PARTTYPE', logger: log)
|
154
|
+
else
|
155
|
+
Facter::Core::Execution.execute('lsblk -p -P -o NAME,FSTYPE,LABEL,UUID,PARTUUID,PARTLABEL', logger: log)
|
156
|
+
end
|
157
|
+
|
158
|
+
output_hash = Hash[*stdout.split(/^(NAME=\S+)/)[1..-1]]
|
159
|
+
output_hash.transform_keys! { |key| key.delete('NAME=')[1..-2] }
|
160
|
+
output_hash.each do |key, value|
|
161
|
+
output_hash[key] = Hash[*value.chomp.rstrip.split(/ ([^= ]+)=/)[1..-1].each { |x| x.delete!('"') }]
|
162
|
+
end
|
163
|
+
output_hash.each_value { |value_hash| value_hash.delete_if { |_k, v| v.empty? } }
|
164
|
+
output_hash.delete_if { |_k, v| v.empty? }
|
165
|
+
end
|
144
166
|
end
|
145
167
|
end
|
146
168
|
end
|
data/lib/facter/version.rb
CHANGED
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.
|
4
|
+
version: 4.9.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-
|
11
|
+
date: 2024-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|