module Puppet::Parser::Functions
newfunction(:nodeinfo, :type => :rvalue) do |args|
module Puppet::Parser::Functions
newfunction(:nodeinfo, :type => :rvalue) do |args|
nodeinfo = function_yamlinfo([host, yamlfile])
nodeinfo['ldap'] = function_ldapinfo([host, '*'])
unless nodeinfo['ldap']['ipHostNumber']
raise Puppet::ParseError, "Host #{host} does not have ipHostNumber values in ldap"
end
nodeinfo['hoster'] = function_whohosts([nodeinfo['ldap']['ipHostNumber']])
nodeinfo = function_yamlinfo([host, yamlfile])
nodeinfo['ldap'] = function_ldapinfo([host, '*'])
unless nodeinfo['ldap']['ipHostNumber']
raise Puppet::ParseError, "Host #{host} does not have ipHostNumber values in ldap"
end
nodeinfo['hoster'] = function_whohosts([nodeinfo['ldap']['ipHostNumber']])
- nodeinfo['porterbox'] = (nodeinfo['ldap']['purpose'].respond_to?('include?') && nodeinfo['ldap']['purpose'].include?('porterbox'))
-
- if lookupvar('::mta') == 'exim4'
- unless nodeinfo['heavy_exim']
- nodeinfo['smarthost'] = 'mailout.debian.org'
- end
- end
+ nodeinfo['ganeti'] = (nodeinfo['ldap']['purpose'].respond_to?('include?') && nodeinfo['ldap']['purpose'].include?('ganeti/kvm host'))
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'] = {}
fqdn = lookupvar('::fqdn')
if fqdn and fqdn == host
v4ips = lookupvar('::v4ips')
if v4ips and v4ips.to_s != "" and v4ips.to_s != 'undefined'
# find out if we are behind nat
intersection = nodeinfo['misc']['v4addrs'] & nodeinfo['ldap']['ipHostNumber']
nodeinfo['misc']['natted'] = intersection.empty?
# find out if we are behind nat
intersection = nodeinfo['misc']['v4addrs'] & nodeinfo['ldap']['ipHostNumber']
nodeinfo['misc']['natted'] = intersection.empty?
+
+ # 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? }
allow_dns_q = call_function('hiera',['allow_dns_query'])
if ns.empty?
# no nameservers known for this hoster
allow_dns_q = call_function('hiera',['allow_dns_query'])
if ns.empty?
# no nameservers known for this hoster