Home

Accessing Custom Facter Facts From the Cli

At $WORK we distribute some custom facts with Puppet using puppet’s pluginsync.
This will, upon first puppet run, sync the custom fact out to the client and make it available to future puppet runs.
At this stage though, running facter from the cli independently from puppet is not able to find these custom facts.
This is due to facter, when called from the CLI, does not read /etc/puppet/puppet.conf for the factpath setting so can not find the custom facts that pluginsync has distributed out to $vardir/lib/facter

To fix this is pretty simple.
We just need to make sure the ENV variable FACTERLIB has been set and includes $vardir/lib/facter

facterpath.pp
# Distibute a profile.d file 
# that extends the FACTLIB env variable.
#
class utils::facterpath {
  file {'/etc/profile.d/facter.sh':
    ensure  => present,
    mode    => '0644'
    content => 'export FACTERLIB=/var/lib/puppet/lib',
  }
}

Comments