unless attributes.include?("*")
next if attributes.any?{ |a| not x[a] or x[a].empty? }
end
- results[x['hostname'][0]] = []
- results[x['hostname'][0]] << x
+ results[x['hostname'][0]] = x
end
rescue LDAP::ResultError
raise Puppet::ParseError, "LDAP error"
ans = "unknown"
yaml = YAML.load_file(yamlfile)
- if (nodeinfo['ldap'].at(0)) and (nodeinfo['ldap'][0].has_key?('ipHostNumber'))
- nodeinfo['ldap'][0]['ipHostNumber'].each do |addr|
+ 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)
mxregex = Regexp.new('^\d+\s+(.*)\.$')
mxinfo.keys.sort.each do |host|
- mxinfo[host][0]['mXRecord'].each do |mx|
+ mxinfo[host]['mXRecord'].each do |mx|
mxmatch = mxregex.match(mx)
if mxmatches.include?(mxmatch[1])
route = host + ":\t\t" + host
mailrelay = []
localinfo.keys.sort.each do |node|
if localinfo[node]['mailrelay']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /:/
mailrelay << ip
end
mailrelay = []
localinfo.keys.sort.each do |node|
if localinfo[node]['mailrelay']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /\./
mailrelay << ip
end
nagii = []
localinfo.keys.sort.each do |node|
if localinfo[node]['nagiosmaster'] or localinfo[node]['extranrpeclient']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /:/
nagii << ip
end
nagii = []
localinfo.keys.sort.each do |node|
if localinfo[node]['nagiosmaster'] or localinfo[node]['extranrpeclient']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /\./
nagii << ip
end
munins = []
localinfo.keys.sort.each do |node|
if localinfo[node]['muninmaster']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /:/
munins << ip
end
munins = []
localinfo.keys.sort.each do |node|
if localinfo[node]['muninmaster']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /\./
munins << ip
end
dbs = []
localinfo.keys.sort.each do |node|
if localinfo[node]['dbmaster']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /\./
dbs << ip
end
dbs = []
localinfo.keys.sort.each do |node|
if localinfo[node]['dbmaster']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /:/
dbs << ip
end
@def $HOST_DEBIAN_V4 = (<%=
dbs = []
keyinfo.keys.sort.each do |node|
- next unless keyinfo[node][0].has_key?('ipHostNumber')
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ next unless keyinfo[node].has_key?('ipHostNumber')
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /:/
dbs << ip
end
@def $HOST_DEBIAN_V6 = (<%=
dbs = []
keyinfo.keys.sort.each do |node|
- next unless keyinfo[node][0].has_key?('ipHostNumber')
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ next unless keyinfo[node].has_key?('ipHostNumber')
+ keyinfo[node]['ipHostNumber'].each do |ip|
next if ip =~ /\./
dbs << ip
end
end
purp += 'Welcome to ' + fqdn
-if (nodeinfo['ldap'].at(0)) and (nodeinfo['ldap'][0].has_key?('purpose'))
- if nodeinfo['ldap'][0]['purpose'].include?('buildd')
+if (nodeinfo['ldap'].has_key?('purpose'))
+ if nodeinfo['ldap']['purpose'].include?('buildd')
purp += ", the Debian "
- if nodeinfo['ldap'][0].has_key?('architecture')
- purp += nodeinfo['ldap'][0]['architecture'][0]
+ if nodeinfo['ldap'].has_key?('architecture')
+ purp += nodeinfo['ldap']['architecture'][0]
end
purp += " build daemon\n"
- elsif nodeinfo['ldap'][0]['purpose'].include?('porterbox')
+ elsif nodeinfo['ldap']['purpose'].include?('porterbox')
purp += ", the Debian "
- if nodeinfo['ldap'][0].has_key?('architecture')
- purp += nodeinfo['ldap'][0]['architecture'][0]
+ if nodeinfo['ldap'].has_key?('architecture')
+ purp += nodeinfo['ldap']['architecture'][0]
end
purp += " porterbox\n"
purp += "\n"
purp += "See 'dchroot -l' for a list of available chroots.\n"
- if nodeinfo['ldap'][0].has_key?('admin')
- purp += "Please contact #{nodeinfo['ldap'][0]['admin'][0]} for install requests,\n"
+ if nodeinfo['ldap'].has_key?('admin')
+ purp += "Please contact #{nodeinfo['ldap']['admin'][0]} for install requests,\n"
purp += "following the recommendations in <URL:http://dsa.debian.org/doc/install-req/>.\n"
end
else
purp += ", used for the following services:\n"
- nodeinfo['ldap'][0]['purpose'].sort.each do |l|
+ nodeinfo['ldap']['purpose'].sort.each do |l|
if l =~ /\[\[(\*|-)?(.*?)\]\]/
l = $2
end
str = ''
localinfo.keys.sort.each do |node|
if localinfo[node]['muninmaster']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
str += "allow ^" + ip.split('.').join('\.') + "$\n"
end
end
nagii = []
localinfo.keys.sort.each do |node|
if localinfo[node]['nagiosmaster'] or localinfo[node]['extranrpeclient']
- nagii << keyinfo[node][0]['ipHostNumber']
+ nagii << keyinfo[node]['ipHostNumber']
end
end
str = ''
localinfo.keys.sort.each do |node|
if localinfo[node]['nagiosmaster']
- keyinfo[node][0]['ipHostNumber'].each do |ip|
+ keyinfo[node]['ipHostNumber'].each do |ip|
str += "\t" + ip + "/32;\n"
end
end
if allowed_ports.length > 0
sshkey = getportforwarderkey(sourcehost)
- remote_ip = keyinfo[sourcehost][0]['ipHostNumber'].join(',')
+ remote_ip = keyinfo[sourcehost]['ipHostNumber'].join(',')
local_bind = '127.101.%d.%d'%[ (sourcehost.hash / 256 % 256), sourcehost.hash % 256 ]
lines << "# from #{sourcehost}"
when "bartok.debian.org", "beethoven.debian.org" then
out = ''
keyinfo.keys.sort.each do |node|
- out += '# ' + keyinfo[node][0]['hostname'].to_s + '
-command="/usr/lib/da-backup/da-backup-ssh-wrap ' + keyinfo[node][0]['hostname'].to_s + '",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,from="' + keyinfo[node][0]['ipHostNumber'].join(',') + '" ' + keyinfo[node][0]['sshRSAHostKey'].to_s + '
+ out += '# ' + keyinfo[node]['hostname'].to_s + '
+command="/usr/lib/da-backup/da-backup-ssh-wrap ' + keyinfo[node]['hostname'].to_s + '",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,from="' + keyinfo[node]['ipHostNumber'].join(',') + '" ' + keyinfo[node]['sshRSAHostKey'].to_s + '
'
end