Mutliple custom facts not showing in facter

1,395 views
Skip to first unread message

Tony G.

unread,
Apr 6, 2011, 11:37:48 PM4/6/11
to puppet...@googlegroups.com
Hi,

I've noticed that defining multiple facts in one file is possible, and puppet can make use of them correctly, but when trying to call with facter --puppet they are not shown, do I need something special to make them work as any other single custom fact?

Master is running 2.6.7

This is a custom fact with two facts in it:
[modules/foobar/lib/facter/foobar.rb ]
require 'facter'
Facter.add("foo") do
  setcode do
    %x{/bin/date +%s}.chomp
  end
end
Facter.add("bar") do
  setcode do
    %x{/bin/date +%s}.chomp
  end
end

I used a simple notify in the node like this:  notify{ "custom_fact": message => "foo:$foo bar:$bar"}

Tested with Puppet Agent 2.6.2 and 2.6.7

Pulling the fact and makes use of it:

# puppet agent -t --environment=test --pluginsync
info: Retrieving plugin
notice: /File[/var/lib/puppet/lib/facter/foobar.rb]/ensure: defined content as '{md5}c28d8a783d44b9c15b7e61a6d90cf0e3'
notice: /File[/var/lib/puppet/lib/facter/utime.rb]/ensure: removed
info: Loading downloaded plugin /var/lib/puppet/lib/facter/foobar.rb
info: Loading facts in foobar
info: Loading facts in foobar
info: Caching catalog for squeeze.tonyskapunk.net
info: Applying configuration version '1302146930'
notice: foo:1302147318 bar:1302147318
notice: /Stage[main]//Node[squeeze.tonyskapunk.net]/Notify[custom_fact]/message: defined 'message' as 'foo:1302147318 bar:1302147318'
notice: Finished catalog run in 0.07 seconds

But not able to call them with facter:

root@squeeze:~# facter --puppet foo
root@squeeze:~# facter --puppet bar
root@squeeze:~#

Tested with Facter 1.5.7 and 1.5.9

Thanks.

--
Tony
http://blog.tonyskapunk.net

Cody Robertson

unread,
Apr 10, 2011, 2:56:02 PM4/10/11
to puppet...@googlegroups.com
Can you invoke any custom facts at all? I suspect it facter might not be looking in the right directory for your puppet facts and thus it's not finding them when run it locally.

I've confirmed no issue with defining multiple facts in a single file / calling them with facter locally:

root@falcon [~]# facter --puppet lvecpanel_version
lve-cpanel-plugin-0.2-1.el5.cloudlinux

root@falcon [~]# facter --puppet lvemanager_version
cpanel-lvemanager-0.3-2.el5.cloudlinux

Tony G.

unread,
Apr 10, 2011, 3:11:05 PM4/10/11
to puppet...@googlegroups.com
This is interesting, what is the name of your fact?

I replied on a forked thread, puppet-users was not included, here my response:

 [root@gnucloud facter]# echo $FACTERLIB

[root@gnucloud facter]# export FACTERLIB=/opt/puppet/test/modules/foobar/lib/facter
[root@gnucloud facter]# echo $FACTERLIB
/opt/puppet/test/modules/foobar/lib/facter
[root@gnucloud facter]# facter -p foo
[root@gnucloud facter]# pwd
/opt/puppet/test/modules/foobar/lib/facter
[root@gnucloud facter]# ls
foobar.rb
[root@gnucloud facter]# cat foobar.rb 
require 'facter'
Facter.add("foo") do
  setcode do
    %x{/bin/date +%s}.chomp
  end
end
Facter.add("bar") do
  setcode do
    %x{/bin/date +%s}.chomp
  end
end

My *guess* is that facter does not like having two facts in one fact, here I simply created another fact:

[root@gnucloud facter]# cat onefact.rb 
require 'facter'
Facter.add("onefact") do

  setcode do
    %x{/bin/date +%s}.chomp
  end
end

[root@gnucloud facter]# facter -p onefact
1302309123

Working without issues..

Doing another test, this time I just renamed the file with the fact:

[root@gnucloud facter]# mv onefact.rb onefact2.rb 
[root@gnucloud facter]# facter -p onefact
[root@gnucloud facter]# facter -p onefact2
[root@gnucloud facter]#

aha!, seems like facter is looking for the fact name that matches the file, woot! is this ok? is this the expected behavior?

Then somehow my assumption was correct, facter is not able to pick facts that the name of the file differs from the fact defined, anyway puppet processes them correctly.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.



--
Tony
http://blog.tonyskapunk.net

Cody Robertson

unread,
Apr 10, 2011, 5:09:01 PM4/10/11
to puppet...@googlegroups.com
Strange - in the example I used the file is named lvemanager_versions.rb while the facts are lvemanager_version and lvecpanel_version.  Although it's highly unlikely this is the problem I'm running facter 1.5.8 which is one version you're not running..

Tony G.

unread,
Apr 10, 2011, 5:18:26 PM4/10/11
to puppet...@googlegroups.com

Facter 1.5.9

Thanks

sent from my android

On Apr 10, 2011 4:09 PM, "Cody Robertson" <co...@hawkhost.com> wrote:

Strange - in the example I used the file is named lvemanager_versions.rb while the facts are lvemanager_version and lvecpanel_version.  Although it's highly unlikely this is the problem I'm running facter 1.5.8 which is one version you're not running..



--
You received this message because you are subscribed to the Google Groups "Puppet Users" group...

Cody Robertson

unread,
Apr 10, 2011, 9:37:48 PM4/10/11
to puppet...@googlegroups.com
It looks like it's a bug in 1.5.9. I upgraded this particular node to the latest (rc4) and now the multiple facts don't work as you initially described. I'd recommend opening a bug report as something changed across versions to cause this.

Cody Robertson

unread,
Apr 10, 2011, 9:42:45 PM4/10/11
to puppet...@googlegroups.com
Er, I upgraded to Facter rc5*

Tony G.

unread,
Apr 10, 2011, 11:04:21 PM4/10/11
to puppet...@googlegroups.com
I tried with rc4, upgradec to rc5 and same behavior, which version you tested out before, I recall testing on 1.5.7 too, with the same thing.

Thanks.

On Sun, Apr 10, 2011 at 8:42 PM, Cody Robertson <co...@hawkhost.com> wrote:
Er, I upgraded to Facter rc5*

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.



--
Tony
http://blog.tonyskapunk.net

Cody Robertson

unread,
Apr 10, 2011, 11:21:47 PM4/10/11
to puppet...@googlegroups.com
I've only tested this on 1.5.8 where it worked. Upgraded to 1.5.9rc5 and it appears broken.

James Turnbull

unread,
Apr 11, 2011, 2:06:19 AM4/11/11
to puppet...@googlegroups.com
Cody Robertson wrote:
> I've only tested this on 1.5.8 where it worked. Upgraded to 1.5.9rc5 and it appears broken.
>

Can one of you please log a ticket for this - we'd obviously like to fix
it before we release Facter 1.5.9.

Thanks

James

--
James Turnbull
Puppet Labs
1-503-734-8571

Cody Robertson

unread,
Apr 11, 2011, 2:45:31 AM4/11/11
to puppet...@googlegroups.com, ja...@puppetlabs.com
I'll test it on more versions tomorrow to see if I can pinpoint exactly where the change happened: http://projects.puppetlabs.com/issues/7039

Ohad Levy

unread,
Apr 11, 2011, 5:03:29 AM4/11/11
to puppet...@googlegroups.com
git bisect is a great way to figure out which commit broke it.

Ohad

On Mon, Apr 11, 2011 at 9:45 AM, Cody Robertson <co...@hawkhost.com> wrote:
I'll test it on more versions tomorrow to see if I can pinpoint exactly where the change happened: http://projects.puppetlabs.com/issues/7039

Cody Robertson

unread,
Apr 11, 2011, 1:41:09 PM4/11/11
to puppet...@googlegroups.com
I went ahead and gave it a whirl and it appears to have done the job in finding which commit introduced the change. Thanks for the tip!

--
Cody Robertson
1-800-859-8803 ext. 5
Reply all
Reply to author
Forward
0 new messages