- results = function_yamlinfo(host, yamlfile)
- results['ldap'] = function_ldapinfo(host, '*')
- unless results['ldap']['ipHostNumber']
- raise Puppet::ParseError, "Host #{host} does not have ipHostNumber values in ldap"
- end
- results['hoster'] = whohosts(results['ldap']['ipHostNumber'], "/etc/puppet/modules/debian-org/misc/hoster.yaml")
-
- results['misc'] = {}
- fqdn = lookupvar('fqdn')
- if fqdn and fqdn == host
- v4ips = lookupvar('v4ips')
- if v4ips
- results['misc']['v4addrs'] = v4ips.split(',')
-
- # find out if we are behind nat
- intersection = results['misc']['v4addrs'] & results['ldap']['ipHostNumber']
- results['misc']['natted'] = intersection.empty?
+ nodeinfo['misc'] = {}
+ fqdn = lookupvar('::fqdn')
+ if fqdn and fqdn == host
+ v4ips = lookupvar('::v4ips')
+ if v4ips and v4ips.to_s != "" and v4ips.to_s != 'undefined'
+ nodeinfo['misc']['v4addrs'] = v4ips.split(',').uniq()
+
+ # find out if we are behind nat
+ intersection = nodeinfo['misc']['v4addrs'] & nodeinfo['ldap']['ipHostNumber']
+ nodeinfo['misc']['natted'] = intersection.empty?
+ else
+ nodeinfo['misc']['v4addrs'] = []
+ end
+
+ v6ips = lookupvar('::v6ips')
+ if v6ips and v6ips.to_s != "" and v6ips.to_s != 'undefined'
+ nodeinfo['misc']['v6addrs'] = v6ips.split(',').uniq()
+ else
+ nodeinfo['misc']['v6addrs'] = []
+ end
+
+ # find out if we have an ipv4 and/or an ipv6 address for our host in ldap.
+ nodeinfo['misc']['has_v4_ldap'] = nodeinfo['ldap']['ipHostNumber'].any? { |x| IPAddr.new(x).ipv4? }
+ nodeinfo['misc']['has_v6_ldap'] = nodeinfo['ldap']['ipHostNumber'].any? { |x| IPAddr.new(x).ipv6? }
+ nodeinfo['misc']['v4_ldap'] = nodeinfo['ldap']['ipHostNumber'].select { |x| IPAddr.new(x).ipv4? }
+ nodeinfo['misc']['v6_ldap'] = nodeinfo['ldap']['ipHostNumber'].select { |x| IPAddr.new(x).ipv6? }