From b6e6411cde70148acac94808f002753bf2a12206 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 1 Mar 2011 10:51:18 +0100 Subject: [PATCH] Handle old and new style hosters.yaml --- .../lib/puppet/parser/functions/whohosts.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb index c2bda8c4a..972c3bc93 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb @@ -15,10 +15,16 @@ module Puppet::Parser::Functions if (nodeinfo['ldap'].has_key?('ipHostNumber')) nodeinfo['ldap']['ipHostNumber'].each do |addr| yaml.keys.each do |hoster| - yaml[hoster].each do |net| - if IPAddr.new(net).include?(addr) - ans = hoster - end + if yaml[hoster].kind_of?(Array) + netrange = yaml[hoster] + elsif yaml[hoster].kind_of?(Array) and yaml[hoster].has_key?['netrange'] + netrange = yaml[hoster]['netrange'] + else + next + end + netrange.each do |net| + if IPAddr.new(net).include?(addr) + return hoster end end end @@ -26,3 +32,6 @@ module Puppet::Parser::Functions return ans end end +# vim:set ts=2: +# vim:set et: +# vim:set shiftwidth=2: -- 2.20.1