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
- Puppet >= 6.0.0 < 8.0.0
- AIX, Debian, RedHat, CentOS, OracleLinux, Scientific, Solaris, SLES, SLED, Ubuntu, windows
Start using this module
Add this module to your Puppetfile:
mod 'ghoneycutt-facter', '4.0.0'
Learn more about managing modules with a PuppetfileDocumentation
puppet-module-facter
Table of Contents
- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with facter
- Usage - Configuration options and additional functionality
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Module description
This module manages facter, specifically the facts.d directory, symlinks to facter that are in your PATH and the ability to define external facts.
Setup
What facter affects
Ensure that /etc/facter/facts.d
exists with the correct permissions
and populate it with facts.txt
which is used for external facts. It
can optionally create a symlink such as /usr/local/bin/facter
to point
to facter in the puppet package that may not be in your $PATH
.
It has defined types for specifying external facts. This allows you to
seed already known information on the system. facter::fact
is for
traditional key=value where the value is a string.
facter::structured_data_fact
allows values to be structured data such
as arrays and hashes. To achive this, the structured data is converted
to YAML format.
Beginning with facter
Declare the main class as demonstrated below.
Usage
You can manage all interaction with facter through the main facter
class. To specify external facts, use the facter::fact
defined type.
You can optionally specify a hash of external facts in Hiera.
facter::fact
---
facter::facts_hash:
role:
value: 'puppetmaster'
location:
value: 'RNB'
file: 'location.txt'
The above configuration in Hiera would produce
/etc/facter/facts.d/facts.txt
with the following content.
role=puppetmaster
It would also produce /etc/facter/facts.d/location.txt
with the following content.
location=RNB
facter::structured_data_fact
---
facter::structured_data_facts_hash:
foo:
data:
my_array:
- one
- two
- three
my_hash:
k: v
bar:
data:
bar_array:
- one
- two
- three
file: bar.yaml
facts_dir: /factsdir
The above configuration would create /etc/facter/facts.d/facts.yaml
with the fact my_array
. It would create /factsdir/bar.yaml
with the
fact bar_array
.
Minimum usage
include facter
Parameters for configuration
Please consult the REFERENCE.md
file for all parameters.
Limitations
This module is compatible with the latest release of Puppet versions 5
and 6. It supports all POSIX like platforms as well as Windows. See
.travis.yml
for an exact matrix of tested Ruby and Puppet versions.
Development
See CONTRIBUTING.md
for information related to the development of this
module.
Reference
Table of Contents
Classes
facter
: Manage facter
Defined types
facter::fact
: Define txt based external factsfacter::structured_data_fact
: Define YAML based external structured data facts.
Classes
facter
This class will manage facter and allow you to specify external facts.
Parameters
The following parameters are available in the facter
class:
manage_facts_d_dir
purge_facts_d
facts_d_dir
facts_d_owner
facts_d_group
facts_d_mode
path_to_facter
path_to_facter_symlink
ensure_facter_symlink
facts_hash
structured_data_facts_hash
facts_file
facts_file_owner
facts_file_group
facts_file_mode
manage_facts_d_dir
Data type: Boolean
Boolean to determine if the external facts directory will be managed.
Default value: true
purge_facts_d
Data type: Boolean
Boolean to determine if the external facts directory should be purged. This will remove files not managed by Puppet.
Default value: false
facts_d_dir
Data type: Stdlib::Absolutepath
Path to the directory which will contain the external facts.
Default value: '/etc/facter/facts.d'
facts_d_owner
Data type: String[1]
The owner of the facts_d_dir
.
Default value: 'root'
facts_d_group
Data type: String[1]
The group of the facts_d_dir
.
Default value: 'root'
facts_d_mode
Data type: Optional[Stdlib::Filemode]
The mode of the facts_d_dir
.
Default value: '0755'
path_to_facter
Data type: Stdlib::Absolutepath
The path to the facter binary.
Default value: '/opt/puppetlabs/bin/facter'
path_to_facter_symlink
Data type: Stdlib::Absolutepath
Path to a symlink that points to the facter binary.
Default value: '/usr/local/bin/facter'
ensure_facter_symlink
Data type: Boolean
Boolean to determine if the symlink should be present.
Default value: false
facts_hash
Data type: Hash
A hash of facter::fact
entries.
Default value: {}
structured_data_facts_hash
Data type: Hash
A hash of facter::structured_data_fact
entries.
Default value: {}
facts_file
Data type: Pattern[/\.txt*\Z/]
The file in which the text based external facts are stored. This file must end with '.txt'.
Default value: 'facts.txt'
facts_file_owner
Data type: String[1]
The owner of the facts_file.
Default value: 'root'
facts_file_group
Data type: String[1]
The group of the facts_file.
Default value: 'root'
facts_file_mode
Data type: Optional[Stdlib::Filemode]
The mode of the facts_file.
Default value: '0644'
Defined types
facter::fact
Define txt based external facts
Parameters
The following parameters are available in the facter::fact
defined type:
value
Data type: String[1]
Value of the fact.
fact
Data type: String[1]
Name of the fact
Default value: $name
file
Data type: Optional[String[1]]
File in which the fact will be placed. If not specified, use the default facts file.
Default value: undef
facts_dir
Data type: Optional[Stdlib::Absolutepath]
Directory in which the file will be placed. If not specified, use the default facts_d_dir.
Default value: undef
facter::structured_data_fact
Define YAML based external structured data facts.
Parameters
The following parameters are available in the facter::structured_data_fact
defined type:
data
Data type: Hash[String[1], Data]
A hash of facts. All keys must be strings.
file
Data type: Pattern[/\.yaml*\Z/]
File in which the fact will be placed. The file name must end with '.yaml'.
Default value: 'facts.yaml'
facts_dir
Data type: Optional[Stdlib::Absolutepath]
Directory in which the file will be placed. If not specified, use the default facts_d_dir.
Default value: undef
Changelog
v4.0.0 (2022-05-02)
Breaking changes:
Closed issues:
v3.5.0 - 2019-01-03
Support Puppet v6
v3.4.0 - 2017-11-01
Support Puppet v5
v3.3.1 - 2017-07-17
Do not manage package with Puppet v4 as it uses the AIO and facter is part of the puppet-agent package.
v3.3.0 - 2016-11-18
Support Ruby 2.3.1
v3.2.0 - 2016-06-03
Support Puppet v4 w/ strict variables
v3.1.1 - 2016-01-13
Bugfix for hiera_merge when no facts are specified
v3.1.0 - 2015-12-11
Add ability to control hiera lookup method
v3.0.0 - 2015-11-04
This version will always manage the facts.txt. Also adds support for Puppet v4.
v2.1.0 - 2015-07-23
Add param to purge facts.d, support future parser
v2.0.0 - 2015-02-01
Changed facter::facts to facter::facts_hash as $facts is now reserved for use with trusted node data.
v1.3.2 - 2015-01-06
Support future parser
v1.3.1 - 2014-11-25
Fix cyclic dependency
v1.3.0 - 2014-09-22
Support external facts
v1.2.1 - 2014-08-06
Add ability to specify arbitrary string for package_ensure
v1.2.0 - 2014-04-29
Ability to specify a symlink to facter Support Puppet v3.5.1 Support Ruby v2.1.0 on Puppet v3.5.1
v1.1.2 - 2014-01-29
Support Puppet v3.4 and Ruby v2.0.0
v1.1.1 - 2014-01-23
Bugfix in error message
v1.1.0 - 2013-11-11
Add ability to toggle management of resources
v1.0.0 - 2013-11-10
First release
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- puppetlabs/stdlib (>= 8.1.0 < 9.0.0)
- puppetlabs/concat (>= 7.1.1 < 8.0.0)
Copyright (C) 2013-2022 Garrett Honeycutt <code@garretthoneycutt.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.