Table of contents
1.
Introduction
2.
Facter 
3.
Facter: CLI
3.1.
Options
3.2.
Examples
4.
Facter: Core Facts
4.1.
Modern Facts
4.2.
Legacy Facts
5.
Frequently Asked Questions
5.1.
What is a Puppet?
5.2.
What is Puppet code?
5.3.
How do you create a custom fact in Puppet?
5.4.
How do you identify Puppet facts?
5.5.
What is puppet software used for?
6.
Conclusion
Last Updated: Jun 28, 2024
Medium

Facter in Puppet

Author yuvatimankar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Puppet in computing is a tool that helps us automate and manage the configuration of servers. Using Puppet isn't just about the tool but also about a way of working and culture. Puppet is made up of multiple packages. All these packages are known as the Puppet platform, which stores, manages, and runs puppet codes.

Facter in puppet

Puppet works on many documentation and resources to help us learn Puppet. So, In this article, we will learn about Facter in Puppet in detail. Stay till the end!

Facter 

Facter is a cross-platform system profiling library in Puppet. It detects and informs per-node facts provided in our Puppet manifest as variables. If we have Ruby installed already in our system, we can install Factor by running the following command:

gem install facter

Facter: CLI

The library behind Facter is convenient and easy to expand. This makes Facter the most straightforward way to collect info about a system. If we are given no queries, it will return all facts to us.

Most command line options can be set through the HOCON configuration file. This file can also be used to cache or block specific fact groups.

Options

--color: For enabling output.
--config, -c: For the location of the configuration file.
--no-color: For disabling color output.
--no-ruby: For disabling loading Ruby, custom facts, & facts requiring Ruby.
--strict: This option enables more aggressive error reporting.
--puppet, -p: This option loads the Puppet libraries, hence allows Facter to load Puppet-specific facts.
--help, -h: This option is for taking help for all arguments.
--timing,-t: This displays the time taken to resolve each fact
-j, --json: This option gives output in JSON format.
--hocon: This option gives output in HOCON format.

Examples

For displaying all facts:

$ facter
disks => {
  sda => {
    model => "Virtual disk",
    size => "8.00 GiB",
    size_in_bytes => 85897534592,
    vendor => "ExampleVendor"
  }
}
dmi => {
  bios => {
    release_date => "06/23/2013",
    vendor => "Example Vendor",
    version => "6.00"
  }
}
[...]


For displaying a single structured fact:

$ facter processors
{
  count => 1,
  isa => "x86_64",
  models => [
  "Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz"
  ],
  physicalcount => 1
}


Format facts as JSON:

$ facter --json os.name os.release.major processors.isa
{
  "os.name": "Ubuntu",
  "os.release.major": "14.04",
  "processors.isa": "x86_64"
}

Facter: Core Facts

Here is the list of all the built-in facts that ship with Facter, including newer structured facts and legacy facts. 

Modern Facts

Fact name Type Purpose
augeas map Return Info about augeas.
az_metdata map Returns the Microsoft Azure instance metadata.
cloud map Returns info about the cloud instance of the node.
dmi map Returns the information about system management.
ec2_metadata map Returns the EC2 instance metadata.
ec2_userdata map Returns the EC2 instance user data.
filesystems string Returns the usable file systems for disk devices or block.
fips_enabled boolean Returns if the platform is in FIPS mode.
processors map Returns info about the processors of the system.
path string Returns the PATH environment variable.
solaris_zones map Returns info about solaris zones.
timezone string Returns the system timezone.
xen map Returns metadata for the xen hypervisor.
nim_type string It determines if the node is standalone or master inside an AIX Nim environment.
zpool_version string Returns the version for ZFS storage pools.
virtual  string Returns the name of the hypervisor for virtual machines for physical machines.

Legacy Facts

Fact name Type Purpose
architecture string Returns the hardware architecture of the operating system.
augeasversion  string Return the version of augeas.
bios_vendor string Returns the vendor of the BIOS system.
boardproductname string Returns the board product name of the system.
boardserialnumber string Returns the board serial number of the system.
domain string Returns the network domain of the system.
fqdn string Returns the FQDN of the system.
hardwaremodel string Returns the hardware model of operating system.
id string Returns the UID of the user running facter.
interfaces string Returns the comma-seperated list of network interfaces names.
ldom_<name> string Returns information regarding solaris LDom.
macaddress mac Returns the MAC address for the default network interface.
memoryfree string Returns the display size of the free system memory. 
memorysize string Returns the display size of the total system memory.
network ip Returns the IPv4 network for the default network interface.
operatingsystem string Returns the name of the os.
osfamily string Returns the family of the os.
sapsize_mb double Returns the size of the total swap memory.
system32 string Returns the path to the system32 directory on Windows.
uptime string Returns the uptime of the system.
uptime_days integer Return the uptime days of the system.
uuid string Returns the product unique identifier of the system.
zone_<name>_status string Returns the zone state for the solaris zone.
zonename string Returns the name of the present solaris zone.
zones integer Returns the count of Solaris zones.

Frequently Asked Questions

What is a Puppet?

It is a tool that helps manage and automate the configuration of servers.

What is Puppet code?

Puppet code is an easy way to programmatically describe what configurations should be in place on the operating systems & applications that you want to manage.

How do you create a custom fact in Puppet?

Custom facts can be added to the main Puppet server by writing snippets of Ruby code. Puppet then distributes the facts to the client via plug-ins in modules.

How do you identify Puppet facts?

Run facter -p on the command line to see a node's fact values or browse facts on node detail pages in the Puppet Enterprise console.

What is puppet software used for?

Puppet is a software configuration management and deployment tool that is open source. It is most commonly used on Linux and Windows to pull the strings on multiple application servers simultaneously.

Conclusion

In this article, we explored the topic of Facter in Puppet. We started with introducing Puppet, and then we further discussed Facter and Facter: CLI.

We hope this blog has helped you enhance your knowledge of Facter in Puppet and if you want to learn more, check out our articles here.

You can refer to other similar articles as well

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available. Also, look at the interview experiences for placement preparations. 

Happy Learning Ninja! 🥷

Live masterclass