I''m a newbie attempting to get a custom fact distributed to clients. I''ve followed the instructions at http://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). Output on client: ---------- # puppetd -t info: Loading fact test_fact info: Retrieving plugins info: Loading fact test_fact Could not retrieve test_fact: non-sh interpreters are not currently supported Could not retrieve test_fact: non-sh interpreters are not currently supported info: Caching catalog at /var/lib/puppet/localconfig.yaml notice: Starting catalog run notice: Finished catalog run in 3.94 seconds ---------- Both the client and the server have the following two lines in puppet.conf''s [main] section: ---------- pluginsync = true factpath = $vardir/lib/facter ---------- 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 ---------- Running facter on the client machine directly after setting FACTERLIB to /var/lib/puppet/lib/facter/ shows the same error on the first line of output: "Could not retrieve test_fact: non-sh interpreters are not currently supported" Can anyone shed some light on this issue? Thanks! --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
On Jul 27, 5:30 pm, jcbollinger <John.Bollin...@stJude.org> wrote:> > 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.You are correct. The longer recipe I copied from did include the lines and in my wisdom I figured since I didn''t understand them I''d take them out (: Siimply wrapping the setcode around the code resolved these issues. Thank you for the gentle explanation.> > 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.Correct, I''ll clearly need to improve the code for it to be useful. I thought I''d try out custom facts and be a bit more clever. What I''m actually trying to accomplish is simply to have puppet set some variables in config files on the client (mail relay, ntp server, etc) differently depending on which network the client sits on (they will all share a puppet master). It''s not clear to me at this point whether a fact at all is even the right way to do this, or if I should instead be setting them in variables in a parent node definition and then using a template in each class that needs to differ, as shown in a sample recipe for resolv.conf (http://reductivelabs.com/trac/puppet/ wiki/Recipes/ResolvConf). A worthwhile exercise anyways, I guess the embarrassment of a stupid question is what I get for diving in without fully understanding Facter! I remain confused about the error message (non-sh interpreters sounds to me like it''s complaining about the first line, so I tried all manner of /usr/bin/ruby, /usr/bin/env ruby, simply commenting with the name as in the example, etc). At any rate, thanks again! -Scott --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
> A worthwhile exercise anyways, I guess the embarrassment of a stupid > question is what I get for diving in without fully understanding > Facter! I remain confused about the error message (non-sh > interpreters sounds to me like it''s complaining about the first line, > so I tried all manner of /usr/bin/ruby, /usr/bin/env ruby, simply > commenting with the name as in the example, etc).Can you file a Facter issue to improve the error reporting on this and I''ll try fix that up (and the documentation). Paul --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
On Jul 28, 5:22 am, Paul Nasrat <pnas...@googlemail.com> wrote:> Can you file a Facter issue to improve the error reporting on this and > I''ll try fix that up (and the documentation). > > PaulDone, it''s filed as Facter issue 2455 (http:// projects.reductivelabs.com/issues/2455). Thanks! --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---