From c835415f36b3fb86fb245f5502320b30b667a3cd Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Tue, 22 Mar 2011 17:27:03 +0000 Subject: add a function to fetch stored fact from the db --- .../lib/puppet/parser/functions/get_fact.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 modules/stored_config/lib/puppet/parser/functions/get_fact.rb 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 -- cgit v1.2.1