Forge Home

facter

Provides a simple method to manage external facts

9,740 downloads

5,477 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.0.0 (latest)
  • 0.2.3
  • 0.2.2
  • 0.2.1
  • 0.2.0
  • 0.1.3
  • 0.1.2
  • 0.1.1
  • 0.1.0
released May 13th 2021
This version is compatible with:
  • Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
  • Puppet >= 4.10.0 < 8.0.0
  • , , , , , ,
Tasks:
  • remove_fact
  • set_fact

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'lcrownover-facter', '1.0.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add lcrownover-facter
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install lcrownover-facter --version 1.0.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

lcrownover/facter — version 1.0.0 May 13th 2021

facter

Provides a simple way to manage external facts

Setup

All you need to do is include the module:

include facter

It will automatically create the facts.d path:

  • Linux:

    /etc/puppetlabs/facter/facts.d
    
  • Windows:

    C:\ProgramData\PuppetLabs\facter\facts.d\
    

Usage

This module creates yaml files in the facts.d directory with the resource name as the file name and content following the external fact convention for yaml:

resource_name: value

You can use the facter::fact defined type in the manifest, or use facter::fact_hash: in hiera to set and remove facts

Examples

Set a fact in a puppet manifest

facter::fact { 'datacenter':
  value => 'us_west',
}

Remove a fact you previously set

facter::fact { 'datacenter':
  ensure => absent,
}

Set a fact with a custom filename

facter::fact { 'datacenter':
  file_name => 'my_datacenter',
  value     => 'us_west',
}

Set one or multiple facts using hiera

facter::fact_hash:
  datacenter: 'us_west'
  cluster: 'web'

Remove facts using hiera

facter::fact_hash:
  datacenter: 'us_west'
  cluster:
    ensure => 'absent'

Or the shorter version to remove a fact, making use of the reserved absent value:

facter::fact_hash:
  datacenter: 'us_west'
  cluster: 'absent'

Parameters

facter

  • disable_reserved_absent

    optional[Boolean]: Disables the reserved word 'absent' for hiera facts. The only reason to disable this would be if you wanted the ability to set the value of facts to the string 'absent'.

    default: false

facter::fact

  • ensure

    optional[String]: Determines if the resource is created or removed.

    default: 'present'

  • value

    required[String]: Value of the fact to be set.

    warning: absent is a reserved word for value in the hiera implementation and will remove the fact

  • file_name

    optional[String]: Set the target file name instead of using the resource name as the file name.

    default: $title

Tasks

This module comes with two cross-platform tasks, set_fact and remove_fact

set_fact

Accepts a name and value parameter. Creates a fact file in the facts.d directory in the same manner as the defined type

bolt task run facter::set_fact --nodes web1.company.vm name=mytestfact value=mytestvalue

remove_fact

Accepts a name parameter. Removes a fact file in the facts.d directory, returns an error if the file doesn't exist

bolt task run facter::remove_fact --nodes web1.company.vm name=mytestfact