ansible: basic support for ssh_args

pull/107/head
David Wilson 7 years ago
parent 8f399083f5
commit a39ab8fa54

@ -135,6 +135,15 @@ class Connection(ansible.plugins.connection.ConnectionBase):
'identity_file': self._play_context.private_key_file, 'identity_file': self._play_context.private_key_file,
'ssh_path': self._play_context.ssh_executable, 'ssh_path': self._play_context.ssh_executable,
'connect_timeout': self.connect_timeout, '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 '')
]
}) })
) )

@ -202,6 +202,7 @@ This list will grow as more missing pieces are discovered.
* ansible_ssh_executable, ssh_executable * ansible_ssh_executable, ssh_executable
* ansible_ssh_private_key_file * ansible_ssh_private_key_file
* ansible_ssh_pass, ansible_password (default: assume passwordless) * ansible_ssh_pass, ansible_password (default: assume passwordless)
* ssh_args, ssh_common_args, ssh_extra_args
Sudo Variables Sudo Variables

@ -1,8 +1,10 @@
[defaults] [defaults]
sudo_flags = -HE
inventory = hosts inventory = hosts
strategy_plugins = ../../ansible_mitogen/plugins/strategy strategy_plugins = ../../ansible_mitogen/plugins/strategy
library = modules library = modules
retry_files_enabled = False retry_files_enabled = False
[ssh_connection] [ssh_connection]
ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s
pipelining = True pipelining = True

@ -60,7 +60,7 @@ class Stream(mitogen.parent.Stream):
def construct(self, hostname, username=None, ssh_path=None, port=None, def construct(self, hostname, username=None, ssh_path=None, port=None,
check_host_keys=True, password=None, identity_file=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) super(Stream, self).construct(**kwargs)
self.hostname = hostname self.hostname = hostname
self.username = username self.username = username
@ -71,6 +71,8 @@ class Stream(mitogen.parent.Stream):
self.compression_level = compression_level self.compression_level = compression_level
if ssh_path: if ssh_path:
self.ssh_path = ssh_path self.ssh_path = ssh_path
if ssh_args:
self.ssh_args = ssh_args
def get_boot_command(self): def get_boot_command(self):
bits = [self.ssh_path] bits = [self.ssh_path]
@ -94,6 +96,8 @@ class Stream(mitogen.parent.Stream):
'-o', 'StrictHostKeyChecking no', '-o', 'StrictHostKeyChecking no',
'-o', 'UserKnownHostsFile /dev/null', '-o', 'UserKnownHostsFile /dev/null',
] ]
if self.ssh_args:
bits += self.ssh_args
bits.append(self.hostname) bits.append(self.hostname)
base = super(Stream, self).get_boot_command() base = super(Stream, self).get_boot_command()
return bits + [commands.mkarg(s).strip() for s in base] return bits + [commands.mkarg(s).strip() for s in base]

Loading…
Cancel
Save