diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index ae840a4de6..287c7431b4 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -217,12 +217,6 @@ class TaskExecutor: # variables to the variable dictionary 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 # 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 @@ -251,6 +245,12 @@ class TaskExecutor: del include_variables['_raw_params'] 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 omit_token = variables.get('omit') 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.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.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) if self._connection_info.remote_addr in ('127.0.0.1', 'localhost'): diff --git a/lib/ansible/inventory/host.py b/lib/ansible/inventory/host.py index ffdbc6f9c3..c14a6f4a25 100644 --- a/lib/ansible/inventory/host.py +++ b/lib/ansible/inventory/host.py @@ -123,6 +123,7 @@ class Host: results = combine_vars(results, self.vars) results['inventory_hostname'] = self.name 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']) return results