Fixing some delegate_to bugs
* Moving connection creation until after the task is post_validated, to make sure all fields are properly templated (#11230) * Fixing problems related to the connection method and remote address lookup on the delegated-to host Fixes #11230
This commit is contained in:
parent
3ba67dd2d0
commit
a9712bb0fb
2 changed files with 8 additions and 7 deletions
|
@ -217,12 +217,6 @@ class TaskExecutor:
|
||||||
# variables to the variable dictionary
|
# variables to the variable dictionary
|
||||||
self._connection_info.update_vars(variables)
|
self._connection_info.update_vars(variables)
|
||||||
|
|
||||||
# get the connection and the handler for this execution
|
|
||||||
self._connection = self._get_connection(variables)
|
|
||||||
self._connection.set_host_overrides(host=self._host)
|
|
||||||
|
|
||||||
self._handler = self._get_action_handler(connection=self._connection, templar=templar)
|
|
||||||
|
|
||||||
# Evaluate the conditional (if any) for this task, which we do before running
|
# Evaluate the conditional (if any) for this task, which we do before running
|
||||||
# the final task post-validation. We do this before the post validation due to
|
# the final task post-validation. We do this before the post validation due to
|
||||||
# the fact that the conditional may specify that the task be skipped due to a
|
# the fact that the conditional may specify that the task be skipped due to a
|
||||||
|
@ -251,6 +245,12 @@ class TaskExecutor:
|
||||||
del include_variables['_raw_params']
|
del include_variables['_raw_params']
|
||||||
return dict(changed=True, include=include_file, include_variables=include_variables)
|
return dict(changed=True, include=include_file, include_variables=include_variables)
|
||||||
|
|
||||||
|
# get the connection and the handler for this execution
|
||||||
|
self._connection = self._get_connection(variables)
|
||||||
|
self._connection.set_host_overrides(host=self._host)
|
||||||
|
|
||||||
|
self._handler = self._get_action_handler(connection=self._connection, templar=templar)
|
||||||
|
|
||||||
# And filter out any fields which were set to default(omit), and got the omit token value
|
# And filter out any fields which were set to default(omit), and got the omit token value
|
||||||
omit_token = variables.get('omit')
|
omit_token = variables.get('omit')
|
||||||
if omit_token is not None:
|
if omit_token is not None:
|
||||||
|
@ -460,7 +460,7 @@ class TaskExecutor:
|
||||||
self._connection_info.port = this_info.get('ansible_ssh_port', self._connection_info.port)
|
self._connection_info.port = this_info.get('ansible_ssh_port', self._connection_info.port)
|
||||||
self._connection_info.password = this_info.get('ansible_ssh_pass', self._connection_info.password)
|
self._connection_info.password = this_info.get('ansible_ssh_pass', self._connection_info.password)
|
||||||
self._connection_info.private_key_file = this_info.get('ansible_ssh_private_key_file', self._connection_info.private_key_file)
|
self._connection_info.private_key_file = this_info.get('ansible_ssh_private_key_file', self._connection_info.private_key_file)
|
||||||
self._connection_info.connection = this_info.get('ansible_connection', self._connection_info.connection)
|
self._connection_info.connection = this_info.get('ansible_connection', C.DEFAULT_TRANSPORT)
|
||||||
self._connection_info.become_pass = this_info.get('ansible_sudo_pass', self._connection_info.become_pass)
|
self._connection_info.become_pass = this_info.get('ansible_sudo_pass', self._connection_info.become_pass)
|
||||||
|
|
||||||
if self._connection_info.remote_addr in ('127.0.0.1', 'localhost'):
|
if self._connection_info.remote_addr in ('127.0.0.1', 'localhost'):
|
||||||
|
|
|
@ -123,6 +123,7 @@ class Host:
|
||||||
results = combine_vars(results, self.vars)
|
results = combine_vars(results, self.vars)
|
||||||
results['inventory_hostname'] = self.name
|
results['inventory_hostname'] = self.name
|
||||||
results['inventory_hostname_short'] = self.name.split('.')[0]
|
results['inventory_hostname_short'] = self.name.split('.')[0]
|
||||||
|
results['ansible_ssh_host'] = self.ipv4_address
|
||||||
results['group_names'] = sorted([ g.name for g in groups if g.name != 'all'])
|
results['group_names'] = sorted([ g.name for g in groups if g.name != 'all'])
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue