facterdb 1.3.0 → 1.7.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/.github/workflows/release.yml +31 -0
- data/.github/workflows/test.yml +28 -0
- data/CHANGELOG.md +164 -116
- data/Gemfile +2 -2
- data/README.md +109 -99
- data/Rakefile +9 -3
- data/facterdb.gemspec +7 -8
- data/facts/3.11/archlinux-x86_64.facts +11 -1
- data/facts/3.11/solaris-10-i86pc.facts +1 -4
- data/facts/3.11/solaris-11-i86pc.facts +1 -4
- data/facts/3.11/solaris-11-sun4v.facts +1 -4
- data/facts/3.14/almalinux-8-x86_64.facts +522 -0
- data/facts/3.14/archlinux-x86_64.facts +11 -1
- data/facts/3.14/darwin-19-x86_64.facts +412 -0
- data/facts/3.14/solaris-11-i86pc.facts +1 -4
- data/facts/3.14/solaris-11-sun4v.facts +1 -4
- data/facts/3.14/ubuntu-20.04-x86_64.facts +680 -0
- data/facts/3.9/solaris-10-i86pc.facts +0 -3
- data/facts/4.0/almalinux-8-x86_64.facts +307 -0
- data/facts/4.0/centos-7-x86_64.facts +706 -0
- data/facts/4.0/debian-10-x86_64.facts +1091 -0
- data/facts/4.0/solaris-11-sun4v.facts +585 -0
- data/facts/Vagrantfile +8 -1
- data/facts/get_facts.sh +14 -0
- data/lib/facterdb.rb +31 -10
- data/lib/facterdb/version.rb +1 -1
- data/spec/facterdb_spec.rb +36 -0
- data/spec/facts_spec.rb +9 -2
- metadata +17 -30
- data/.travis.yml +0 -28
data/facts/Vagrantfile
CHANGED
@@ -150,7 +150,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
150
150
|
host.vm.provision "shell", path: "get_facts.sh"
|
151
151
|
host.vm.provision "shell", inline: "/sbin/shutdown -h now"
|
152
152
|
end
|
153
|
-
|
153
|
+
config.vm.define "almalinux-8-x86_64" do |host|
|
154
|
+
host.vm.box = "almalinux/8"
|
155
|
+
host.vm.synced_folder ".", "/vagrant"
|
156
|
+
host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools"
|
157
|
+
host.vm.provision "file", source: "Gemfile", destination: "Gemfile"
|
158
|
+
host.vm.provision "shell", path: "get_facts.sh"
|
159
|
+
host.vm.provision "shell", inline: "/sbin/shutdown -h now"
|
160
|
+
end
|
154
161
|
config.vm.define "redhat-8-x86_64" do |host|
|
155
162
|
host.vm.box = "generic/rhel8"
|
156
163
|
host.vm.synced_folder ".", "/vagrant"
|
data/facts/get_facts.sh
CHANGED
@@ -37,6 +37,9 @@ elif test -f /etc/redhat-release ; then
|
|
37
37
|
fedora*)
|
38
38
|
osfamily='Fedora'
|
39
39
|
;;
|
40
|
+
almalinux*)
|
41
|
+
osfamily='AlmaLinux'
|
42
|
+
;;
|
40
43
|
*)
|
41
44
|
echo 'Failed to determine osfamily from /etc/redhat-release'
|
42
45
|
exit 1
|
@@ -150,6 +153,14 @@ case "${osfamily}" in
|
|
150
153
|
yum remove -y puppet6-release
|
151
154
|
fi
|
152
155
|
;;
|
156
|
+
'AlmaLinux')
|
157
|
+
dnf localinstall -y "http://yum.puppetlabs.com/puppet6-release-el-${operatingsystemmajrelease}.noarch.rpm"
|
158
|
+
if dnf install -y puppet-agent; then
|
159
|
+
output_file="/vagrant/$(facter --version | cut -d. -f1,2)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts"
|
160
|
+
mkdir -p $(dirname ${output_file})
|
161
|
+
facter --show-legacy -p -j | tee ${output_file}
|
162
|
+
fi
|
163
|
+
;;
|
153
164
|
|
154
165
|
'Debian')
|
155
166
|
if [[ "serena" =~ ${lsbdistcodename} ]]; then
|
@@ -300,6 +311,9 @@ bundle install --path vendor/bundler
|
|
300
311
|
for version in 1.6.0 1.7.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0; do
|
301
312
|
FACTER_GEM_VERSION="~> ${version}" bundle update
|
302
313
|
case "${operatingsystem}" in
|
314
|
+
almalinux)
|
315
|
+
break
|
316
|
+
;;
|
303
317
|
openbsd)
|
304
318
|
output_file="/vagrant/$(bundle exec facter --version | cut -d. -f1,2)/${operatingsystem}-${operatingsystemrelease}-${hardwaremodel}.facts"
|
305
319
|
;;
|
data/lib/facterdb.rb
CHANGED
@@ -2,6 +2,9 @@ require 'facter'
|
|
2
2
|
require 'jgrep'
|
3
3
|
|
4
4
|
module FacterDB
|
5
|
+
module Errors
|
6
|
+
class InvalidFilter < RuntimeError; end
|
7
|
+
end
|
5
8
|
|
6
9
|
# @return [String] - returns a giant incomprehensible string of concatenated json data
|
7
10
|
def self.database
|
@@ -92,18 +95,36 @@ module FacterDB
|
|
92
95
|
get_facts(filter_str)
|
93
96
|
end
|
94
97
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
# @return [String] - the string filter
|
99
|
+
# @param filter [Object] - The filter to convert to jgrep string
|
100
|
+
def self.generate_filter_str(filter=nil)
|
101
|
+
case filter
|
102
|
+
when ::Array
|
103
|
+
'(' + filter.map { |f| f.map { |k,v | "#{k}=#{v}" }.join(' and ') }.join(') or (') + ')'
|
104
|
+
when ::Hash
|
105
|
+
filter.map { |k,v | "#{k}=#{v}" }.join(' and ')
|
106
|
+
when ::String
|
107
|
+
filter
|
108
|
+
when ::NilClass
|
109
|
+
''
|
104
110
|
else
|
105
|
-
raise
|
111
|
+
raise Errors::InvalidFilter, "filter must be either an Array a Hash, String, or nil, received #{filter.class}"
|
106
112
|
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# @return [Boolean] - true if the filter is valid against the jgrep filter validator
|
116
|
+
# @param filter [Object] - The filter to convert to jgrep string
|
117
|
+
def self.valid_filters?(filters)
|
118
|
+
filter_str = generate_filter_str(filters)
|
119
|
+
JGrep.validate_filters(filter_str).nil?
|
120
|
+
rescue RuntimeError
|
121
|
+
false
|
122
|
+
end
|
123
|
+
|
124
|
+
# @return [Array] - array of hashes of facts
|
125
|
+
# @param filter [Object] - The filter to convert to jgrep string
|
126
|
+
def self.get_facts(filter=nil)
|
127
|
+
filter_str = generate_filter_str(filter)
|
107
128
|
JGrep.jgrep(database, filter_str).map { |hash| Hash[hash.map{ |k, v| [k.to_sym, v] }] }
|
108
129
|
end
|
109
130
|
end
|
data/lib/facterdb/version.rb
CHANGED
data/spec/facterdb_spec.rb
CHANGED
@@ -282,6 +282,42 @@ describe FacterDB do
|
|
282
282
|
end
|
283
283
|
end
|
284
284
|
|
285
|
+
describe '.valid_filters?' do
|
286
|
+
it 'invalid and false' do
|
287
|
+
expect( FacterDB.valid_filters?('and')).to be_falsey
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'valid and true' do
|
291
|
+
expect( FacterDB.valid_filters?('foo')).to be_truthy
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
describe '.generate_filter_str' do
|
296
|
+
it 'invalid type' do
|
297
|
+
expect{FacterDB.generate_filter_str(3)}.to raise_error(FacterDB::Errors::InvalidFilter)
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'with string' do
|
301
|
+
expect(FacterDB.generate_filter_str('foo')).to eq("foo")
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'with hash' do
|
305
|
+
expect(FacterDB.generate_filter_str({:osfamily => 'Debian'})).to eq("osfamily=Debian")
|
306
|
+
end
|
307
|
+
|
308
|
+
it 'with Array' do
|
309
|
+
expect(FacterDB.generate_filter_str([:osfamily => 'Debian'])).to eq("(osfamily=Debian)")
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'empty' do
|
313
|
+
expect(FacterDB.generate_filter_str('')).to eq('')
|
314
|
+
end
|
315
|
+
|
316
|
+
it 'nil filter' do
|
317
|
+
expect(FacterDB.generate_filter_str(nil)).to eq('')
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
285
321
|
describe '.get_facts' do
|
286
322
|
subject(:result) { FacterDB.get_facts(filter) }
|
287
323
|
|
data/spec/facts_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'digest'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
5
|
RSpec::Matchers.define :have_a_unique_hash do
|
5
6
|
match do |actual|
|
@@ -99,9 +100,15 @@ describe 'Default Facts' do
|
|
99
100
|
expect(content['facterversion']).to have_facter_version(facter_dir_path, filepath)
|
100
101
|
end
|
101
102
|
|
102
|
-
it 'contains an ipaddress fact' do
|
103
|
+
it 'contains an ipaddress or networking.ip fact' do
|
103
104
|
pending KNOWN_IPADDRESS_PENDING[relative_path] if KNOWN_IPADDRESS_PENDING.key?(relative_path)
|
104
|
-
|
105
|
+
case content['facterversion']
|
106
|
+
when /^[1-3]/
|
107
|
+
expect(content['ipaddress']).to not_be_nil.and not_be_empty
|
108
|
+
else
|
109
|
+
expect(content['networking']['ip']).to not_be_nil.and not_be_empty
|
110
|
+
end
|
111
|
+
|
105
112
|
end
|
106
113
|
end
|
107
114
|
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: 1.
|
4
|
+
version: 1.7.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:
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -66,40 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: github_changelog_generator
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.10'
|
76
|
-
- - "<"
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: 1.10.4
|
79
|
-
type: :development
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
requirements:
|
83
|
-
- - "~>"
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '1.10'
|
86
|
-
- - "<"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 1.10.4
|
89
69
|
- !ruby/object:Gem::Dependency
|
90
70
|
name: facter
|
91
71
|
requirement: !ruby/object:Gem::Requirement
|
92
72
|
requirements:
|
93
73
|
- - "<"
|
94
74
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
75
|
+
version: 5.0.0
|
96
76
|
type: :runtime
|
97
77
|
prerelease: false
|
98
78
|
version_requirements: !ruby/object:Gem::Requirement
|
99
79
|
requirements:
|
100
80
|
- - "<"
|
101
81
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
82
|
+
version: 5.0.0
|
103
83
|
- !ruby/object:Gem::Dependency
|
104
84
|
name: jgrep
|
105
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,15 +96,16 @@ dependencies:
|
|
116
96
|
version: '0'
|
117
97
|
description: Contains facts from many Facter version on many Operating Systems
|
118
98
|
email:
|
119
|
-
-
|
99
|
+
- voxpupuli@groups.io
|
120
100
|
executables:
|
121
101
|
- facterdb
|
122
102
|
extensions: []
|
123
103
|
extra_rdoc_files: []
|
124
104
|
files:
|
105
|
+
- ".github/workflows/release.yml"
|
106
|
+
- ".github/workflows/test.yml"
|
125
107
|
- ".gitignore"
|
126
108
|
- ".gitmodules"
|
127
|
-
- ".travis.yml"
|
128
109
|
- CHANGELOG.md
|
129
110
|
- Gemfile
|
130
111
|
- HISTORY.md
|
@@ -1292,6 +1273,7 @@ files:
|
|
1292
1273
|
- facts/3.13/windows-2016-x86_64.facts
|
1293
1274
|
- facts/3.13/windows-2019-x86_64.facts
|
1294
1275
|
- facts/3.14/VirtuozzoLinux-7-x86_64.facts
|
1276
|
+
- facts/3.14/almalinux-8-x86_64.facts
|
1295
1277
|
- facts/3.14/amazon-2-x86_64.facts
|
1296
1278
|
- facts/3.14/amazon-2016-x86_64.facts
|
1297
1279
|
- facts/3.14/archlinux-x86_64.facts
|
@@ -1301,6 +1283,7 @@ files:
|
|
1301
1283
|
- facts/3.14/darwin-16-x86_64.facts
|
1302
1284
|
- facts/3.14/darwin-17-x86_64.facts
|
1303
1285
|
- facts/3.14/darwin-18-x86_64.facts
|
1286
|
+
- facts/3.14/darwin-19-x86_64.facts
|
1304
1287
|
- facts/3.14/debian-10-x86_64.facts
|
1305
1288
|
- facts/3.14/debian-8-x86_64.facts
|
1306
1289
|
- facts/3.14/debian-9-x86_64.facts
|
@@ -1327,6 +1310,7 @@ files:
|
|
1327
1310
|
- facts/3.14/ubuntu-14.04-x86_64.facts
|
1328
1311
|
- facts/3.14/ubuntu-16.04-x86_64.facts
|
1329
1312
|
- facts/3.14/ubuntu-18.04-x86_64.facts
|
1313
|
+
- facts/3.14/ubuntu-20.04-x86_64.facts
|
1330
1314
|
- facts/3.14/windows-10-i386.facts
|
1331
1315
|
- facts/3.14/windows-10-x86_64.facts
|
1332
1316
|
- facts/3.14/windows-2012 r2-core-x86_64.facts
|
@@ -1709,6 +1693,10 @@ files:
|
|
1709
1693
|
- facts/3.9/windows-2012-x86_64.facts
|
1710
1694
|
- facts/3.9/windows-2016-x86_64.facts
|
1711
1695
|
- facts/3.9/windows-2019-x86_64.facts
|
1696
|
+
- facts/4.0/almalinux-8-x86_64.facts
|
1697
|
+
- facts/4.0/centos-7-x86_64.facts
|
1698
|
+
- facts/4.0/debian-10-x86_64.facts
|
1699
|
+
- facts/4.0/solaris-11-sun4v.facts
|
1712
1700
|
- facts/Gemfile
|
1713
1701
|
- facts/Vagrantfile
|
1714
1702
|
- facts/Windows_README.md
|
@@ -1737,7 +1725,7 @@ files:
|
|
1737
1725
|
- spec/facterdb_spec.rb
|
1738
1726
|
- spec/facts_spec.rb
|
1739
1727
|
- spec/spec_helper.rb
|
1740
|
-
homepage: http://github.com/
|
1728
|
+
homepage: http://github.com/voxpupuli/facterdb
|
1741
1729
|
licenses:
|
1742
1730
|
- Apache-2.0
|
1743
1731
|
metadata: {}
|
@@ -1756,8 +1744,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1756
1744
|
- !ruby/object:Gem::Version
|
1757
1745
|
version: '0'
|
1758
1746
|
requirements: []
|
1759
|
-
|
1760
|
-
rubygems_version: 2.7.7
|
1747
|
+
rubygems_version: 3.2.22
|
1761
1748
|
signing_key:
|
1762
1749
|
specification_version: 4
|
1763
1750
|
summary: A Database of OS facts provided by Facter
|
data/.travis.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
cache: bundler
|
4
|
-
script:
|
5
|
-
- bundle exec rake spec
|
6
|
-
rvm:
|
7
|
-
- 2.3
|
8
|
-
env:
|
9
|
-
- FACTER_GEM_VERSION="~> 1.6.0"
|
10
|
-
- FACTER_GEM_VERSION="~> 1.7.0"
|
11
|
-
- FACTER_GEM_VERSION="~> 2.0.0"
|
12
|
-
- FACTER_GEM_VERSION="~> 2.1.0"
|
13
|
-
- FACTER_GEM_VERSION="~> 2.2.0"
|
14
|
-
- FACTER_GEM_VERSION="~> 2.3.0"
|
15
|
-
- FACTER_GEM_VERSION="~> 2.4.0"
|
16
|
-
- FACTER_GEM_VERSION="~> 2.0" COVERAGE=yes
|
17
|
-
matrix:
|
18
|
-
fast_finish: true
|
19
|
-
notifications:
|
20
|
-
email: false
|
21
|
-
deploy:
|
22
|
-
provider: rubygems
|
23
|
-
api_key:
|
24
|
-
secure: Ja5JTWVsXcpYKVBrM35h9jLBoEuSm2f28A7UBk/culOC45dXzlS1BQfcxuVuNeRZ1/pPHHOnCM11yfliqJ2eF6FsNTqaLiFnNDAP/qPI2an9T1FO9dnBQ/EJp3jMp6DcXvb7CbYMS9n61CM+W0RzAdGpRK6AGLFAN5Ttba1SEIGPtlBV6e0MOu7Ma9DI7tFboqi3quSTPhvXUHpyYXDicQ+2/eijAWde/Tll3wJB8ir9lqmNh/xV9qHKdjZsAK8PG6PiuuaVsBUiQMFnapZD2OZmgLJFrOLnTvvntdcsQecsvlykHZXgbqta372KxDRIsJ2ld9a2GiL/wZDvZ9SWC+r5RAKxkvtKyQPezecO9yjJxaYAryY06YA92WibmZPBuODI4iz0MkueiulXjT4W5e/04Dj+oHtNTSGOucM5J8a08NN0UNW0IpJL/VDIw7viyXc2DzwrPJGzn/jfjzvjX7ITNKS2DIPNps/thmiGu88+Snx/5O3Cmg15OgrIlSQfkJmnLedR+qQHoE5Xk4laIJ/+4L3o9X5lFwzQYneY4u/xedKrZl66idlMGqxkbmzyf4gjKzq7pZPnFePavJwrJlCU7HXangYcOotBo4Lb2lwpeL2ilgrgLn1p7bfLdTlQcNCH4WyRAyOlVtN4vNPVc7+a3n+BL0gz7Y1B7NQUukQ=
|
25
|
-
gem: facterdb
|
26
|
-
on:
|
27
|
-
tags: true
|
28
|
-
repo: camptocamp/facterdb
|