From a856e51c0739acaf77379a7d29114dc5274f68f3 Mon Sep 17 00:00:00 2001 From: polski-g Date: Wed, 16 Feb 2022 23:00:29 -0500 Subject: [PATCH] Fetch ssh_arg data from delegated host when task requires delegation --- ansible_mitogen/transport_config.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index 4babbde3..d7baf4f9 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -464,12 +464,17 @@ class PlayContextSpec(Spec): ) def ssh_args(self): + if 'ansible_delegated_vars' in self._task_vars and self._connection.delegate_to_hostname: + local_vars = self._task_vars['ansible_delegated_vars'][self._connection.delegate_to_hostname].get("vars", {}) + else: + local_vars = self._task_vars.get("vars", {}) + return [ mitogen.core.to_text(term) for s in ( - C.config.get_config_value("ssh_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {})), - C.config.get_config_value("ssh_common_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {})), - C.config.get_config_value("ssh_extra_args", plugin_type="connection", plugin_name="ssh", variables=self._task_vars.get("vars", {})) + C.config.get_config_value("ssh_args", plugin_type="connection", plugin_name="ssh", variables=local_vars), + C.config.get_config_value("ssh_common_args", plugin_type="connection", plugin_name="ssh", variables=local_vars), + C.config.get_config_value("ssh_extra_args", plugin_type="connection", plugin_name="ssh", variables=local_vars) ) for term in ansible.utils.shlex.shlex_split(s or '') ]