diff --git a/examples/ansible.cfg b/examples/ansible.cfg index a9306a61193..f1a24605f8f 100644 --- a/examples/ansible.cfg +++ b/examples/ansible.cfg @@ -131,6 +131,16 @@ filter_plugins = /usr/share/ansible_plugins/filter_plugins # control_path = %(directory)s/%%h-%%r #control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r +# Enabling pipelining reduces the number of SSH operations required to +# execute a module on the remote server. This can result in a significant +# performance improvement when enabled, however when using "sudo:" you must +# first disable 'requiretty' in /etc/sudoers +# +# By default, this option is disabled to preserve compatibility with +# sudoers configurations that have requiretty (the default on many distros). +# +#pipelining = False + # if True, make ansible use scp if the connection type is ssh # (default is sftp) #scp_if_ssh = True diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 386291e23c9..bf9084ef992 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -146,6 +146,7 @@ DEPRECATION_WARNINGS = get_config(p, DEFAULTS, 'deprecation_warnings', # CONNECTION RELATED ANSIBLE_SSH_ARGS = get_config(p, 'ssh_connection', 'ssh_args', 'ANSIBLE_SSH_ARGS', None) ANSIBLE_SSH_CONTROL_PATH = get_config(p, 'ssh_connection', 'control_path', 'ANSIBLE_SSH_CONTROL_PATH', "%(directory)s/ansible-ssh-%%h-%%p-%%r") +ANSIBLE_SSH_PIPELINING = get_config(p, 'ssh_connection', 'pipelining', 'ANSIBLE_SSH_PIPELINING', False, boolean=False) PARAMIKO_RECORD_HOST_KEYS = get_config(p, 'paramiko_connection', 'record_host_keys', 'ANSIBLE_PARAMIKO_RECORD_HOST_KEYS', True, boolean=True) ZEROMQ_PORT = get_config(p, 'fireball_connection', 'zeromq_port', 'ANSIBLE_ZEROMQ_PORT', 5099, integer=True) ACCELERATE_PORT = get_config(p, 'accelerate', 'accelerate_port', 'ACCELERATE_PORT', 5099, integer=True) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 7fa798428bd..ef8d4aac211 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -310,6 +310,7 @@ class Runner(object): if (module_style != 'new' or async_jid is not None or not conn.has_pipelining + or not C.ANSIBLE_SSH_PIPELINING or C.DEFAULT_KEEP_REMOTE_FILES): self._transfer_str(conn, tmp, module_name, module_data) @@ -353,7 +354,7 @@ class Runner(object): cmd = " ".join([str(x) for x in [remote_module_path, async_jid, async_limit, async_module, argsfile]]) else: if async_jid is None: - if conn.has_pipelining and not C.DEFAULT_KEEP_REMOTE_FILES: + if conn.has_pipelining and C.ANSIBLE_SSH_PIPELINING and not C.DEFAULT_KEEP_REMOTE_FILES: in_data = module_data else: cmd = "%s" % (remote_module_path) @@ -797,7 +798,7 @@ class Runner(object): if tmp.find("tmp") != -1: # tmp has already been created return False - if not conn.has_pipelining or C.DEFAULT_KEEP_REMOTE_FILES: + if not conn.has_pipelining or not C.ANSIBLE_SSH_PIPELINING or C.DEFAULT_KEEP_REMOTE_FILES: # tmp is necessary to store the module source code # or we want to keep the files on the target system return True