facter
Gather system facts
SYNOPSIS
facter [options] [fact1] [fact2 ...]
PARAMETERS
-h, --help
Display brief help information and exit.
-v, --version
Display the facter version and exit.
-j, --json
Output facts in JSON format. This is often preferred for scripting.
-y, --yaml
Output facts in YAML format.
-p, --puppet
Load Puppet's internal facts, making them available to facter.
-d, --debug
Enable debug logging, showing more verbose output about fact resolution.
--trace
Enable backtraces for errors, useful for debugging fact failures.
-e DIR, --external-dir DIR
Specify a directory to search for external facts.
-c DIR, --custom-dir DIR
Specify a directory to search for custom (Ruby) facts.
--list-facts
List all available fact names without resolving their values.
--no-custom-facts
Disable the loading and resolution of custom facts.
--no-external-facts
Disable the loading and resolution of external facts.
-t, --timing
Show the time taken to resolve each fact, aiding performance analysis.
--config FILE
Specify a custom configuration file for facter.
--no-ruby
Disable all Ruby-based features, including custom and external facts that rely on Ruby.
--strict
Enable strict checking, causing facter to fail on certain warnings or errors.
DESCRIPTION
facter is a powerful, cross-platform system profiling tool developed by Puppet Inc.
It collects fundamental information, known as "facts," about a system's hardware, operating system, network interfaces, and configuration. These facts include details like the operating system type and version, CPU count, memory, IP addresses, hostname, kernel version, and more.
While primarily designed as a core component of the Puppet configuration management system, providing dynamic data for manifest compilation, facter can also be used as a standalone command-line utility. System administrators and developers leverage facter to quickly audit system configurations, gather inventory data, and script automated tasks based on system attributes. Its extensibility allows users to define custom and external facts, enabling the collection of highly specific or application-level data. The output can be presented in various formats, including plain text, JSON, and YAML, facilitating integration with other tools and scripts.
CAVEATS
Performance overhead: On very large systems or during initial runs, facter can consume notable CPU and memory as it gathers extensive system data.
Sensitive data: Some facts (e.g., IP addresses, MAC addresses) might be considered sensitive. Care should be taken when sharing facter output.
External dependencies: Relies on various system commands and files to gather information, potentially failing if these are missing or permissions are incorrect.
Ruby dependency: While modern facter versions (4.x+) are largely C++ based, custom and external facts written in Ruby still require a Ruby runtime.
FACT TYPES
facter categorizes facts into three main types:
Core Facts: Built-in facts provided by facter itself, covering common system attributes like OS, CPU, and memory.
External Facts: Facts resolved from static files (e.g., JSON, YAML, text files) or executable scripts placed in specific directories. These are useful for static data or simple script-based data.
Custom Facts: Facts written in Ruby, providing dynamic data collection logic for highly specific system attributes or application-level information. These offer the most flexibility.
FACT RESOLUTION ORDER
facter loads facts in a specific order: Core Facts, then External Facts, and finally Custom Facts. If a fact with the same name is defined in multiple sources, the value from the last source processed will take precedence. For instance, a custom fact can override an external fact, and an external fact can override a core fact.
HISTORY
facter was originally developed by Puppet Inc. as a crucial component of the Puppet configuration management system. It was initially written entirely in Ruby, serving as the default fact-gathering mechanism for Puppet agents. Over time, to improve performance and reduce dependencies, facter underwent significant architectural changes. With facter 4.x and later, a substantial portion of the core fact resolution logic was rewritten in C++, making it faster and more resource-efficient, especially on systems with a large number of facts or extensive custom/external fact directories. Its evolution reflects the need for robust and efficient system introspection in dynamic IT environments.