mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Look at 'ansible_host' for callbacks, not just 'ansible_ssh_host'.
This commit is contained in:
parent
26adcf5972
commit
2e39070ffd
@ -2564,20 +2564,22 @@ class JobTemplateCallback(GenericAPIView):
|
||||
# Next, try matching based on name or ansible_ssh_host variable.
|
||||
matches = set()
|
||||
for host in hosts:
|
||||
ansible_ssh_host = host.variables_dict.get('ansible_ssh_host', '')
|
||||
if ansible_ssh_host in remote_hosts:
|
||||
matches.add(host)
|
||||
if host.name != ansible_ssh_host and host.name in remote_hosts:
|
||||
matches.add(host)
|
||||
for host_var in ['ansible_ssh_host', 'ansible_host']:
|
||||
ansible_host = host.variables_dict.get(host_var, '')
|
||||
if ansible_host in remote_hosts:
|
||||
matches.add(host)
|
||||
if host.name != ansible_host and host.name in remote_hosts:
|
||||
matches.add(host)
|
||||
if len(matches) == 1:
|
||||
return matches
|
||||
|
||||
# Try to resolve forward addresses for each host to find matches.
|
||||
for host in hosts:
|
||||
hostnames = set([host.name])
|
||||
ansible_ssh_host = host.variables_dict.get('ansible_ssh_host', '')
|
||||
if ansible_ssh_host:
|
||||
hostnames.add(ansible_ssh_host)
|
||||
for host_var in ['ansible_ssh_host', 'ansible_host']:
|
||||
ansible_host = host.variables_dict.get(host_var, '')
|
||||
if ansible_host:
|
||||
hostnames.add(ansible_host)
|
||||
for hostname in hostnames:
|
||||
try:
|
||||
result = socket.getaddrinfo(hostname, None)
|
||||
|
Loading…
Reference in New Issue
Block a user