Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/voxpupuli/facterdb
A Database of OS facts provided by Facter
https://github.com/voxpupuli/facterdb
hacktoberfest ruby
Last synced: 3 months ago
JSON representation
A Database of OS facts provided by Facter
- Host: GitHub
- URL: https://github.com/voxpupuli/facterdb
- Owner: voxpupuli
- License: apache-2.0
- Created: 2015-05-29T12:16:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T05:16:42.000Z (6 months ago)
- Last Synced: 2024-05-23T04:42:49.884Z (6 months ago)
- Topics: hacktoberfest, ruby
- Language: Ruby
- Homepage: http://voxpupuli.org/facterdb/
- Size: 3.93 MB
- Stars: 42
- Watchers: 41
- Forks: 74
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - voxpupuli/facterdb - A Database of OS facts provided by Facter (ruby)
README
facterdb
========[![License](https://img.shields.io/github/license/voxpupuli/facterdb.svg)](https://github.com/voxpupuli/facterdb/blob/master/LICENSE)
[![Test](https://github.com/voxpupuli/facterdb/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/facterdb/actions/workflows/test.yml)
[![Release](https://github.com/voxpupuli/facterdb/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/facterdb/actions/workflows/release.yml)
[![RubyGem Version](https://img.shields.io/gem/v/facterdb.svg)](https://rubygems.org/gems/facterdb)
[![RubyGem Downloads](https://img.shields.io/gem/dt/facterdb.svg)](https://rubygems.org/gems/facterdb)
[![Donated by Camptocamp](https://img.shields.io/badge/donated%20by-camptocamp-fb7047.svg)](#transfer-notice)A Gem that contains a lot of facts for a lot of Operating Systems.
![FacterDB](images/facterdb.png)
**With facterdb 2 legacy facts are deprecated and will be removed in facterdb 3**
Some facts were declared legacy a long time ago: [Core facts documentation](https://www.puppet.com/docs/puppet/latest/core_facts.html)
With Puppet 8 they are disabled by default. With the release of facterdb 3 we will also remove the legacy facts from our factsets.# Usage
## CLI
```shell
facterdb 'facterversion=/^2.4\./ and (operatingsystem=Debian and operatingsystemrelease>=7 or operatingsystem=RedHat and operatingsystemrelease=/^7/)'
```Will return a JSON containing the facts for Debian 7, Debian 8 and RedHat 7 generated by Facter 2.4.
## Ruby
```ruby
require 'facterdb'
FacterDB::get_facts()
```Returns an Array of Hash containing the whole facts database.
## Filtering by Facter version and fact values
### With an Array filter
```ruby
require 'facterdb'FacterDB.get_facts([{:osfamily => 'Debian'}])
```### With an Hash filter
```ruby
require 'facterdb'FacterDB.get_facts({:osfamily => 'Debian'})
```### With a String filter
```ruby
require 'facterdb'FacterDB::get_facts('osfamily=Debian')
```## Included Factsets
Starting with version 1.28.0 (May 2024), check [RubyDoc](https://www.rubydoc.info/gems/facterdb/) for Factsets included in each released gem.
Check the [Voxpupuli website](https://voxpupuli.org/facterdb/) for Factsets included in the `master` branch.## Add new Operating System support
There is `Vagrantfile` to automagically populate `facts` for all supported operating systems by spawning a new VM and launches a provisioning scripts.
Details of how to generate facts for each operating system are [here](facts/README.md).## Supplying custom external facts
The default facts are great for many things but there will be times when you need to have facterdb search custom
fact sets that only make sense in your environment or might contain sensitive information.This can be useful when combined with [rspec_puppet_facts](https://github.com/mcanevet/rspec-puppet-facts) or the [puppet-debugger](https://github.com/nwops/puppet-debugger) which both use this gem.
To supply external facts to facterdb just set the `FACTERDB_SEARCH_PATHS` environment variable with one or more
paths to your facts. Do this any time facterdb is used directly or indirectly.When separating paths please use the default path separator character supported by your OS.
* Unix/Linux/OSX = `:`
* Windows = `;`Each fact set you create must meet the following requirements:
1. A JSON serialized file containing a single Hash of all the facts.
2. The facts file must end in `.facts`
3. Must be placed inside some directory. You can organize this directory however you like.Facterdb is smart enough the search your supplied directories for files ending with '.facts'. You can even supply
multiple directories.Example:
`FACTERDB_SEARCH_PATHS="/var/opt/lib/custom_facts"`
or
`FACTERDB_SEARCH_PATHS="/var/opt/lib/custom_facts:/tmp/custom_facts:/home/user1/custom_facts"`
We still highly encourage you to create pull requests with new fact sets over of using external facts.
You can create these files via many methods.
* `puppet facts | jq '.values' > /tmp/custom_facts/datacenter_a/2.4/os_x.facts` # must have jq command
* Via puppetdb queries
* hand craftedAdditionally you can skip the default FacterDB facts completely by setting the environment variable `FACTERDB_SKIP_DEFAULTDB`.
This will instruct facterdb to not look at its built-in facts which can be useful should you need to completely replace which facts are used.Setting the variable `FACTERDB_SKIP_DEFAULTDB` to anything will disable the internal facts used by facterdb. You would most likely use this in combination
with the `FACTERDB_SEARCH_PATHS` environment variable.Example:
```
FACTERDB_SEARCH_PATHS="/var/opt/lib/custom_facts:/tmp/custom_facts:/home/user1/custom_facts"
FACTERDB_SKIP_DEFAULTDB='yes'
```## Debugging fact sets
By setting the environment variable `FACTERDB_INJECT_SOURCE` the following facts are injected into all fact sets:
`_facterdb_path` : The base name of the file used to load this fact set e.g. `centos-5-i386.facts`
`_facterdb_filename` : The full path of the file used to load this fact set e.g. `/project/facter-db/centos-5-i386.facts`
``` json
{
"_facterdb_path": "centos-5-i386.facts",
"_facterdb_filename": "/project/facter-db/centos-5-i386.facts",
"aio_agent_version": "1.8.3",
"architecture": "i386",
"augeas": {
"version": "1.4.0"
},
"augeasversion": "1.4.0",
"bios_release_date": "07/30/2013",
"bios_vendor": "Phoenix Technologies LTD",
"bios_version": "6.00",
"blockdevice_fd0_size": 4096,
"blockdevice_hdc_size": 4294965248,
"blockdevice_sda_model": "Virtual disk",
...
```To set the environment variable use;
``` bash
bash> FACTERDB_INJECT_SOURCE='true'
```
or on Windows
``` powershell
powershell> $ENV:FACTERDB_INJECT_SOURCE = 'true'
```# Contributing
Please submit issues at https://github.com/voxpupuli/facterdb/issues or PRs in the same repository.
## Release process
* Update the version in `lib/facterdb/version.rb`
* Run `rake changelog`
* Commit and PR the results.## Transfer Notice
This plugin was originally authored by [Camptocamp](http://www.camptocamp.com).
The maintainer preferred that Puppet Community take ownership of the module for future improvement and maintenance.
Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.Previously: https://github.com/camptocamp/facterdb