facterdb 2.0.1 → 3.0.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/.rubocop_todo.yml +10 -34
- data/CHANGELOG.md +28 -0
- data/bin/legacy-facts-striper +127 -0
- data/database/list_arch_os_facter.md +6 -16
- data/database/list_facter_os_arch.md +211 -227
- data/database/list_os_arch_facter.md +45 -56
- data/database/list_os_facter_arch.md +210 -229
- data/database/table.md +0 -3
- data/facts/4.0/almalinux-8-x86_64.facts +0 -63
- data/facts/4.0/almalinux-9-x86_64.facts +0 -59
- data/facts/4.0/debian-11-x86_64.facts +0 -58
- data/facts/4.0/freebsd-11-x86_64.facts +0 -42
- data/facts/4.0/freebsd-12-x86_64.facts +0 -42
- data/facts/4.0/freebsd-13-x86_64.facts +0 -42
- data/facts/4.0/opensuse-15-x86_64.facts +0 -54
- data/facts/4.0/oraclelinux-7-x86_64.facts +23 -16
- data/facts/4.0/redhat-8-x86_64.facts +0 -64
- data/facts/4.0/rocky-8-x86_64.facts +0 -60
- data/facts/4.0/rocky-9-x86_64.facts +0 -64
- data/facts/4.0/scientific-7-x86_64.facts +23 -16
- data/facts/4.0/solaris-11-sun4v.facts +0 -6
- data/facts/4.0/ubuntu-18.04-x86_64.facts +0 -60
- data/facts/4.0/ubuntu-20.04-x86_64.facts +0 -60
- data/facts/4.0/ubuntu-21.04-x86_64.facts +0 -60
- data/facts/4.0/ubuntu-21.10-x86_64.facts +0 -60
- data/facts/4.1/almalinux-8-x86_64.facts +0 -63
- data/facts/4.1/almalinux-9-x86_64.facts +0 -59
- data/facts/4.1/debian-11-x86_64.facts +0 -58
- data/facts/4.1/freebsd-11-x86_64.facts +0 -42
- data/facts/4.1/freebsd-12-x86_64.facts +0 -42
- data/facts/4.1/freebsd-13-x86_64.facts +0 -42
- data/facts/4.1/opensuse-15-x86_64.facts +0 -54
- data/facts/4.1/redhat-8-x86_64.facts +0 -64
- data/facts/4.1/rocky-8-x86_64.facts +0 -60
- data/facts/4.1/rocky-9-x86_64.facts +0 -64
- data/facts/4.1/ubuntu-18.04-x86_64.facts +0 -60
- data/facts/4.1/ubuntu-20.04-x86_64.facts +0 -60
- data/facts/4.1/ubuntu-21.04-x86_64.facts +0 -60
- data/facts/4.1/ubuntu-21.10-x86_64.facts +0 -60
- data/facts/4.2/almalinux-8-x86_64.facts +0 -59
- data/facts/4.2/almalinux-9-x86_64.facts +0 -59
- data/facts/4.2/amazon-2022-x86_64.facts +0 -7
- data/facts/4.2/archlinux-x86_64.facts +13 -56
- data/facts/4.2/centos-9-x86_64.facts +0 -62
- data/facts/4.2/darwin-20-x86_64.facts +1 -63
- data/facts/4.2/debian-11-x86_64.facts +0 -58
- data/facts/4.2/debian-12-i386.facts +0 -58
- data/facts/4.2/debian-12-x86_64.facts +0 -58
- data/facts/4.2/fedora-36-x86_64.facts +0 -63
- data/facts/4.2/fedora-37-x86_64.facts +0 -63
- data/facts/4.2/fedora-38-x86_64.facts +0 -62
- data/facts/4.2/fedora-39-x86_64.facts +0 -62
- data/facts/4.2/freebsd-11-x86_64.facts +0 -42
- data/facts/4.2/freebsd-12-x86_64.facts +0 -42
- data/facts/4.2/freebsd-13-x86_64.facts +0 -42
- data/facts/4.2/gentoo-2-x86_64.facts +0 -65
- data/facts/4.2/opensuse-15-x86_64.facts +0 -54
- data/facts/4.2/oraclelinux-7-x86_64.facts +0 -63
- data/facts/4.2/oraclelinux-8-x86_64.facts +0 -63
- data/facts/4.2/oraclelinux-9-x86_64.facts +0 -12
- data/facts/4.2/popos-21.10-x86_64.facts +0 -36
- data/facts/4.2/redhat-8-x86_64.facts +0 -64
- data/facts/4.2/redhat-9-x86_64.facts +0 -64
- data/facts/4.2/rocky-8-x86_64.facts +0 -60
- data/facts/4.2/rocky-9-x86_64.facts +0 -64
- data/facts/4.2/scientific-7-x86_64.facts +0 -63
- data/facts/4.2/sles-12-x86_64.facts +0 -54
- data/facts/4.2/sles-15-x86_64.facts +0 -58
- data/facts/4.2/ubuntu-18.04-x86_64.facts +0 -60
- data/facts/4.2/ubuntu-20.04-x86_64.facts +0 -60
- data/facts/4.2/ubuntu-21.04-x86_64.facts +0 -60
- data/facts/4.2/ubuntu-21.10-x86_64.facts +0 -60
- data/facts/4.2/ubuntu-22.04-x86_64.facts +0 -60
- data/facts/4.2/ubuntu-22.10-x86_64.facts +0 -60
- data/facts/4.2/windows-10-x86_64.facts +1 -44
- data/facts/4.2/windows-11-x86_64.facts +1 -44
- data/facts/4.2/windows-2012 r2-x86_64.facts +1 -42
- data/facts/4.2/windows-2012-x86_64.facts +7 -42
- data/facts/4.2/windows-2016-core-x86_64.facts +7 -43
- data/facts/4.2/windows-2016-x86_64.facts +7 -43
- data/facts/4.2/windows-2019-core-x86_64.facts +1 -43
- data/facts/4.2/windows-2019-x86_64.facts +1 -43
- data/facts/4.2/windows-2022-core-x86_64.facts +1 -44
- data/facts/4.2/windows-2022-x86_64.facts +1 -44
- data/facts/4.3/almalinux-8-x86_64.facts +0 -59
- data/facts/4.3/almalinux-9-x86_64.facts +0 -59
- data/facts/4.3/archlinux-x86_64.facts +13 -56
- data/facts/4.3/centos-9-x86_64.facts +0 -62
- data/facts/4.3/debian-11-x86_64.facts +0 -58
- data/facts/4.3/debian-12-i386.facts +0 -58
- data/facts/4.3/debian-12-x86_64.facts +0 -58
- data/facts/4.3/fedora-36-x86_64.facts +0 -63
- data/facts/4.3/fedora-37-x86_64.facts +0 -63
- data/facts/4.3/fedora-38-x86_64.facts +0 -62
- data/facts/4.3/fedora-39-x86_64.facts +0 -62
- data/facts/4.3/freebsd-13-x86_64.facts +0 -43
- data/facts/4.3/gentoo-2-x86_64.facts +0 -65
- data/facts/4.3/opensuse-15-x86_64.facts +0 -54
- data/facts/4.3/oraclelinux-8-x86_64.facts +0 -68
- data/facts/4.3/oraclelinux-9-x86_64.facts +0 -60
- data/facts/4.3/redhat-8-x86_64.facts +0 -64
- data/facts/4.3/redhat-9-x86_64.facts +0 -64
- data/facts/4.3/rocky-8-x86_64.facts +0 -64
- data/facts/4.3/rocky-9-x86_64.facts +0 -64
- data/facts/4.3/sles-12-x86_64.facts +0 -61
- data/facts/4.3/ubuntu-18.04-x86_64.facts +0 -60
- data/facts/4.3/ubuntu-20.04-x86_64.facts +0 -60
- data/facts/4.3/ubuntu-22.04-x86_64.facts +0 -60
- data/facts/4.3/windows-10-x86_64.facts +1 -44
- data/facts/4.3/windows-11-x86_64.facts +1 -44
- data/facts/4.3/windows-2012 r2-x86_64.facts +2 -43
- data/facts/4.3/windows-2012-x86_64.facts +1 -42
- data/facts/4.3/windows-2016-core-x86_64.facts +1 -43
- data/facts/4.3/windows-2016-x86_64.facts +1 -43
- data/facts/4.3/windows-2019-core-x86_64.facts +1 -43
- data/facts/4.3/windows-2019-x86_64.facts +1 -43
- data/facts/4.3/windows-2022-core-x86_64.facts +1 -44
- data/facts/4.3/windows-2022-x86_64.facts +1 -44
- data/facts/4.4/almalinux-8-x86_64.facts +0 -59
- data/facts/4.4/almalinux-9-x86_64.facts +0 -59
- data/facts/4.4/archlinux-x86_64.facts +13 -56
- data/facts/4.4/centos-9-x86_64.facts +0 -62
- data/facts/4.4/debian-11-x86_64.facts +0 -58
- data/facts/4.4/debian-12-i386.facts +0 -58
- data/facts/4.4/debian-12-x86_64.facts +0 -58
- data/facts/4.4/fedora-36-x86_64.facts +0 -63
- data/facts/4.4/fedora-37-x86_64.facts +0 -63
- data/facts/4.4/fedora-38-x86_64.facts +0 -62
- data/facts/4.4/fedora-39-x86_64.facts +0 -62
- data/facts/4.4/freebsd-13-x86_64.facts +0 -41
- data/facts/4.4/gentoo-2-x86_64.facts +0 -65
- data/facts/4.4/opensuse-15-x86_64.facts +0 -54
- data/facts/4.4/oraclelinux-8-x86_64.facts +0 -68
- data/facts/4.4/oraclelinux-9-x86_64.facts +0 -60
- data/facts/4.4/redhat-8-x86_64.facts +0 -64
- data/facts/4.4/redhat-9-x86_64.facts +0 -64
- data/facts/4.4/rocky-8-x86_64.facts +0 -64
- data/facts/4.4/rocky-9-x86_64.facts +0 -64
- data/facts/4.4/sles-12-x86_64.facts +0 -61
- data/facts/4.4/ubuntu-18.04-x86_64.facts +0 -60
- data/facts/4.4/ubuntu-20.04-x86_64.facts +0 -60
- data/facts/4.4/ubuntu-22.04-x86_64.facts +0 -60
- data/facts/4.4/windows-10-x86_64.facts +1 -44
- data/facts/4.4/windows-11-x86_64.facts +1 -44
- data/facts/4.4/windows-2012 r2-x86_64.facts +1 -42
- data/facts/4.4/windows-2012-x86_64.facts +1 -42
- data/facts/4.4/windows-2016-core-x86_64.facts +1 -43
- data/facts/4.4/windows-2016-x86_64.facts +2 -44
- data/facts/4.4/windows-2019-core-x86_64.facts +1 -43
- data/facts/4.4/windows-2019-x86_64.facts +1 -43
- data/facts/4.4/windows-2022-core-x86_64.facts +1 -44
- data/facts/4.4/windows-2022-x86_64.facts +1 -44
- data/facts/4.5/almalinux-8-x86_64.facts +0 -59
- data/facts/4.5/almalinux-9-x86_64.facts +0 -59
- data/facts/4.5/amazon-2-x86_64.facts +0 -54
- data/facts/4.5/archlinux-x86_64.facts +13 -56
- data/facts/4.5/centos-9-x86_64.facts +0 -62
- data/facts/4.5/debian-11-x86_64.facts +0 -58
- data/facts/4.5/debian-12-x86_64.facts +0 -58
- data/facts/4.5/fedora-36-x86_64.facts +0 -63
- data/facts/4.5/fedora-37-x86_64.facts +0 -63
- data/facts/4.5/fedora-38-x86_64.facts +0 -62
- data/facts/4.5/fedora-39-x86_64.facts +0 -62
- data/facts/4.5/freebsd-12-x86_64.facts +0 -43
- data/facts/4.5/freebsd-13-x86_64.facts +0 -43
- data/facts/4.5/gentoo-2-x86_64.facts +0 -65
- data/facts/4.5/opensuse-15-x86_64.facts +0 -54
- data/facts/4.5/oraclelinux-8-x86_64.facts +0 -68
- data/facts/4.5/oraclelinux-9-x86_64.facts +0 -60
- data/facts/4.5/redhat-8-x86_64.facts +0 -64
- data/facts/4.5/redhat-9-x86_64.facts +0 -64
- data/facts/4.5/rocky-8-x86_64.facts +0 -64
- data/facts/4.5/rocky-9-x86_64.facts +0 -64
- data/facts/4.5/ubuntu-18.04-x86_64.facts +0 -60
- data/facts/4.5/ubuntu-20.04-x86_64.facts +0 -60
- data/facts/4.5/ubuntu-22.04-x86_64.facts +0 -60
- data/facts/4.5/windows-10-x86_64.facts +1 -44
- data/facts/4.5/windows-11-x86_64.facts +1 -44
- data/facts/4.5/windows-2019-x86_64.facts +1 -43
- data/facts/4.5/windows-2022-x86_64.facts +1 -44
- data/facts/4.6/almalinux-8-x86_64.facts +0 -59
- data/facts/4.6/almalinux-9-x86_64.facts +0 -59
- data/facts/4.6/archlinux-x86_64.facts +13 -56
- data/facts/4.6/centos-9-x86_64.facts +0 -62
- data/facts/4.6/debian-11-x86_64.facts +0 -58
- data/facts/4.6/debian-12-x86_64.facts +0 -58
- data/facts/4.6/fedora-36-x86_64.facts +0 -63
- data/facts/4.6/fedora-37-x86_64.facts +0 -63
- data/facts/4.6/fedora-38-x86_64.facts +0 -62
- data/facts/4.6/fedora-39-x86_64.facts +0 -62
- data/facts/4.6/gentoo-2-x86_64.facts +0 -65
- data/facts/4.6/oraclelinux-8-x86_64.facts +0 -68
- data/facts/4.6/oraclelinux-9-x86_64.facts +0 -60
- data/facts/4.6/redhat-8-x86_64.facts +0 -64
- data/facts/4.6/redhat-9-x86_64.facts +0 -64
- data/facts/4.6/rocky-9-x86_64.facts +0 -64
- data/facts/4.6/ubuntu-20.04-x86_64.facts +0 -60
- data/facts/4.6/ubuntu-22.04-x86_64.facts +0 -60
- data/facts/4.6/windows-10-x86_64.facts +1 -44
- data/facts/4.6/windows-11-x86_64.facts +1 -44
- data/facts/4.6/windows-2019-x86_64.facts +1 -43
- data/facts/4.6/windows-2022-x86_64.facts +1 -44
- data/facts/4.7/almalinux-8-x86_64.facts +0 -59
- data/facts/4.7/almalinux-9-x86_64.facts +0 -59
- data/facts/4.7/archlinux-x86_64.facts +13 -56
- data/facts/4.7/centos-9-x86_64.facts +0 -62
- data/facts/4.7/debian-11-x86_64.facts +0 -58
- data/facts/4.7/debian-12-x86_64.facts +0 -58
- data/facts/4.7/fedora-36-x86_64.facts +0 -63
- data/facts/4.7/fedora-37-x86_64.facts +0 -63
- data/facts/4.7/fedora-38-x86_64.facts +0 -62
- data/facts/4.7/fedora-39-x86_64.facts +0 -62
- data/facts/4.7/gentoo-2-x86_64.facts +0 -65
- data/facts/4.7/openbsd-7-x86_64.facts +0 -31
- data/facts/4.7/opensuse-15-x86_64.facts +0 -54
- data/facts/4.7/oraclelinux-8-x86_64.facts +0 -68
- data/facts/4.7/oraclelinux-9-x86_64.facts +0 -60
- data/facts/4.7/redhat-8-x86_64.facts +0 -64
- data/facts/4.7/redhat-9-x86_64.facts +0 -64
- data/facts/4.7/rocky-9-x86_64.facts +0 -64
- data/facts/4.7/ubuntu-20.04-x86_64.facts +0 -60
- data/facts/4.7/ubuntu-22.04-x86_64.facts +0 -60
- data/facts/4.7/windows-10-x86_64.facts +1 -44
- data/facts/4.7/windows-11-x86_64.facts +1 -44
- data/facts/4.7/windows-2019-x86_64.facts +1 -43
- data/facts/4.7/windows-2022-x86_64.facts +1 -44
- data/facts/Vagrantfile +0 -32
- data/facts/get_facts.sh +10 -10
- data/facts/windows_get_facts.ps1 +1 -1
- data/lib/facterdb/bin.rb +1 -1
- data/lib/facterdb/version.rb +1 -1
- data/lib/facterdb.rb +6 -33
- data/spec/facter_db_spec.rb +27 -91
- data/spec/facts_spec.rb +24 -2
- metadata +4 -18
- data/facts/4.0/centos-7-x86_64.facts +0 -694
- data/facts/4.0/centos-8-x86_64.facts +0 -512
- data/facts/4.0/redhat-7-x86_64.facts +0 -694
- data/facts/4.1/centos-7-x86_64.facts +0 -582
- data/facts/4.1/centos-8-x86_64.facts +0 -514
- data/facts/4.2/centos-7-x86_64.facts +0 -593
- data/facts/4.2/centos-8-x86_64.facts +0 -521
- data/facts/4.2/redhat-7-x86_64.facts +0 -536
- data/facts/4.3/centos-7-x86_64.facts +0 -592
- data/facts/4.3/centos-8-x86_64.facts +0 -521
- data/facts/4.4/centos-7-x86_64.facts +0 -592
- data/facts/4.4/centos-8-x86_64.facts +0 -521
- data/facts/4.5/centos-7-x86_64.facts +0 -602
- data/facts/4.5/centos-8-x86_64.facts +0 -527
- data/facts/4.6/centos-8-x86_64.facts +0 -529
- data/facts/4.7/centos-8-x86_64.facts +0 -529
data/lib/facterdb.rb
CHANGED
|
@@ -78,37 +78,6 @@ module FacterDB
|
|
|
78
78
|
(external_fact_files + default_fact_files).uniq
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
# @deprecated Use {.get_facts} instead.
|
|
82
|
-
def self.get_os_facts(facter_version = '*', filter = [])
|
|
83
|
-
if facter_version == '*'
|
|
84
|
-
if filter.is_a?(Array)
|
|
85
|
-
filter_str = filter.map { |f| f.map { |k, v| "#{k}=#{v}" }.join(' and ') }.join(' or ')
|
|
86
|
-
elsif filter.is_a?(Hash)
|
|
87
|
-
filter_str = filter.map { |k, v| "#{k}=#{v}" }.join(' and ')
|
|
88
|
-
elsif filter.is_a?(String)
|
|
89
|
-
filter_str = filter
|
|
90
|
-
else
|
|
91
|
-
raise 'filter must be either an Array a Hash or a String'
|
|
92
|
-
end
|
|
93
|
-
elsif filter.is_a?(Array)
|
|
94
|
-
filter_str = "facterversion=/^#{facter_version}/ and (#{filter.map do |f|
|
|
95
|
-
f.map do |k, v|
|
|
96
|
-
"#{k}=#{v}"
|
|
97
|
-
end.join(' and ')
|
|
98
|
-
end.join(' or ')})"
|
|
99
|
-
elsif filter.is_a?(Hash)
|
|
100
|
-
filter_str = "facterversion=/^#{facter_version}/ and (#{filter.map { |k, v| "#{k}=#{v}" }.join(' and ')})"
|
|
101
|
-
elsif filter.is_a?(String)
|
|
102
|
-
filter_str = "facterversion=/^#{facter_version}/ and (#{filter})"
|
|
103
|
-
else
|
|
104
|
-
raise 'filter must be either an Array a Hash or a String'
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
warn "[DEPRECATION] `get_os_facts` is deprecated. Please use `get_facts(#{filter_str})` instead."
|
|
108
|
-
|
|
109
|
-
get_facts(filter_str)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
81
|
# @return [String] the string filter
|
|
113
82
|
# @param filter [Object] The filter to convert to jgrep string
|
|
114
83
|
def self.generate_filter_str(filter = nil)
|
|
@@ -137,13 +106,17 @@ module FacterDB
|
|
|
137
106
|
|
|
138
107
|
# @return [Array[Hash[Symbol, Any]]] array of hashes of facts
|
|
139
108
|
# @param filter [Object] The filter to convert to jgrep string
|
|
140
|
-
|
|
109
|
+
# @param symbolize_keys [Boolean]
|
|
110
|
+
# Whether to symbolize the keys. Note this is only on the top level and not
|
|
111
|
+
# on nested values.
|
|
112
|
+
def self.get_facts(filter = nil, cache = true, symbolize_keys: true)
|
|
141
113
|
if cache && filter && filter == Thread.current[:facterdb_last_filter_seen]
|
|
142
114
|
return Thread.current[:facterdb_last_facts_seen]
|
|
143
115
|
end
|
|
144
116
|
|
|
145
117
|
filter_str = generate_filter_str(filter)
|
|
146
|
-
result = JGrep.jgrep(database, filter_str)
|
|
118
|
+
result = JGrep.jgrep(database, filter_str)
|
|
119
|
+
result = result.map { |hash| hash.transform_keys(&:to_sym) } if symbolize_keys
|
|
147
120
|
if cache
|
|
148
121
|
Thread.current[:facterdb_last_filter_seen] = filter
|
|
149
122
|
Thread.current[:facterdb_last_facts_seen] = result
|
data/spec/facter_db_spec.rb
CHANGED
|
@@ -197,91 +197,6 @@ describe FacterDB do
|
|
|
197
197
|
end
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
-
describe '.get_os_facts' do
|
|
201
|
-
subject(:result) { FacterDB.get_os_facts(facter_version, filter) }
|
|
202
|
-
|
|
203
|
-
before do
|
|
204
|
-
object = defined?(Warning) ? Warning : Kernel
|
|
205
|
-
allow(object).to receive(:warn).and_call_original
|
|
206
|
-
allow(object).to receive(:warn).with(a_string_matching(/`get_os_facts` is deprecated/))
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
context 'without parameters' do
|
|
210
|
-
subject(:result) { FacterDB.get_os_facts }
|
|
211
|
-
|
|
212
|
-
include_examples 'returns a result'
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
context 'when matching all Facter versions' do
|
|
216
|
-
let(:facter_version) { '*' }
|
|
217
|
-
|
|
218
|
-
context 'with an Array filter' do
|
|
219
|
-
let(:filter) { [{ osfamily: 'Debian' }] }
|
|
220
|
-
|
|
221
|
-
include_examples 'returns a result'
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
context 'with a Hash filter' do
|
|
225
|
-
let(:filter) { { osfamily: 'Debian' } }
|
|
226
|
-
|
|
227
|
-
include_examples 'returns a result'
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
context 'with a String filter' do
|
|
231
|
-
let(:filter) { 'osfamily=Debian' }
|
|
232
|
-
|
|
233
|
-
include_examples 'returns a result'
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
context 'with a filter of an unsupported type' do
|
|
237
|
-
let(:filter) { true }
|
|
238
|
-
|
|
239
|
-
it 'raises an error' do
|
|
240
|
-
expect { result }.to raise_error(/filter must be either/)
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
context 'when matching a specific facter version' do
|
|
246
|
-
let(:facter_version) { '4.0.52' }
|
|
247
|
-
|
|
248
|
-
shared_examples 'returns only the specified version' do
|
|
249
|
-
it 'only includes fact sets for the specified version' do
|
|
250
|
-
expect(result).to all(include(facterversion: match(/^4\.0/)))
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
context 'with an Array filter' do
|
|
255
|
-
let(:filter) { [{ osfamily: 'Debian' }] }
|
|
256
|
-
|
|
257
|
-
include_examples 'returns a result'
|
|
258
|
-
include_examples 'returns only the specified version'
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
context 'with a Hash filter' do
|
|
262
|
-
let(:filter) { { osfamily: 'Debian' } }
|
|
263
|
-
|
|
264
|
-
include_examples 'returns a result'
|
|
265
|
-
include_examples 'returns only the specified version'
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
context 'with a String filter' do
|
|
269
|
-
let(:filter) { 'osfamily=Debian' }
|
|
270
|
-
|
|
271
|
-
include_examples 'returns a result'
|
|
272
|
-
include_examples 'returns only the specified version'
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
context 'with a filter of an unsupported type' do
|
|
276
|
-
let(:filter) { true }
|
|
277
|
-
|
|
278
|
-
it 'raises an error' do
|
|
279
|
-
expect { result }.to raise_error(/filter must be either/)
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
|
|
285
200
|
describe '.valid_filters?' do
|
|
286
201
|
it 'invalid and false' do
|
|
287
202
|
expect(FacterDB.valid_filters?('and')).to be_falsey
|
|
@@ -302,11 +217,11 @@ describe FacterDB do
|
|
|
302
217
|
end
|
|
303
218
|
|
|
304
219
|
it 'with hash' do
|
|
305
|
-
expect(FacterDB.generate_filter_str({
|
|
220
|
+
expect(FacterDB.generate_filter_str({ kernel: 'Linux' })).to eq('kernel=Linux')
|
|
306
221
|
end
|
|
307
222
|
|
|
308
223
|
it 'with Array' do
|
|
309
|
-
expect(FacterDB.generate_filter_str([
|
|
224
|
+
expect(FacterDB.generate_filter_str([kernel: 'Linux'])).to eq('(kernel=Linux)')
|
|
310
225
|
end
|
|
311
226
|
|
|
312
227
|
it 'empty' do
|
|
@@ -319,28 +234,49 @@ describe FacterDB do
|
|
|
319
234
|
end
|
|
320
235
|
|
|
321
236
|
describe '.get_facts' do
|
|
322
|
-
subject(:result) { FacterDB.get_facts(filter) }
|
|
237
|
+
subject(:result) { FacterDB.get_facts(filter, symbolize_keys: symbolize_keys) }
|
|
323
238
|
|
|
324
239
|
let(:filter) { nil }
|
|
240
|
+
let(:symbolize_keys) { nil }
|
|
325
241
|
|
|
326
242
|
context 'without parameters' do
|
|
327
243
|
include_examples 'returns a result'
|
|
328
244
|
end
|
|
329
245
|
|
|
246
|
+
context 'with stringified output' do
|
|
247
|
+
let(:symbolize_keys) { false }
|
|
248
|
+
|
|
249
|
+
it 'returns strings as keys in factsets' do
|
|
250
|
+
result.each do |factset|
|
|
251
|
+
expect(factset.keys).to all(be_an_instance_of(String))
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
context 'with symbolized output' do
|
|
257
|
+
let(:symbolize_keys) { true }
|
|
258
|
+
|
|
259
|
+
it 'returns strings as keys in factsets' do
|
|
260
|
+
result.each do |factset|
|
|
261
|
+
expect(factset.keys).to all(be_an_instance_of(Symbol))
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
330
266
|
context 'with an Array filter' do
|
|
331
|
-
let(:filter) { [
|
|
267
|
+
let(:filter) { [kernel: 'Linux'] }
|
|
332
268
|
|
|
333
269
|
include_examples 'returns a result'
|
|
334
270
|
end
|
|
335
271
|
|
|
336
272
|
context 'with a Hash filter' do
|
|
337
|
-
let(:filter) { {
|
|
273
|
+
let(:filter) { { kernel: 'Linux' } }
|
|
338
274
|
|
|
339
275
|
include_examples 'returns a result'
|
|
340
276
|
end
|
|
341
277
|
|
|
342
278
|
context 'with a String filter' do
|
|
343
|
-
let(:filter) { '
|
|
279
|
+
let(:filter) { 'kernel=Linux' }
|
|
344
280
|
|
|
345
281
|
include_examples 'returns a result'
|
|
346
282
|
end
|
data/spec/facts_spec.rb
CHANGED
|
@@ -98,8 +98,8 @@ describe 'Default Facts' do
|
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
it 'contains the legacy ipaddress fact' do
|
|
102
|
-
expect(content['ipaddress']).to
|
|
101
|
+
it 'does not contains the legacy ipaddress fact' do
|
|
102
|
+
expect(content['ipaddress']).to be_nil
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
it 'contains no facts from puppetlabs/stdlib' do
|
|
@@ -117,6 +117,28 @@ describe 'Default Facts' do
|
|
|
117
117
|
expect(content['systemd_version']).to be_nil
|
|
118
118
|
expect(content['systemd_internal_services']).to be_nil
|
|
119
119
|
end
|
|
120
|
+
|
|
121
|
+
# those are used in newer rspec-puppet-facts versions
|
|
122
|
+
# by ensuring those facts exists, we can drop a huge amount of logic in rspec-puppet-facts
|
|
123
|
+
it 'contains the mandatory OS facts' do
|
|
124
|
+
expect(content['os']['release']['major']).to not_be_nil.and not_be_empty
|
|
125
|
+
expect(content['os']['name']).to not_be_nil.and not_be_empty
|
|
126
|
+
expect(content['os']['hardware']).to not_be_nil.and not_be_empty
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'does not contain a legacy hostname, domain and fqdn fact' do
|
|
130
|
+
expect(content['hostname']).to be_nil
|
|
131
|
+
expect(content['fqdn']).to be_nil
|
|
132
|
+
expect(content['domain']).to be_nil
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'does not contain the legacy osfamily fact' do
|
|
136
|
+
expect(content['osfamily']).to be_nil
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it 'does not contain the legacy operatingsystem fact' do
|
|
140
|
+
expect(content['operatingsystem']).to be_nil
|
|
141
|
+
end
|
|
120
142
|
end
|
|
121
143
|
end
|
|
122
144
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: facterdb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vox Pupuli
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-06-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: coveralls
|
|
@@ -111,6 +111,7 @@ email:
|
|
|
111
111
|
- voxpupuli@groups.io
|
|
112
112
|
executables:
|
|
113
113
|
- facterdb
|
|
114
|
+
- legacy-facts-striper
|
|
114
115
|
extensions: []
|
|
115
116
|
extra_rdoc_files: []
|
|
116
117
|
files:
|
|
@@ -130,6 +131,7 @@ files:
|
|
|
130
131
|
- README.md
|
|
131
132
|
- Rakefile
|
|
132
133
|
- bin/facterdb
|
|
134
|
+
- bin/legacy-facts-striper
|
|
133
135
|
- database/list_arch_os_facter.md
|
|
134
136
|
- database/list_facter_os_arch.md
|
|
135
137
|
- database/list_os_arch_facter.md
|
|
@@ -152,15 +154,12 @@ files:
|
|
|
152
154
|
- facterdb.gemspec
|
|
153
155
|
- facts/4.0/almalinux-8-x86_64.facts
|
|
154
156
|
- facts/4.0/almalinux-9-x86_64.facts
|
|
155
|
-
- facts/4.0/centos-7-x86_64.facts
|
|
156
|
-
- facts/4.0/centos-8-x86_64.facts
|
|
157
157
|
- facts/4.0/debian-11-x86_64.facts
|
|
158
158
|
- facts/4.0/freebsd-11-x86_64.facts
|
|
159
159
|
- facts/4.0/freebsd-12-x86_64.facts
|
|
160
160
|
- facts/4.0/freebsd-13-x86_64.facts
|
|
161
161
|
- facts/4.0/opensuse-15-x86_64.facts
|
|
162
162
|
- facts/4.0/oraclelinux-7-x86_64.facts
|
|
163
|
-
- facts/4.0/redhat-7-x86_64.facts
|
|
164
163
|
- facts/4.0/redhat-8-x86_64.facts
|
|
165
164
|
- facts/4.0/rocky-8-x86_64.facts
|
|
166
165
|
- facts/4.0/rocky-9-x86_64.facts
|
|
@@ -172,8 +171,6 @@ files:
|
|
|
172
171
|
- facts/4.0/ubuntu-21.10-x86_64.facts
|
|
173
172
|
- facts/4.1/almalinux-8-x86_64.facts
|
|
174
173
|
- facts/4.1/almalinux-9-x86_64.facts
|
|
175
|
-
- facts/4.1/centos-7-x86_64.facts
|
|
176
|
-
- facts/4.1/centos-8-x86_64.facts
|
|
177
174
|
- facts/4.1/debian-11-x86_64.facts
|
|
178
175
|
- facts/4.1/freebsd-11-x86_64.facts
|
|
179
176
|
- facts/4.1/freebsd-12-x86_64.facts
|
|
@@ -190,8 +187,6 @@ files:
|
|
|
190
187
|
- facts/4.2/almalinux-9-x86_64.facts
|
|
191
188
|
- facts/4.2/amazon-2022-x86_64.facts
|
|
192
189
|
- facts/4.2/archlinux-x86_64.facts
|
|
193
|
-
- facts/4.2/centos-7-x86_64.facts
|
|
194
|
-
- facts/4.2/centos-8-x86_64.facts
|
|
195
190
|
- facts/4.2/centos-9-x86_64.facts
|
|
196
191
|
- facts/4.2/darwin-20-x86_64.facts
|
|
197
192
|
- facts/4.2/debian-11-x86_64.facts
|
|
@@ -210,7 +205,6 @@ files:
|
|
|
210
205
|
- facts/4.2/oraclelinux-8-x86_64.facts
|
|
211
206
|
- facts/4.2/oraclelinux-9-x86_64.facts
|
|
212
207
|
- facts/4.2/popos-21.10-x86_64.facts
|
|
213
|
-
- facts/4.2/redhat-7-x86_64.facts
|
|
214
208
|
- facts/4.2/redhat-8-x86_64.facts
|
|
215
209
|
- facts/4.2/redhat-9-x86_64.facts
|
|
216
210
|
- facts/4.2/rocky-8-x86_64.facts
|
|
@@ -237,8 +231,6 @@ files:
|
|
|
237
231
|
- facts/4.3/almalinux-8-x86_64.facts
|
|
238
232
|
- facts/4.3/almalinux-9-x86_64.facts
|
|
239
233
|
- facts/4.3/archlinux-x86_64.facts
|
|
240
|
-
- facts/4.3/centos-7-x86_64.facts
|
|
241
|
-
- facts/4.3/centos-8-x86_64.facts
|
|
242
234
|
- facts/4.3/centos-9-x86_64.facts
|
|
243
235
|
- facts/4.3/debian-11-x86_64.facts
|
|
244
236
|
- facts/4.3/debian-12-i386.facts
|
|
@@ -273,8 +265,6 @@ files:
|
|
|
273
265
|
- facts/4.4/almalinux-8-x86_64.facts
|
|
274
266
|
- facts/4.4/almalinux-9-x86_64.facts
|
|
275
267
|
- facts/4.4/archlinux-x86_64.facts
|
|
276
|
-
- facts/4.4/centos-7-x86_64.facts
|
|
277
|
-
- facts/4.4/centos-8-x86_64.facts
|
|
278
268
|
- facts/4.4/centos-9-x86_64.facts
|
|
279
269
|
- facts/4.4/debian-11-x86_64.facts
|
|
280
270
|
- facts/4.4/debian-12-i386.facts
|
|
@@ -310,8 +300,6 @@ files:
|
|
|
310
300
|
- facts/4.5/almalinux-9-x86_64.facts
|
|
311
301
|
- facts/4.5/amazon-2-x86_64.facts
|
|
312
302
|
- facts/4.5/archlinux-x86_64.facts
|
|
313
|
-
- facts/4.5/centos-7-x86_64.facts
|
|
314
|
-
- facts/4.5/centos-8-x86_64.facts
|
|
315
303
|
- facts/4.5/centos-9-x86_64.facts
|
|
316
304
|
- facts/4.5/debian-11-x86_64.facts
|
|
317
305
|
- facts/4.5/debian-12-x86_64.facts
|
|
@@ -339,7 +327,6 @@ files:
|
|
|
339
327
|
- facts/4.6/almalinux-8-x86_64.facts
|
|
340
328
|
- facts/4.6/almalinux-9-x86_64.facts
|
|
341
329
|
- facts/4.6/archlinux-x86_64.facts
|
|
342
|
-
- facts/4.6/centos-8-x86_64.facts
|
|
343
330
|
- facts/4.6/centos-9-x86_64.facts
|
|
344
331
|
- facts/4.6/debian-11-x86_64.facts
|
|
345
332
|
- facts/4.6/debian-12-x86_64.facts
|
|
@@ -362,7 +349,6 @@ files:
|
|
|
362
349
|
- facts/4.7/almalinux-8-x86_64.facts
|
|
363
350
|
- facts/4.7/almalinux-9-x86_64.facts
|
|
364
351
|
- facts/4.7/archlinux-x86_64.facts
|
|
365
|
-
- facts/4.7/centos-8-x86_64.facts
|
|
366
352
|
- facts/4.7/centos-9-x86_64.facts
|
|
367
353
|
- facts/4.7/debian-11-x86_64.facts
|
|
368
354
|
- facts/4.7/debian-12-x86_64.facts
|