A database of OS facts, stored and looked up under the real Facter version that produced them. It coexists with upstream facterdb: nothing is shared between the two gems.
gem 'puppetlabs-facterdb'Requires Ruby >= 3.1.
require 'puppetlabs/facterdb'
# Hash: keys are ANDed
Puppetlabs::FacterDB.get_facts({ 'os.family' => 'Debian', facterversion: '/^4\.11/' })
# Array of Hashes: each Hash is ORed
Puppetlabs::FacterDB.get_facts([{ 'os.name' => 'Debian' }, { 'os.name' => 'Ubuntu' }])
# String: passed straight to jgrep
Puppetlabs::FacterDB.get_facts('os.family=RedHat and facterversion=/^4\.11/')get_facts(filter = nil, cache = true, symbolize_keys: true) returns an Array of Hashes. facterversion accepts a regex; nested facts use dotted paths such as os.family.
puppetlabs-facterdb 'os.family=Debian'Prints a pretty-printed JSON array of the matching facts. When nothing matches it prints [] and exits 0.
| Variable | Effect |
|---|---|
PUPPETLABS_FACTERDB_SEARCH_EXTERNAL_DIR |
Path-separator delimited list of extra directories searched for *.facts files. Nonexistent directories are silently ignored. Extra files take precedence over bundled ones. |
PUPPETLABS_FACTERDB_SKIP_DEFAULTDB |
If set to any value (including empty), the facts bundled with the gem are skipped. |
PUPPETLABS_FACTERDB_INJECT_SOURCE |
If set, _facterdb_filename and _facterdb_path are injected into each fact set. |
The upstream FACTERDB_* environment variables have no effect on this gem.
facts/<facter major.minor>/<os>-<release>-<arch>.facts
- Each file holds one full
facter -jJSON object. - The latest patch release for each major.minor overwrites the previous one; the exact patch is in the inner
facterversionfact. - The directory is organisational only. Filters match the inner facts, not the directory name.
- The bundled data covers Facter 4.0-4.11, seeded from facterdb-private (source commit in facts/seed-manifest.json). Facter 4.12+ arrives from Puppet Core gathers.
- Filenames must not contain spaces. A
-corerelease suffix is allowed, and rolling distros listed inconfig/facts.ymluse<os>-<arch>.
The gem follows semantic versioning on its API. Its version is independent of the Facter versions stored in it.
- Major: breaking changes to the lookup API, the CLI, the environment variables or the fact layout.
- Minor: new facts, new Facter versions or new OSes.
- Patch: bug fixes and corrections to existing facts.
puppetlabs-facterdb shares no require path, constant, executable, environment variable or cache key with facterdb, so both can be installed together. Existing consumers such as rspec-puppet-facts keep using facterdb until they are switched over; see docs/decisions/0001-consumer-loading.md.
| Item | facterdb |
puppetlabs-facterdb |
|---|---|---|
| Gem | facterdb |
puppetlabs-facterdb |
| Require | require 'facterdb' |
require 'puppetlabs/facterdb' |
| Namespace | FacterDB |
Puppetlabs::FacterDB |
| CLI | facterdb |
puppetlabs-facterdb |
| Extra fact directories | FACTERDB_SEARCH_PATHS |
PUPPETLABS_FACTERDB_SEARCH_EXTERNAL_DIR |
| Skip bundled facts | FACTERDB_SKIP_DEFAULTDB |
PUPPETLABS_FACTERDB_SKIP_DEFAULTDB |
| Inject source facts | FACTERDB_INJECT_SOURCE |
PUPPETLABS_FACTERDB_INJECT_SOURCE |
# Gemfile
gem 'facterdb' # before
gem 'puppetlabs-facterdb' # after
# require
require 'facterdb' # before
require 'puppetlabs/facterdb' # after
# lookup
FacterDB.get_facts(filter) # before
Puppetlabs::FacterDB.get_facts(filter) # afterFacts are keyed by the real Facter version under facts/<major.minor>/.
bundle install
bundle exec rake spec
bundle exec rake rubocop
BUNDLE_GEMFILE=spec/integration/dual_install/Gemfile bundle exec rspec spec/integration/dual_installFact store tooling:
bundle exec rake facts:validate # validate every fact file (CI runs this)
bundle exec rake facts:normalise # scrub and normalise fact files in place
CHECK=1 bundle exec rake facts:normalise # report files that would change, exit non-zero
bundle exec rake gather:next_version # print the Facter version the next gather would pick
bundle exec rake versions:update # refresh config/facter_versions.yml (needs PUPPET_FORGE_TOKEN)The scrub policy lives in config/scrub.yml and the filename rules in config/facts.yml. The tooling under tools/ is not shipped in the gem.
Two workflows keep the store current:
update-facter-versionsruns weekly on Mondays at 03:00 UTC and on manual dispatch. It refreshesconfig/facter_versions.yml(Facter version to agent version) from the Puppet Core gem index and release notes, and opens a PR.gather-factsruns on manual dispatch and on pushes tomainthat touchconfig/facter_versions.yml,config/metadata.jsonorfacts/**, so merging each facts PR starts the next missing version until nothing is missing. It never runs onpull_request. It gathers one Facter version per run: the oldest not yet gathered, or anX.Y.Zpassed as theversioninput. It provisions every OS inconfig/metadata.jsonthat the provisioning service offers as a VM with litmus, installs the mapped agent, runsfacter -j, scrubs and normalises the output and opens one PR.
A version is "not yet gathered" when no stored file in that major.minor reports a facterversion >= it, so older patches are never re-gathered. Existing fact files are never deleted.
-
A version whose legs all fail stays missing and blocks the queue until it is fixed or dispatched past with an explicit
version. Legs skipped because no agent package exists for that OS do not block. -
Scheduled workflows in public repositories are disabled after 60 days without repository activity and may need re-enabling.
-
The OS list is
config/metadata.json. To add an OS, edit it; names must match puppet_litmusmatrix.json. -
The litmus fixture modules (default branch unless a
refis set) are listed inconfig/litmus_modules.yml. -
Scrubbing uses
config/scrub.yml; review its effect on every facts PR. -
PRs are opened with
GITHUB_TOKENand merged by hand. They do not trigger CI; close and reopen to run checks. The repo setting "Allow GitHub Actions to create and approve pull requests" must stay enabled. -
Failed legs are listed in the PR body with a short reason (provision service error or other) and turn the run red; the remaining legs still land.
-
A leg whose OS has no package for the mapped agent version is skipped, not failed: it exits green, does not turn the run red and is listed under "Skipped (no agent package for this OS)" in the PR body.
-
Failure details from provisioning and agent install are withheld from the public run log (only a category is printed) because litmus output includes the VM address.
-
The Puppet Core token comes from the org secret. It is set only on the steps that need it (the Bundler install steps, the matrix generator and the gather leg), and the gather workflows never run on pull requests.
Facts are gathered on provisioning service VMs only. Docker is not used because containers share the runner kernel and have no init, so virtual, service_provider, kernel* and similar facts would be wrong for the OS.
Known gaps: macOS, ppc64le and ARMv7L are not gathered. Fedora 41, AlmaLinux 10, Rocky 10 and Windows 11 have no litmus provisioner. AmazonLinux 2023, OracleLinux 8 and Ubuntu 26.04 are only available as docker and are not gathered.
Apache-2.0. Derived from voxpupuli/facterdb (Apache-2.0). Spec fixtures are copied from facterdb. Seeded data comes from Puppet's facterdb-private fork of voxpupuli/facterdb.
See NOTICE for attribution and facts/seed-manifest.json for the seed source.