Ask Your Question

Overwrite facter 'osfamily' value

asked 2015-09-01 13:11:36 -0500

udaysagar gravatar image

I extended a module by calling it from my module. The base module prefers to identify Amazon Linux OSfamily as 'Redhat' but the facter installed by puppet on the Amazon Linux OS reports the os as 'Linux'.

I want to correct this bug by overwriting the facter value of osfamily from Linux to Redhat before calling the base module.

my osfamily.rb inside mymodule/lib/facter is

  Facter.add('osfamily') do
    setcode do
       case Facter.value(:operatingsystem)
       when "Amazon"

But the problem is, I am unable to overwrite the osfamily value. Even after loading facts from osfamily.rb, osfamily is still being reported as 'Linux' instead of 'Redhat'.

my code is working correctly for new values like 'osfamilytest' or ''operatingsystemreleasetest' but not for existing values like 'osfamily' or 'operatingsystemrelease'.

Puppet Version: 2.7.25 
Facter Version: 1.6.18 
Operating System:
Amazon Linux 2015.03 
Puppet installation steps:
yum install puppet
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-09-02 08:24:15 -0500

johnnyb04 gravatar image

Rather than writing a custom fact, I suggest re-writing the core fact to include Amazon. They have a fix on adding Amazon as an operating system, so you might can just upgrade facter/puppet to correct this automatically. On my computer, the core osfamily.rb file is located under /usr/lib/ruby/site_ruby/1.8/facter. Changing it to include Amazon might fix your problem.

edit flag offensive delete link more


The problem is I am extending a module that does not support Amazon Linux with facter versions < 1.7 and I want to support them.

udaysagar gravatar imageudaysagar ( 2015-09-07 20:40:27 -0500 )edit

I found an answer on stack overflow [] but as the answer says, adding a weight of 100 will just report my new custom facts to other existing modules which might be expecting older facter values. Do you know how to limit my custom facts to affect only my module?

udaysagar gravatar imageudaysagar ( 2015-09-07 20:44:12 -0500 )edit

You might could create a new fact with a new name just for this. You'd need to configure your module to look at this new value. If non-Amazon clients would use this module too, you'll need to add an IF statement at the beginning that checks to see if your new fact amazon_linux_version != null.

johnnyb04 gravatar imagejohnnyb04 ( 2015-09-08 07:39:53 -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


Asked: 2015-09-01 13:11:36 -0500

Seen: 484 times

Last updated: Sep 02 '15