Merge pull request #40934 from gtmanfred/ipv6

Only display IPvX warning if role is master
This commit is contained in:
Mike Place 2017-04-28 05:53:50 -06:00 committed by GitHub
commit d5e0b8b655

View File

@ -1678,10 +1678,14 @@ def ip_fqdn():
ret = {}
ret['ipv4'] = salt.utils.network.ip_addrs(include_loopback=True)
ret['ipv6'] = salt.utils.network.ip_addrs6(include_loopback=True)
_fqdn = hostname()['fqdn']
for socket_type, ipv_num in ((socket.AF_INET, '4'), (socket.AF_INET6, '6')):
sockets = [(socket.AF_INET, '4')]
if __opts__.get('ipv6', True):
ret['ipv6'] = salt.utils.network.ip_addrs6(include_loopback=True)
sockets.append((socket.AF_INET6, '6'))
for socket_type, ipv_num in sockets:
key = 'fqdn_ip' + ipv_num
if not ret['ipv' + ipv_num]:
ret[key] = []
@ -1690,8 +1694,9 @@ def ip_fqdn():
info = socket.getaddrinfo(_fqdn, None, socket_type)
ret[key] = list(set(item[4][0] for item in info))
except socket.error:
log.warning('Unable to find IPv{0} record for "{1}" causing a 10 second timeout when rendering grains. '
'Set the dns or /etc/hosts for IPv{0} to clear this.'.format(ipv_num, _fqdn))
if __opts__['__role'] == 'master':
log.warning('Unable to find IPv{0} record for "{1}" causing a 10 second timeout when rendering grains. '
'Set the dns or /etc/hosts for IPv{0} to clear this.'.format(ipv_num, _fqdn))
ret[key] = []
return ret
@ -1758,7 +1763,7 @@ def ip6_interfaces():
# Provides:
# ip_interfaces
if salt.utils.is_proxy():
if salt.utils.is_proxy() or not __opts__.get('ipv6', True):
return {}
ret = {}
@ -1802,8 +1807,10 @@ def dns():
return {}
resolv = salt.utils.dns.parse_resolv()
for key in ('nameservers', 'ip4_nameservers', 'ip6_nameservers',
'sortlist'):
keys = ['nameservers', 'ip4_nameservers', 'sortlist']
if __opts__.get('ipv6', True):
keys.append('ip6_nameservers')
for key in keys:
if key in resolv:
resolv[key] = [str(i) for i in resolv[key]]