/[adm]/puppet/modules/stored_config/lib/puppet/parser/functions/get_fact.rb
ViewVC logotype

Contents of /puppet/modules/stored_config/lib/puppet/parser/functions/get_fact.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1351 - (show annotations) (download)
Tue Mar 22 17:27:03 2011 UTC (10 years, 6 months ago) by misc
File size: 647 byte(s)
add a function to fetch stored fact from the db
1 require 'puppet/rails'
2
3 # get_fact($node,$fact)
4 # -> return the fact, from stored config
5
6 module Puppet::Parser::Functions
7 newfunction(:get_fact, :type => :rvalue) do |args|
8 node = args[0]
9 fact = args[1]
10
11 Puppet::Rails.connect()
12 return Puppet::Rails::FactValue.find( :first,
13 :joins => [ :host, :fact_name ],
14 :conditions => { :fact_names => {:name => fact },
15 :hosts => {:name => node }}
16 ).value
17 end
18 end

  ViewVC Help
Powered by ViewVC 1.1.28