When Facter’s built-in facts cause issues with third-party software or Puppet Enterprise (PE), you might want to override or disable them.
For example:
-
The
ec2
structured fact might cause repeated connections to Openstack metadata nodes. -
A very large fact might cause performance issues, such as slow Puppet runs.
-
Solaris automounts each user’s home directory, causing the
mountpoints
fact, which stores all filesystems mounted on each system, to become very large.
Version and installation information
PE version: All supported
Solution
In PE 2021.0 and later, you can block any fact using the blocklist
setting in facter.conf
In PE 2019.8, you can block the generation of ec2_metadata
, ec2_userdata
, mountpoints
, filesystems
, or partitions
facts using the blocklist
setting in facter.conf
, preventing all facts within the listed groups from being resolved when Facter runs.
If you can’t use those solutions, complete the following steps to create a module that overrides the fact. If you are using a version of PE that doesn’t support using blocklist
, we recommend that you upgrade to the most recent long-term support version (PE 2021.7) . However, if that’s not possible, you can use the steps in this article to replace a fact with an empty string. In this example, the new module uses a custom fact to replace the mountpoints
fact value with an empty string.
You can override a different fact by replacing mountpoints
with a different fact.
-
Create a module:
puppet module generate --skip-interview user-factoverride
-
Create a directory for your fact in the module:
mkdir -p factoverride/lib/facter
-
Create a custom fact in the file
factoverride/lib/facter/mountpoints_override.rb
with the following contents:Facter.add(:mountpoints) do has_weight 100 end
-
Deploy the module.
If you use Code Manager: Deploy the module using Code Manager.
If you do not use Code Manager: Deploy the module to the module directory for the desired environment.
-
As root, log into the primary server. Copy the new fact to the cache directory with
pluginsync
by runningpuppet agent -t
. Your output should be similar to the following:Info: Using configured environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/mountpoints_override.rb]/ensure: defined content as '{md5}7392c29fb7fe442b55196fc7aa8a92fb' Info: Loading facts Info: Caching catalog for puppetserver.domain.com Info: Applying configuration version '1c4bf0f741772f86cc7d91479a85b9d6b78f455d'
-
Verify that the override was successful by checking that
mountpoints
does not return any output. As root on the primary server runfacter -p mountpoints
.
How can we improve this article?
0 comments
Please sign in to leave a comment.
Related articles