facterdb 1.0.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +19 -11
  4. data/CHANGELOG.md +76 -6
  5. data/README.md +13 -7
  6. data/Rakefile +16 -4
  7. data/facterdb.gemspec +1 -2
  8. data/facts/1.6/amazon-2-x86_64.facts +53 -0
  9. data/facts/1.6/amazon-2016-x86_64.facts +62 -0
  10. data/facts/1.6/centos-8-x86_64.facts +59 -0
  11. data/facts/1.7/amazon-2-x86_64.facts +76 -0
  12. data/facts/1.7/amazon-2016-x86_64.facts +78 -0
  13. data/facts/1.7/centos-8-x86_64.facts +82 -0
  14. data/facts/2.0/amazon-2-x86_64.facts +77 -0
  15. data/facts/2.0/amazon-2016-x86_64.facts +79 -0
  16. data/facts/2.0/centos-8-x86_64.facts +82 -0
  17. data/facts/2.1/amazon-2-x86_64.facts +90 -0
  18. data/facts/2.1/amazon-2016-x86_64.facts +90 -0
  19. data/facts/2.1/centos-8-x86_64.facts +92 -0
  20. data/facts/2.2/amazon-2-x86_64.facts +106 -0
  21. data/facts/2.2/amazon-2016-x86_64.facts +113 -0
  22. data/facts/2.2/centos-8-x86_64.facts +115 -0
  23. data/facts/2.3/amazon-2-x86_64.facts +107 -0
  24. data/facts/2.3/amazon-2016-x86_64.facts +114 -0
  25. data/facts/2.3/centos-8-x86_64.facts +143 -0
  26. data/facts/2.4/amazon-2-x86_64.facts +110 -0
  27. data/facts/2.4/amazon-2016-x86_64.facts +117 -0
  28. data/facts/2.4/centos-8-x86_64.facts +160 -0
  29. data/facts/2.4/raspbian-9-armv6l.facts +116 -0
  30. data/facts/2.4/raspbian-9-armv7l.facts +116 -0
  31. data/facts/2.5/amazon-2-x86_64.facts +116 -0
  32. data/facts/2.5/amazon-2016-x86_64.facts +117 -0
  33. data/facts/2.5/centos-8-x86_64.facts +160 -0
  34. data/facts/3.0/amazon-4-x86_64.facts +123 -173
  35. data/facts/3.1/amazon-4-x86_64.facts +127 -177
  36. data/facts/3.10/amazon-2-x86_64.facts +382 -0
  37. data/facts/3.10/amazon-2016-x86_64.facts +324 -0
  38. data/facts/3.10/archlinux-x86_64.facts +4 -3
  39. data/facts/3.11/amazon-2-x86_64.facts +488 -0
  40. data/facts/3.11/amazon-2016-x86_64.facts +379 -0
  41. data/facts/3.11/archlinux-x86_64.facts +4 -3
  42. data/facts/3.11/centos-8-x86_64.facts +494 -0
  43. data/facts/3.11/fedora-30-x86_64.facts +530 -0
  44. data/facts/3.11/gentoo-x86_64.facts +463 -0
  45. data/facts/3.11/raspbian-10-armv6l.facts +392 -0
  46. data/facts/3.11/raspbian-10-armv7l.facts +392 -0
  47. data/facts/3.11/solaris-11-i86pc.facts +647 -0
  48. data/facts/3.11/solaris-11-sun4v.facts +618 -0
  49. data/facts/3.12/amazon-2-x86_64.facts +385 -0
  50. data/facts/3.12/amazon-2016-x86_64.facts +327 -0
  51. data/facts/3.12/archlinux-x86_64.facts +3 -2
  52. data/facts/3.12/centos-8-x86_64.facts +400 -0
  53. data/facts/3.13/amazon-2-x86_64.facts +385 -0
  54. data/facts/3.13/amazon-2016-x86_64.facts +327 -0
  55. data/facts/3.13/centos-8-x86_64.facts +406 -0
  56. data/facts/3.13/debian-10-x86_64.facts +534 -0
  57. data/facts/3.14/amazon-2-x86_64.facts +385 -0
  58. data/facts/3.14/amazon-2016-x86_64.facts +327 -0
  59. data/facts/3.14/archlinux-x86_64.facts +4 -3
  60. data/facts/3.14/centos-8-x86_64.facts +406 -0
  61. data/facts/3.14/debian-10-x86_64.facts +534 -0
  62. data/facts/3.14/gentoo-x86_64.facts +463 -0
  63. data/facts/3.14/solaris-11-i86pc.facts +647 -0
  64. data/facts/3.14/solaris-11-sun4v.facts +618 -0
  65. data/facts/3.14/ubuntu-20.04-x86_64.facts +680 -0
  66. data/facts/3.3/amazon-4-x86_64.facts +127 -177
  67. data/facts/3.6/amazon-2-x86_64.facts +375 -0
  68. data/facts/3.6/amazon-2016-x86_64.facts +317 -0
  69. data/facts/3.7/amazon-2-x86_64.facts +375 -0
  70. data/facts/3.7/amazon-2016-x86_64.facts +317 -0
  71. data/facts/3.8/amazon-2-x86_64.facts +375 -0
  72. data/facts/3.8/amazon-2016-x86_64.facts +317 -0
  73. data/facts/3.9/amazon-2-x86_64.facts +381 -0
  74. data/facts/3.9/amazon-2016-x86_64.facts +323 -0
  75. data/facts/3.9/archlinux-x86_64.facts +4 -3
  76. data/facts/Vagrantfile +23 -0
  77. data/facts/get_facts.sh +24 -6
  78. data/lib/facterdb.rb +31 -10
  79. data/lib/facterdb/version.rb +1 -1
  80. data/spec/facterdb_spec.rb +36 -0
  81. metadata +67 -8
@@ -0,0 +1,323 @@
1
+ {
2
+ "aio_agent_version": "5.3.7",
3
+ "architecture": "x86_64",
4
+ "augeas": {
5
+ "version": "1.8.1"
6
+ },
7
+ "augeasversion": "1.8.1",
8
+ "bios_release_date": "12/01/2006",
9
+ "bios_vendor": "innotek GmbH",
10
+ "bios_version": "VirtualBox",
11
+ "blockdevice_sda_model": "VBOX HARDDISK",
12
+ "blockdevice_sda_size": 8589934592,
13
+ "blockdevice_sda_vendor": "ATA",
14
+ "blockdevices": "sda",
15
+ "boardmanufacturer": "Oracle Corporation",
16
+ "boardproductname": "VirtualBox",
17
+ "boardserialnumber": "0",
18
+ "chassistype": "Other",
19
+ "dhcp_servers": {
20
+ "eth0": "10.0.2.2",
21
+ "system": "10.0.2.2"
22
+ },
23
+ "disks": {
24
+ "sda": {
25
+ "model": "VBOX HARDDISK",
26
+ "size": "8.00 GiB",
27
+ "size_bytes": 8589934592,
28
+ "vendor": "ATA"
29
+ }
30
+ },
31
+ "dmi": {
32
+ "bios": {
33
+ "release_date": "12/01/2006",
34
+ "vendor": "innotek GmbH",
35
+ "version": "VirtualBox"
36
+ },
37
+ "board": {
38
+ "manufacturer": "Oracle Corporation",
39
+ "product": "VirtualBox",
40
+ "serial_number": "0"
41
+ },
42
+ "chassis": {
43
+ "type": "Other"
44
+ },
45
+ "manufacturer": "innotek GmbH",
46
+ "product": {
47
+ "name": "VirtualBox",
48
+ "serial_number": "0",
49
+ "uuid": "170E71AA-95F8-4004-B5C2-79D0352D7D23"
50
+ }
51
+ },
52
+ "domain": "example.com",
53
+ "facterversion": "3.9.6",
54
+ "filesystems": "ext3,ext4",
55
+ "fqdn": "foo.example.com",
56
+ "gid": "root",
57
+ "hardwareisa": "x86_64",
58
+ "hardwaremodel": "x86_64",
59
+ "hostname": "foo",
60
+ "hypervisors": {
61
+ "virtualbox": {
62
+ "revision": "133895",
63
+ "version": "6.0.14"
64
+ }
65
+ },
66
+ "id": "root",
67
+ "identity": {
68
+ "gid": 0,
69
+ "group": "root",
70
+ "privileged": true,
71
+ "uid": 0,
72
+ "user": "root"
73
+ },
74
+ "interfaces": "eth0,lo",
75
+ "ipaddress": "10.0.2.15",
76
+ "ipaddress6": "fe80::a00:27ff:fe24:4686",
77
+ "ipaddress6_eth0": "fe80::a00:27ff:fe24:4686",
78
+ "ipaddress6_lo": "::1",
79
+ "ipaddress_eth0": "10.0.2.15",
80
+ "ipaddress_lo": "127.0.0.1",
81
+ "is_virtual": true,
82
+ "kernel": "Linux",
83
+ "kernelmajversion": "4.4",
84
+ "kernelrelease": "4.4.44-39.55.amzn1.x86_64",
85
+ "kernelversion": "4.4.44",
86
+ "load_averages": {
87
+ "15m": 0.18,
88
+ "1m": 0.62,
89
+ "5m": 0.42
90
+ },
91
+ "macaddress": "08:00:27:24:46:86",
92
+ "macaddress_eth0": "08:00:27:24:46:86",
93
+ "manufacturer": "innotek GmbH",
94
+ "memory": {
95
+ "system": {
96
+ "available": "879.06 MiB",
97
+ "available_bytes": 921759744,
98
+ "capacity": "11.82%",
99
+ "total": "996.94 MiB",
100
+ "total_bytes": 1045364736,
101
+ "used": "117.88 MiB",
102
+ "used_bytes": 123604992
103
+ }
104
+ },
105
+ "memoryfree": "879.06 MiB",
106
+ "memoryfree_mb": 879.05859375,
107
+ "memorysize": "996.94 MiB",
108
+ "memorysize_mb": 996.9375,
109
+ "mountpoints": {
110
+ "/": {
111
+ "available": "6.17 GiB",
112
+ "available_bytes": 6626181120,
113
+ "capacity": "20.35%",
114
+ "device": "/dev/sda1",
115
+ "filesystem": "ext4",
116
+ "options": [
117
+ "rw",
118
+ "noatime",
119
+ "data=ordered"
120
+ ],
121
+ "size": "7.75 GiB",
122
+ "size_bytes": 8318783488,
123
+ "used": "1.58 GiB",
124
+ "used_bytes": 1692602368
125
+ },
126
+ "/dev/shm": {
127
+ "available": "498.47 MiB",
128
+ "available_bytes": 522682368,
129
+ "capacity": "0%",
130
+ "device": "tmpfs",
131
+ "filesystem": "tmpfs",
132
+ "options": [
133
+ "rw",
134
+ "relatime"
135
+ ],
136
+ "size": "498.47 MiB",
137
+ "size_bytes": 522682368,
138
+ "used": "0 bytes",
139
+ "used_bytes": 0
140
+ }
141
+ },
142
+ "mtu_eth0": 1500,
143
+ "mtu_lo": 65536,
144
+ "netmask": "255.255.255.0",
145
+ "netmask6": "ffff:ffff:ffff:ffff::",
146
+ "netmask6_eth0": "ffff:ffff:ffff:ffff::",
147
+ "netmask6_lo": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
148
+ "netmask_eth0": "255.255.255.0",
149
+ "netmask_lo": "255.0.0.0",
150
+ "network": "10.0.2.0",
151
+ "network6": "fe80::",
152
+ "network6_eth0": "fe80::",
153
+ "network6_lo": "::1",
154
+ "network_eth0": "10.0.2.0",
155
+ "network_lo": "127.0.0.0",
156
+ "networking": {
157
+ "dhcp": "10.0.2.2",
158
+ "domain": "example.com",
159
+ "fqdn": "foo.example.com",
160
+ "hostname": "foo",
161
+ "interfaces": {
162
+ "eth0": {
163
+ "bindings": [
164
+ {
165
+ "address": "10.0.2.15",
166
+ "netmask": "255.255.255.0",
167
+ "network": "10.0.2.0"
168
+ }
169
+ ],
170
+ "bindings6": [
171
+ {
172
+ "address": "fe80::a00:27ff:fe24:4686",
173
+ "netmask": "ffff:ffff:ffff:ffff::",
174
+ "network": "fe80::"
175
+ }
176
+ ],
177
+ "dhcp": "10.0.2.2",
178
+ "ip": "10.0.2.15",
179
+ "ip6": "fe80::a00:27ff:fe24:4686",
180
+ "mac": "08:00:27:24:46:86",
181
+ "mtu": 1500,
182
+ "netmask": "255.255.255.0",
183
+ "netmask6": "ffff:ffff:ffff:ffff::",
184
+ "network": "10.0.2.0",
185
+ "network6": "fe80::"
186
+ },
187
+ "lo": {
188
+ "bindings": [
189
+ {
190
+ "address": "127.0.0.1",
191
+ "netmask": "255.0.0.0",
192
+ "network": "127.0.0.0"
193
+ }
194
+ ],
195
+ "bindings6": [
196
+ {
197
+ "address": "::1",
198
+ "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
199
+ "network": "::1"
200
+ }
201
+ ],
202
+ "ip": "127.0.0.1",
203
+ "ip6": "::1",
204
+ "mtu": 65536,
205
+ "netmask": "255.0.0.0",
206
+ "netmask6": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
207
+ "network": "127.0.0.0",
208
+ "network6": "::1"
209
+ }
210
+ },
211
+ "ip": "10.0.2.15",
212
+ "ip6": "fe80::a00:27ff:fe24:4686",
213
+ "mac": "08:00:27:24:46:86",
214
+ "mtu": 1500,
215
+ "netmask": "255.255.255.0",
216
+ "netmask6": "ffff:ffff:ffff:ffff::",
217
+ "network": "10.0.2.0",
218
+ "network6": "fe80::",
219
+ "primary": "eth0"
220
+ },
221
+ "operatingsystem": "Amazon",
222
+ "operatingsystemmajrelease": "2016",
223
+ "operatingsystemrelease": "2016.09",
224
+ "os": {
225
+ "architecture": "x86_64",
226
+ "family": "RedHat",
227
+ "hardware": "x86_64",
228
+ "name": "Amazon",
229
+ "release": {
230
+ "full": "2016.09",
231
+ "major": "2016",
232
+ "minor": "09"
233
+ },
234
+ "selinux": {
235
+ "enabled": false
236
+ }
237
+ },
238
+ "osfamily": "RedHat",
239
+ "partitions": {
240
+ "/dev/sda1": {
241
+ "filesystem": "ext4",
242
+ "label": "/",
243
+ "mount": "/",
244
+ "partlabel": "Linux",
245
+ "partuuid": "5f8b9a22-14e2-467d-88a0-89b19021a1c7",
246
+ "size": "8.00 GiB",
247
+ "size_bytes": 8587820544,
248
+ "uuid": "84ecb40c-7e79-497a-9181-82a14c108b3b"
249
+ },
250
+ "/dev/sda128": {
251
+ "partlabel": "BIOS Boot Partition",
252
+ "partuuid": "d9d3c309-5ba9-49d4-a702-4d81b7df239e",
253
+ "size": "1.00 MiB",
254
+ "size_bytes": 1048576
255
+ }
256
+ },
257
+ "path": "/opt/puppetlabs/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/root/bin",
258
+ "physicalprocessorcount": 1,
259
+ "processor0": "Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz",
260
+ "processorcount": 1,
261
+ "processors": {
262
+ "count": 1,
263
+ "isa": "x86_64",
264
+ "models": [
265
+ "Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz"
266
+ ],
267
+ "physicalcount": 1
268
+ },
269
+ "productname": "VirtualBox",
270
+ "puppetversion": "5.3.7",
271
+ "ruby": {
272
+ "platform": "x86_64-linux",
273
+ "sitedir": "/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.4.0",
274
+ "version": "2.4.4"
275
+ },
276
+ "rubyplatform": "x86_64-linux",
277
+ "rubysitedir": "/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.4.0",
278
+ "rubyversion": "2.4.4",
279
+ "selinux": false,
280
+ "serialnumber": "0",
281
+ "ssh": {
282
+ "ecdsa": {
283
+ "fingerprints": {
284
+ "sha1": "SSHFP 3 1 f7209576950731ce607d529e7fad5798f39e3c79",
285
+ "sha256": "SSHFP 3 2 dc50a6f0c262a3e650301b904db34834e9c6733b78c44da6d971c7a64051a7f4"
286
+ },
287
+ "key": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIl9DhX/TT6XkAxp7ROAIP8/67ycpIo7t0+NSP4f0FJy9W2Ifj8m+l0i6zxMATRSOmgDNI+PL/TtLLWRZQ/VbQk="
288
+ },
289
+ "ed25519": {
290
+ "fingerprints": {
291
+ "sha1": "SSHFP 4 1 6be19cdb6a3bb6cf184b2eab1f538b4da090d8e6",
292
+ "sha256": "SSHFP 4 2 20421f8d892a4b5aca7f917af3caae21e57c98bacb5746a974705e0dfe9e58fc"
293
+ },
294
+ "key": "AAAAC3NzaC1lZDI1NTE5AAAAIBOrX7JImKM57m5n0t3ll23Lb9Dmh4UiPE9ANkViu0y4"
295
+ },
296
+ "rsa": {
297
+ "fingerprints": {
298
+ "sha1": "SSHFP 1 1 62609e9683ca74c4076fbc583047df10f3d889ea",
299
+ "sha256": "SSHFP 1 2 aeb4e2c9242e3a2bbc81cc5718b38f3ca97fda038f7fe436278389d40536e066"
300
+ },
301
+ "key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDZ1lqGL2XwHIZ9fAJbcht6kKAthGOPsz5aC5sM1QP+mY3ouLB5jrwSpQcV51KvIl30IHu3Rp/Jrl06TpN9nw2kZnSMV0dY1k24ujEwF0CpL4STuv9AHkjD0tUFOa1BqmUukLYFKz2cZroUkFO9GZ4l/Z1EZGquQt37x+q0rq45IKlcoWyttLYFmX6zQhK7ICwnrjfTNXs8ID8g0NEFSne1AoDrHa3QjY/Epa5QVQpEOvJ/hrS5yJ2wYp7Rlg3uR4J+sA/Dpn6UCYC/xlj/aXcl90HPORlIy50gLpzLj55fcH6rTIMcLp5hl5gVyr5lygk+Ep5FiuYBMUPzCeCQ6o0v"
302
+ }
303
+ },
304
+ "sshecdsakey": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIl9DhX/TT6XkAxp7ROAIP8/67ycpIo7t0+NSP4f0FJy9W2Ifj8m+l0i6zxMATRSOmgDNI+PL/TtLLWRZQ/VbQk=",
305
+ "sshed25519key": "AAAAC3NzaC1lZDI1NTE5AAAAIBOrX7JImKM57m5n0t3ll23Lb9Dmh4UiPE9ANkViu0y4",
306
+ "sshfp_ecdsa": "SSHFP 3 1 f7209576950731ce607d529e7fad5798f39e3c79\nSSHFP 3 2 dc50a6f0c262a3e650301b904db34834e9c6733b78c44da6d971c7a64051a7f4",
307
+ "sshfp_ed25519": "SSHFP 4 1 6be19cdb6a3bb6cf184b2eab1f538b4da090d8e6\nSSHFP 4 2 20421f8d892a4b5aca7f917af3caae21e57c98bacb5746a974705e0dfe9e58fc",
308
+ "sshfp_rsa": "SSHFP 1 1 62609e9683ca74c4076fbc583047df10f3d889ea\nSSHFP 1 2 aeb4e2c9242e3a2bbc81cc5718b38f3ca97fda038f7fe436278389d40536e066",
309
+ "sshrsakey": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDZ1lqGL2XwHIZ9fAJbcht6kKAthGOPsz5aC5sM1QP+mY3ouLB5jrwSpQcV51KvIl30IHu3Rp/Jrl06TpN9nw2kZnSMV0dY1k24ujEwF0CpL4STuv9AHkjD0tUFOa1BqmUukLYFKz2cZroUkFO9GZ4l/Z1EZGquQt37x+q0rq45IKlcoWyttLYFmX6zQhK7ICwnrjfTNXs8ID8g0NEFSne1AoDrHa3QjY/Epa5QVQpEOvJ/hrS5yJ2wYp7Rlg3uR4J+sA/Dpn6UCYC/xlj/aXcl90HPORlIy50gLpzLj55fcH6rTIMcLp5hl5gVyr5lygk+Ep5FiuYBMUPzCeCQ6o0v",
310
+ "system_uptime": {
311
+ "days": 0,
312
+ "hours": 0,
313
+ "seconds": 198,
314
+ "uptime": "0:03 hours"
315
+ },
316
+ "timezone": "UTC",
317
+ "uptime": "0:03 hours",
318
+ "uptime_days": 0,
319
+ "uptime_hours": 0,
320
+ "uptime_seconds": 198,
321
+ "uuid": "170E71AA-95F8-4004-B5C2-79D0352D7D23",
322
+ "virtual": "virtualbox"
323
+ }
@@ -55,7 +55,7 @@
55
55
  "gid": "root",
56
56
  "hardwareisa": "unknown",
57
57
  "hardwaremodel": "x86_64",
58
- "hostname": "archlinux",
58
+ "hostname": "foo",
59
59
  "hypervisors": {
60
60
  "virtualbox": {}
61
61
  },
@@ -324,8 +324,8 @@
324
324
  "network_lo": "127.0.0.0",
325
325
  "networking": {
326
326
  "dhcp": "10.0.2.2",
327
- "fqdn": "archlinux",
328
- "hostname": "archlinux",
327
+ "fqdn": "foo.example.com",
328
+ "hostname": "foo",
329
329
  "interfaces": {
330
330
  "eth0": {
331
331
  "bindings": [
@@ -506,5 +506,6 @@
506
506
  "uptime_hours": 0,
507
507
  "uptime_seconds": 268,
508
508
  "uuid": "eb6e0002-bde8-4896-b25f-780ea4ce4e2d",
509
+ "domain": "example.com",
509
510
  "virtual": "virtualbox"
510
511
  }
@@ -142,6 +142,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
142
142
  host.vm.provision "shell", path: "get_facts.sh"
143
143
  host.vm.provision "shell", inline: "/sbin/shutdown -h now"
144
144
  end
145
+ config.vm.define "centos-8-x86_64" do |host|
146
+ host.vm.box = "centos/8"
147
+ host.vm.synced_folder ".", "/vagrant"
148
+ host.vm.provision "shell", inline: "dnf -y install wget make gcc net-tools"
149
+ host.vm.provision "file", source: "Gemfile", destination: "Gemfile"
150
+ host.vm.provision "shell", path: "get_facts.sh"
151
+ host.vm.provision "shell", inline: "/sbin/shutdown -h now"
152
+ end
153
+
145
154
  config.vm.define "redhat-8-x86_64" do |host|
146
155
  host.vm.box = "generic/rhel8"
147
156
  host.vm.synced_folder ".", "/vagrant"
@@ -401,4 +410,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
401
410
  host.vm.provision 'shell', path: "windows_get_facts.ps1"
402
411
  host.vm.provision 'shell', inline: "shutdown -s -f -c \"Fact Collection Complete\""
403
412
  end
413
+ config.vm.define "amazonlinux-2-x86_64" do |host|
414
+ host.vm.box = "bento/amazonlinux-2"
415
+ host.vm.provision "shell", inline: "yum -y install gcc glibc-devel"
416
+ host.vm.provision "file", source: "Gemfile", destination: "Gemfile"
417
+ host.vm.provision "shell", path: "get_facts.sh"
418
+ host.vm.provision "shell", inline: "/sbin/shutdown -h now"
419
+ end
420
+ config.vm.define "amazonlinux-1-x86_64" do |host|
421
+ host.vm.box = "spscommerce/amazonlinux"
422
+ host.vm.provision "shell", inline: "yum -y install gcc glibc-devel"
423
+ host.vm.provision "file", source: "Gemfile", destination: "Gemfile"
424
+ host.vm.provision "shell", path: "get_facts.sh"
425
+ host.vm.provision "shell", inline: "/sbin/shutdown -h now"
426
+ end
404
427
  end
@@ -28,17 +28,32 @@ elif test -f /usr/bin/apt-get; then
28
28
  operatingsystem=$(lsb_release -si)
29
29
  operatingsystemmajrelease=$(lsb_release -sr)
30
30
  osfamily='Debian'
31
- elif test -f /usr/bin/dnf -a ! -f /sbin/rhn_register; then
32
- operatingsystemmajrelease=$(cat /etc/redhat-release | cut -d' ' -f3 )
33
- osfamily='Fedora'
34
- elif test -f /usr/bin/yum; then
35
- operatingsystemmajrelease=$(cat /etc/redhat-release | sed 's/[^0-9.]//g' | cut -d'.' -f1)
36
- osfamily='RedHat'
31
+ elif test -f /etc/redhat-release ; then
32
+ operatingsystemmajrelease=$(rpm -qf /etc/redhat-release --queryformat '%{version}' | cut -f1 -d'.')
33
+ case $(rpm -qf /etc/redhat-release --queryformat '%{name}') in
34
+ centos*|redhat*)
35
+ osfamily='RedHat'
36
+ ;;
37
+ fedora*)
38
+ osfamily='Fedora'
39
+ ;;
40
+ *)
41
+ echo 'Failed to determine osfamily from /etc/redhat-release'
42
+ exit 1
43
+ esac
37
44
  elif test -f '/usr/bin/pacman'; then
38
45
  operatingsystemmajrelease=3
39
46
  osfamily='Archlinux'
40
47
  elif test -f '/etc/gentoo-release'; then
41
48
  osfamily='Gentoo'
49
+ elif test -f '/etc/os-release' && grep -q 'Amazon' '/etc/os-release'; then
50
+ osfamily='RedHat'
51
+ operatingsystemmajrelease=$(rpm -qf /etc/os-release --queryformat '%{version}' | cut -f1 -d'.')
52
+ if [[ $operatingsystemmajrelease -eq 2 ]]; then
53
+ operatingsystemmajrelease='7'
54
+ else
55
+ operatingsystemmajrelease='6'
56
+ fi
42
57
  else
43
58
  osfamily=$(uname)
44
59
  fi
@@ -261,6 +276,9 @@ case "${osfamily}" in
261
276
  ;;
262
277
  'Gentoo')
263
278
  emerge -vq1 dev-lang/ruby dev-ruby/bundler app-admin/puppet
279
+ output_file="/vagrant/$(facter --version | cut -d. -f1,2)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter hardwaremodel).facts"
280
+ mkdir -p $(dirname ${output_file})
281
+ facter --show-legacy -p -j | tee ${output_file}
264
282
  esac
265
283
 
266
284
  operatingsystem=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
@@ -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
- def self.get_facts(filter=nil)
96
- if filter.is_a?(Array)
97
- filter_str = '(' + filter.map { |f| f.map { |k,v | "#{k}=#{v}" }.join(' and ') }.join(') or (') + ')'
98
- elsif filter.is_a?(Hash)
99
- filter_str = filter.map { |k,v | "#{k}=#{v}" }.join(' and ')
100
- elsif filter.is_a?(String)
101
- filter_str = filter
102
- elsif filter == nil
103
- filter_str = ''
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 'filter must be either an Array a Hash or a String'
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