Ask Your Question

Question on custom fact

asked 2016-03-11 18:56:43 -0600

ancymathews gravatar image

updated 2016-03-11 23:43:10 -0600

Hi, I am trying to get my first custom fact working.

My custom fact executes a shell script to get the value and returns a string. Code is :

Facter.add(':ora_psu_num') do
setcode do

To test it I set env variable $FACTERLIB to include my custom facter code and query

facter :ora_psu_num

and I get the expected result


However, When I try to get it from puppet code it is not returning any value:

Code is:

notify {"$foo":}


puppet apply test_facter.pp
Could not retrieve fact='package_provider', resolution='<anonymous>': Malformed version number string 3.7.4 (Puppet Enterprise 3.7.2)
Notice: Compiled catalog for in environment production in 0.02 seconds
Notice: /Stage[main]/Main/Notify[]/message: defined 'message' as ''
Notice: Finished catalog run in 0.11 seconds
Error: Failed to apply catalog: No title provided and "Notify[]" is not a valid resource reference

What am I doing wrong? Advice.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-11 19:36:59 -0600

ancymathews gravatar image

updated 2016-03-11 23:43:29 -0600

I figured it out.

Modified the code from

Facter.add(':ora_psu_num' )do


Facter.add(:ora_psu_num )do

and everything worked as expected.

edit flag offensive delete link more


Nice catch. In ruby, a name prefixed with ":" is a symbol, and in your earlier example, you created a fact with the string ":ora_psu_num" looking up "facter :ora_psu_num" found the fact (with the : as a part of the key) Good luck, happy factoring! Hard to find good help on custom facts!

DarylW gravatar imageDarylW ( 2016-03-13 23:35:35 -0600 )edit

Thank you for the explanation, It makes sense now.

ancymathews gravatar imageancymathews ( 2016-03-14 00:45:51 -0600 )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


Asked: 2016-03-11 18:56:43 -0600

Seen: 278 times

Last updated: Mar 11 '16