Skip to content

Commit

Permalink
Bugfix: include FQDNs aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Maryniuk committed Jan 29, 2019
1 parent 743c8d8 commit 2910d46
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,14 +2187,13 @@ def fqdns():
grains = {}
fqdns = set()

addresses = salt.utils.network.ip_addrs(include_loopback=False,
interface_data=_INTERFACES)
addresses.extend(salt.utils.network.ip_addrs6(include_loopback=False,
interface_data=_INTERFACES))
addresses = salt.utils.network.ip_addrs(include_loopback=False)
addresses.extend(salt.utils.network.ip_addrs6(include_loopback=False))
err_message = 'Exception during resolving address: %s'
for ip in addresses:
try:
fqdns.add(socket.getfqdn(socket.gethostbyaddr(ip)[0]))
name, aliaslist, addresslist = socket.gethostbyaddr(ip)
fqdns.update([socket.getfqdn(name)] + [als for als in aliaslist if salt.utils.network.is_fqdn(als)])
except socket.herror as err:
if err.errno == 0:
# No FQDN for this IP address, so we don't need to know this all the time.
Expand All @@ -2204,8 +2203,7 @@ def fqdns():
except (socket.error, socket.gaierror, socket.timeout) as err:
log.error(err_message, err)

grains['fqdns'] = sorted(list(fqdns))
return grains
return {"fqdns": sorted(list(fqdns))}


def ip_fqdn():
Expand Down

0 comments on commit 2910d46

Please sign in to comment.