diff options
author | Michael Scherer <misc@mageia.org> | 2011-03-22 17:27:03 +0000 |
---|---|---|
committer | Michael Scherer <misc@mageia.org> | 2011-03-22 17:27:03 +0000 |
commit | c835415f36b3fb86fb245f5502320b30b667a3cd (patch) | |
tree | d0067a9f242a3f8f68cb328bcb6c65fe0119ddc0 /modules/stored_config/lib | |
parent | 494e64754efec2844600cc3aa2b7c4344cc3c18b (diff) | |
download | puppet-c835415f36b3fb86fb245f5502320b30b667a3cd.tar puppet-c835415f36b3fb86fb245f5502320b30b667a3cd.tar.gz puppet-c835415f36b3fb86fb245f5502320b30b667a3cd.tar.bz2 puppet-c835415f36b3fb86fb245f5502320b30b667a3cd.tar.xz puppet-c835415f36b3fb86fb245f5502320b30b667a3cd.zip |
add a function to fetch stored fact from the db
Diffstat (limited to 'modules/stored_config/lib')
-rw-r--r-- | modules/stored_config/lib/puppet/parser/functions/get_fact.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/stored_config/lib/puppet/parser/functions/get_fact.rb b/modules/stored_config/lib/puppet/parser/functions/get_fact.rb new file mode 100644 index 00000000..1aae8b5a --- /dev/null +++ b/modules/stored_config/lib/puppet/parser/functions/get_fact.rb @@ -0,0 +1,18 @@ +require 'puppet/rails' + +# get_fact($node,$fact) +# -> return the fact, from stored config + +module Puppet::Parser::Functions + newfunction(:get_fact, :type => :rvalue) do |args| + node = args[0] + fact = args[1] + + Puppet::Rails.connect() + return Puppet::Rails::FactValue.find( :first, + :joins => [ :host, :fact_name ], + :conditions => { :fact_names => {:name => fact }, + :hosts => {:name => node }} + ).value + end +end |