Pete Emerson
2010-Apr-09 16:04 UTC
[Puppet Users] Custom facts for a puppetmasterless environment
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/8c127ae8898d3bcf/c5ca551b77c4eb67?lnk=gst&q=facter+perl#c5ca551b77c4eb67 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 -- 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.
Pete Emerson
2010-Apr-09 17:38 UTC
[Puppet Users] Re: Custom facts for a puppetmasterless environment
On Apr 9, 9:04 am, Pete Emerson <pemer...@gmail.com> 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? > > PeteOkay, 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 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.
Thomas A. McGonagle
2010-Apr-09 23:32 UTC
Re: [Puppet Users] Re: Custom facts for a puppetmasterless environment
I also like to embed facts with bash logic using bash startup files in /etc/profile.d/puppet.sh The puppet labs FAQ has a write up on it. Can I access environmental variables with Facter? Not directly no but Facter has a special types of facts that can be set from environment variables. Any environment variable with a prefix of FACTER<http://puppetlabs.com/projects/facter> will be taken by Facter and converted into a fact, for example: $ FACTER_FOO="bar" $ export FACTER_FOO $ facter | grep ''foo'' foo => bar The value of the FACTER_FOO environmental variable would now be available in your Puppet manifests as $foo with a value of ‘bar’. -Tom Thomas A. McGonagle tom@dataero.com Google Voice: 617-229-5185 On Fri, Apr 9, 2010 at 1:38 PM, Pete Emerson <pemerson@gmail.com> wrote:> On Apr 9, 9:04 am, Pete Emerson <pemer...@gmail.com> 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 puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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.
Apparently Analagous Threads
- Node classifier not loading any defined classes
- How to recive Incoming calls in Chan Dongle ?
- [dongle0] timedout while waiting 'OK' in response to 'AT'
- [dongle0] timedout while waiting 'OK' in response to 'AT'
- OT - Chan-mobile -Bluetooth dongle on remote LAN workstation