Ask Your Question

Should "puppet resource" commands load module/lib/facter?

asked 2016-09-14 19:12:05 -0500

iamback gravatar image

I have a module that has ruby facts (.rb files) defined in <module>/lib/facter.

These facts load and are available and work great when I run puppet apply.

However, when i try to run "puppet resource" none of those facts in lib/facter are loaded and executed.

It seems to me like they should load and execute, should they not?

"augeasversion": "1.4.0",
"facterversion": "3.1.6",
"puppetversion": "4.4.2",
"rubyversion": "2.1.8",

Note, I test/develop these by typically storing the modules in a specific place and pointing to them with a --modulepath flag.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-09-15 01:55:12 -0500

lupin gravatar image

facter -p will show you all the facts including custom facts.

edit flag offensive delete link more


Thank you, unfortunately, it did not help. Puppet apply and agent, etc., seem to work and match mostly the output of the command you've suggested. However, running "puppet resource mycustomtype" is not loading and running fact logic/definitions from MyModule/lib/facter.

iamback gravatar imageiamback ( 2016-09-15 09:47:49 -0500 )edit

I have seen either manually setting the FACTERLIB, or running facter -p as sudo to actually see my own custom facts

DarylW gravatar imageDarylW ( 2016-09-15 13:08:17 -0500 )edit

answered 2016-09-14 21:50:57 -0500

DarylW gravatar image

The 'puppet resource' call calls the 'self.instances' method on the specified type.

There is a good explanation of how it works

The execution of facts doesn't have anything to do with calling the type's self.instances method.

edit flag offensive delete link more


Yes it does. And in that code I am trying to make use of a fact defined in a .rb file in MyModule/lib/facter, which happens just fine during puppet apply. However, puppet resource mytype does not appear to provide me those facts and that is the issue. It loads custom external facts fine though.

iamback gravatar imageiamback ( 2016-09-15 09:48:56 -0500 )edit

when you run puppet apply, it uses the local facter lib to figure out facts. if you run puppet resource mytype, it uses the facts that are installed for the system. I don't think puppet apply installs the facts to the system

DarylW gravatar imageDarylW ( 2016-09-15 13:06:18 -0500 )edit

If you have a puppet master, try running it that way. puppet agent -t --environment myenv, it'll sync the facter facts, and then run sudo facter -p to make sure that is has the correct path for facter

DarylW gravatar imageDarylW ( 2016-09-15 13:07:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-09-14 19:12:05 -0500

Seen: 42 times

Last updated: Sep 15 '16