X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fpuppetmaster%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fwhohosts.rb;h=43592854ca1e2f47de66f6ca5394427800ba5ec2;hb=d55193d32bcface5935ae2a6acc2cdc6eed71a80;hp=20f83d367851f75ad07ad9ba6f957eaaff82038b;hpb=7fbd1fb63f9a8e87683b183e8b39bce18af59a4a;p=mirror%2Fdsa-puppet.git diff --git a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb index 20f83d367..43592854c 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb @@ -5,20 +5,14 @@ module Puppet::Parser::Functions ipAddrs = args[0] yamlfile = args[1] - parser.watch_file(yamlfile) - - $KCODE = 'utf-8' ans = {"name" => "unknown"} yaml = YAML.load_file(yamlfile) ipAddrs.each do |addr| yaml.keys.each do |hoster| - if yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange') - netrange = yaml[hoster]['netrange'] - else - next - end + next unless yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange') + netrange = yaml[hoster]['netrange'] netrange.each do |net| begin @@ -32,6 +26,9 @@ module Puppet::Parser::Functions end end end + if not ans['longname'] + ans['longname'] = ans['name'] + end return ans end end