facter

pdk
tasks
Provides a simple method to manage external facts
Lucas Crownover

Lucas Crownover

lcrownover

3,102 downloads

1,419 latest version

4.8 quality score

Version information

  • 0.2.3 (latest)
  • 0.2.2
  • 0.2.1
  • 0.2.0
  • 0.1.3
  • 0.1.2
  • 0.1.1
  • 0.1.0
released Mar 2nd 2020
This version is compatible with:
  • Puppet Enterprise 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 < 7.0.0
  • CentOS
    ,
    OracleLinux
    ,
    RedHat
    ,
    Scientific
    ,
    Debian
    ,
    Ubuntu
    ,
    windows
Tasks:
  • remove_fact
  • set_fact

Start using this module

Documentation

lcrownover/facter — version 0.2.3 Mar 2nd 2020

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