The project is in a healthy, maintained state
Contains facts from many Facter versions on many operating systems, stored and looked up under the real Facter version that produced them.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.5, >= 1.5.4
 Project Readme

puppetlabs-facterdb

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.

Installation

gem 'puppetlabs-facterdb'

Requires Ruby >= 3.1.

Usage

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.

CLI

puppetlabs-facterdb 'os.family=Debian'

Prints a pretty-printed JSON array of the matching facts. When nothing matches it prints [] and exits 0.

Environment variables

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.

Data layout

facts/<facter major.minor>/<os>-<release>-<arch>.facts
  • Each file holds one full facter -j JSON object.
  • The latest patch release for each major.minor overwrites the previous one; the exact patch is in the inner facterversion fact.
  • 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 -core release suffix is allowed, and rolling distros listed in config/facts.yml use <os>-<arch>.

Versioning

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.

Using alongside facterdb

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.

Migrating from facterdb

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)   # after

Facts are keyed by the real Facter version under facts/<major.minor>/.

Development

bundle install
bundle exec rake spec
bundle exec rake rubocop
BUNDLE_GEMFILE=spec/integration/dual_install/Gemfile bundle exec rspec spec/integration/dual_install

Fact 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.

Gathering facts

Two workflows keep the store current:

  1. update-facter-versions runs weekly on Mondays at 03:00 UTC and on manual dispatch. It refreshes config/facter_versions.yml (Facter version to agent version) from the Puppet Core gem index and release notes, and opens a PR.
  2. gather-facts runs on manual dispatch and on pushes to main that touch config/facter_versions.yml, config/metadata.json or facts/**, so merging each facts PR starts the next missing version until nothing is missing. It never runs on pull_request. It gathers one Facter version per run: the oldest not yet gathered, or an X.Y.Z passed as the version input. It provisions every OS in config/metadata.json that the provisioning service offers as a VM with litmus, installs the mapped agent, runs facter -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_litmus matrix.json.

  • The litmus fixture modules (default branch unless a ref is set) are listed in config/litmus_modules.yml.

  • Scrubbing uses config/scrub.yml; review its effect on every facts PR.

  • PRs are opened with GITHUB_TOKEN and 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.

Licence and attribution

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.