X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fpuppetmaster%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fyamlinfo.rb;h=42a47959adf1713131675ef2db3fddc73a1b426a;hb=b2a6f14054fb5d39f29be46e49cb456fb5f43b5b;hp=0d12c661433ef26a59468f623d701d4c9aa4caf6;hpb=7279eedc32f3735e78c8be28c07c3ce75aab697f;p=mirror%2Fdsa-puppet.git diff --git a/modules/puppetmaster/lib/puppet/parser/functions/yamlinfo.rb b/modules/puppetmaster/lib/puppet/parser/functions/yamlinfo.rb index 0d12c6614..42a47959a 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/yamlinfo.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/yamlinfo.rb @@ -1,11 +1,11 @@ +require 'puppet/file_system' + module Puppet::Parser::Functions newfunction(:yamlinfo, :type => :rvalue) do |args| host = args[0] - yamlfile = args[1] - self.interp.newfile(yamlfile) - def read_yaml(yaml, host) + read_yaml = lambda { |yaml, host| results = {} ['nameinfo', 'footer'].each do |detail| @@ -27,8 +27,7 @@ module Puppet::Parser::Functions results['smarthost'] = '' results['heavy_exim'] = '' results['smarthost_port'] = 587 - results['reservedaddrs'] = '0.0.0.0/8 : 127.0.0.0/8 : 10.0.0.0/8 : 169.254.0.0/16 : 172.16.0.0/12 : 192.0.0.0/17 : 192.168.0.0/16 : 224.0.0.0/4 : 240.0.0.0/5 : 248.0.0.0/5' - + if yaml['host_settings'].kind_of?(Hash) yaml['host_settings'].each_pair do |property, values| if values.kind_of?(Hash) @@ -39,11 +38,11 @@ module Puppet::Parser::Functions end end return(results) - end + } require 'yaml' - $KCODE = 'utf-8' + yamlfile = Puppet::Parser::Files.find_file('debian_org/misc/local.yaml', compiler.environment) yaml = YAML.load_file(yamlfile) ret = {} @@ -51,10 +50,10 @@ module Puppet::Parser::Functions Dir.entries('/var/lib/puppet/yaml/node/').each do |fname| next unless fname =~ /(.*)\.yaml$/ host_name = $1 - ret[host_name] = read_yaml(yaml, host_name) + ret[host_name] = read_yaml.call(yaml, host_name) end else - ret = read_yaml(yaml, host) + ret = read_yaml.call(yaml, host) end return(ret)