diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 78936fd1..e11a6839 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -135,6 +135,15 @@ class Connection(ansible.plugins.connection.ConnectionBase): 'identity_file': self._play_context.private_key_file, 'ssh_path': self._play_context.ssh_executable, 'connect_timeout': self.connect_timeout, + 'ssh_args': [ + term + for s in ( + getattr(self._play_context, 'ssh_args', ''), + getattr(self._play_context, 'ssh_common_args', ''), + getattr(self._play_context, 'ssh_extra_args', '') + ) + for term in shlex.split(s or '') + ] }) ) diff --git a/docs/ansible.rst b/docs/ansible.rst index 6b672513..7715d78e 100644 --- a/docs/ansible.rst +++ b/docs/ansible.rst @@ -202,6 +202,7 @@ This list will grow as more missing pieces are discovered. * ansible_ssh_executable, ssh_executable * ansible_ssh_private_key_file * ansible_ssh_pass, ansible_password (default: assume passwordless) +* ssh_args, ssh_common_args, ssh_extra_args Sudo Variables diff --git a/examples/playbook/ansible.cfg b/examples/playbook/ansible.cfg index 350df1fb..367f2b02 100644 --- a/examples/playbook/ansible.cfg +++ b/examples/playbook/ansible.cfg @@ -1,8 +1,10 @@ [defaults] +sudo_flags = -HE inventory = hosts strategy_plugins = ../../ansible_mitogen/plugins/strategy library = modules retry_files_enabled = False [ssh_connection] +ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s pipelining = True diff --git a/mitogen/ssh.py b/mitogen/ssh.py index 9a04731e..c15417d0 100644 --- a/mitogen/ssh.py +++ b/mitogen/ssh.py @@ -60,7 +60,7 @@ class Stream(mitogen.parent.Stream): def construct(self, hostname, username=None, ssh_path=None, port=None, check_host_keys=True, password=None, identity_file=None, - compression_level=6, **kwargs): + compression_level=6, ssh_args=None, **kwargs): super(Stream, self).construct(**kwargs) self.hostname = hostname self.username = username @@ -71,6 +71,8 @@ class Stream(mitogen.parent.Stream): self.compression_level = compression_level if ssh_path: self.ssh_path = ssh_path + if ssh_args: + self.ssh_args = ssh_args def get_boot_command(self): bits = [self.ssh_path] @@ -94,6 +96,8 @@ class Stream(mitogen.parent.Stream): '-o', 'StrictHostKeyChecking no', '-o', 'UserKnownHostsFile /dev/null', ] + if self.ssh_args: + bits += self.ssh_args bits.append(self.hostname) base = super(Stream, self).get_boot_command() return bits + [commands.mkarg(s).strip() for s in base]