Unable to add fact

good afternoon. I’m trying to add a fact to the foreman server in /etc/puppetlabs/code/modules/lib/name.rb with the following contents

# hardware_platform.rb

Facter.add("h_platform") do
  setcode do
    Facter::Util::Resolution.exec('/bin/uname -i')

after that, I run /opt/puppetlabs/puppet/bin/puppet agent -t on the client there are no errors, but when executing /opt/puppetlabs/puppet/bin/facter -p | grep h_platform, the output is empty, which indicates the absence of this fact. Please tell me what I’m missing?

Expected outcome:

Foreman and Proxy versions:
foreman 3.4
Foreman and Proxy plugin versions:
Distribution and version:

Other relevant data:

This is more of a Puppet issue than a Foreman issue, but I can try to help anyways.
Afaik, you need to have the lib folder in an actual puppet module for the plugin sync to work. Try putting your custom fact in a folder like /etc/puppetlabs/code/modules/platform/lib/name.rb (notice the additional folder between modules and lib). This should enable the client to sync the fact on the next run.
Also, you might want to check your puppet.conf if plugin sync is enabled and if your modulepath contains /etc/puppetlabs/code/modules/
You can also read more about the plugin sync here: Plug-ins in modules

1 Like

@areyus thank you very much! it works for me!