mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix ansible_ssh_host after 339c05bb
This commit is contained in:
parent
6ce844167a
commit
37b91c7b81
1 changed files with 9 additions and 16 deletions
|
@ -382,7 +382,12 @@ class Runner(object):
|
||||||
|
|
||||||
conn = None
|
conn = None
|
||||||
actual_host = host
|
actual_host = host
|
||||||
|
actual_port = port
|
||||||
try:
|
try:
|
||||||
|
alternative_host = inject.get('ansible_ssh_host', None)
|
||||||
|
if alternative_host is not None:
|
||||||
|
actual_host = alternative_host
|
||||||
|
|
||||||
delegate_to = inject.get('delegate_to', None)
|
delegate_to = inject.get('delegate_to', None)
|
||||||
|
|
||||||
# the delegated host may have different SSH port configured, etc
|
# the delegated host may have different SSH port configured, etc
|
||||||
|
@ -390,23 +395,11 @@ class Runner(object):
|
||||||
|
|
||||||
if delegate_to is not None:
|
if delegate_to is not None:
|
||||||
delegate_to = utils.template(self.basedir, delegate_to, inject)
|
delegate_to = utils.template(self.basedir, delegate_to, inject)
|
||||||
delegate_vars = {}
|
actual_host = inject['hostvars'][delegate_to].get('ansible_ssh_host', delegate_to)
|
||||||
try:
|
actual_port = inject['hostvars'][delegate_to].get('ansible_ssh_port', port)
|
||||||
delegate_vars = inject['hostvars'][delegate_to]
|
|
||||||
for (k,v) in delegate_vars.iteritems():
|
|
||||||
if k.startswith('ansible_ssh_'):
|
|
||||||
inject[k] = v
|
|
||||||
except errors.AnsibleError:
|
|
||||||
# host not listed in inventory, it's ok
|
|
||||||
pass
|
|
||||||
|
|
||||||
# the host record may just be an alias in case of tunnels
|
|
||||||
alternative_host = inject.get('ansible_ssh_host', None)
|
|
||||||
if delegate_to is not None and not alternative_host:
|
|
||||||
actual_host = delegate_to
|
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
conn = self.connector.connect(actual_host, port)
|
conn = self.connector.connect(actual_host, actual_port)
|
||||||
|
|
||||||
if delegate_to is not None or alternative_host is not None:
|
if delegate_to is not None or alternative_host is not None:
|
||||||
conn._delegate_for = host
|
conn._delegate_for = host
|
||||||
|
|
Loading…
Reference in a new issue