1 require 'puppet/file_system'
3 module Puppet::Parser::Functions
4 newfunction(:yamlinfo, :type => :rvalue) do |args|
8 read_yaml = lambda { |yaml, host|
11 ['nameinfo', 'footer'].each do |detail|
12 if yaml.has_key?(detail)
13 if yaml[detail].has_key?(host)
14 results[detail] = yaml[detail][host]
19 if yaml.has_key?('services')
20 yaml['services'].each_pair do |service, hostlist|
21 hostlist=[hostlist] unless hostlist.kind_of?(Array)
22 results[service] = hostlist.include?(host)
26 if yaml['host_settings'].kind_of?(Hash)
27 yaml['host_settings'].each_pair do |property, values|
28 if values.kind_of?(Hash)
29 results[property] = values[host] if values.has_key?(host)
30 elsif values.kind_of?(Array)
31 results[property] = values.include?(host)
40 yamlfile = Puppet::Parser::Files.find_file('debian_org/misc/local.yaml', compiler.environment)
41 yaml = YAML.load_file(yamlfile)
45 Dir.entries('/var/lib/puppet/yaml/node/').each do |fname|
46 next unless fname =~ /(.*)\.yaml$/
48 ret[host_name] = read_yaml.call(yaml, host_name)
51 ret = read_yaml.call(yaml, host)