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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1351 - (hide annotations) (download)
Tue Mar 22 17:27:03 2011 UTC (13 years, 1 month ago) by misc
File size: 647 byte(s)
add a function to fetch stored fact from the db
1 misc 1351 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.30