On Apr 9, 9:04 am, Pete Emerson <[email protected]> wrote:
> I see the instructions for creating custom facter recipes here:
>
> http://projects.reductivelabs.com/projects/puppet/wiki/Adding_Facts
>
> and in this thread, James Turnbull suggests that Facter might some day
> support other languages besides ruby:
>
> http://groups.google.com/group/puppet-users/browse_thread/thread/8c12...
>
> He writes:
> > Agreed. That'd be a useful feature and if we'd probably do it like
> > Nagios plug-ins do - doesn't matter what the language is as long as they
> > output data that the Facter API can parse into facts - Perl, Python, C,
> > Rexx (*coughs*), etc.
>
> Has such a feature been released in the latest versions of facter / puppet ?
>
> I'm experimenting with puppet with no puppetmaster, but need to add
> facts that my puppet_node_classifier usually provides. I assume using
> facter is the way to go (I have not played with facter yet). Is there
> an alternate solution for getting my own facts into a puppet node
> without a puppetmaster?
>
> Pete
Okay, I think I got it. Pretty exciting, especially given I don't know
ruby at all. Comments appreciated, for sure, as I'm not positive that
I might be trying to fit a square peg into a round hole.
I've made a fact that loads results from a perl script.
1) The sample perl script gives output just like a puppet node
classifier would using YAML
2) The ruby parses the output of the perl script and generates facts.
################### /usr/local/bin/facter.pl
#!/usr/bin/perl -w
print <<END
---
parameters:
dongle: "special_dongle_value"
END
################### /var/lib/puppet/lib/facter/classifier.rb
require "yaml"
yaml_obj = YAML::load(%x{/usr/local/bin/facter.pl})
yaml_obj['parameters'].each { |key, value|
Facter.add(key) do
setcode do
value
end
end
}
#################### Manual run
# export FACTERLIB=/var/lib/puppet/lib/facter ; facter | grep dongle
dongle => special_dongle_value
#################### /etc/puppet/puppet.conf additions
pluginsync = true
factpath = $vardir/lib/facter
#################### test.pp
exec { "dongle":
command => "/bin/echo '$dongle' > /tmp/dongle.txt"
}
###################### Puppet run
# puppet -v test.pp
info: Loading facts in classifier
info: Applying configuration version '1270834249'
notice: //Exec[dongle]/returns: executed successfully
# cat /tmp/dongle.txt
special_dongle_value
##############################################
Pete
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.