Version information
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
Add this module to your Puppetfile:
mod 'lcrownover-facter', '1.0.0'
Learn more about managing modules with a PuppetfileDocumentation
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
What are tasks?
Modules can contain tasks that take action outside of a desired state managed by Puppet. It’s perfect for troubleshooting or deploying one-off changes, distributing scripts to run across your infrastructure, or automating changes that need to happen in a particular order as part of an application deployment.
Tasks in this module release
Dependencies
- puppetlabs/stdlib (>= 3.2.0 < 7.0.0)