On Jul 27, 3:30 pm, scott <mcco...@gmail.com> wrote:
> I'm a newbie attempting to get a custom fact distributed to clients.
> I've followed the instructions 
> athttp://reductivelabs.com/trac/puppet/wiki/AddingFacts
> and based my first fact on a simple recipe.
>
> I'm having at least one problem and possibly more.
>
> 1) Puppet/facter fails to load the custom fact, complaining that "non-
> sh interpreters are not currently supported"
> 2) Puppet seems to be loading the fact twice (though that may be
> because of the above).

[...]

> And I've put test_fact.rb in /etc/puppet/modules/custom/plugins/facter/
> test_fact.rb:
> ----------
> # cat modules/custom/plugins/facter/test_fact.rb
> # test_fact.rb
> ## Return symbolic network name based on eth0 subnet.
>
> Facter.add("test_fact") do
>         confine :kernel => :linux
>         ipaddress=%x{/sbin/ifconfig eth0}.chomp
>         iparray = ipaddress.split(".")
>         netw = iparray[0]+"."+iparray[1]+"."+iparray[2]  #I never
> claimed to be a ruby programmer
>         netname = case netw
>                 when "192.168.4" then "siteA"
>                 when "10.1.1" then "siteA"
>                 when "192.168.88" then "siteB"
>                 else "Unknown"
>         end
>
>         netname
> end

[...]

> Can anyone shed some light on this issue?

I think I can.  It doesn't look like you have accurately followed the
custom fact instructions you referenced.  Your custom code should be
wrapped in "setcode do [...] end", as in the example.

Also, I think you'll find that your code doesn't do what you want, for
"/sbin/ifconfig eth0" returns a lot more information than just the
host's IP address.

Also also, on my linux systems, facter 1.5.6 discerns standard facts
"ipaddress" and "ipaddress_eth0".  Using one of these, you may be able
to get away without a custom fact at all, instead defining "netname"
as a standard Puppet variable and initializing it based on one of
those facts.

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

Reply via email to