diff options
Diffstat (limited to 'modules')
-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 |