From 5b1b831cc7cedebce64255c3c37b31bab85d16ca Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Wed, 18 Sep 2013 15:03:40 -0400 Subject: [PATCH 1/2] Make ssh's ControlPath configurable via ansible.cfg This shouldn't generally be needed unless you're working in an environment that uses rediculously long FQDNs; if the name is too long, you wind up hitting unix domain socket filepath limits enforced by ssh. --- lib/ansible/constants.py | 3 ++- lib/ansible/runner/connection_plugins/ssh.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index b9941c2e93a..c25df27abf9 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -47,7 +47,7 @@ def _get_config(p, section, key, env_var, default, boolean=True): return value if p is not None: try: - return p.get(section, key) + return p.get(section, key, raw=True) except: return default return default @@ -130,6 +130,7 @@ DEFAULT_LOG_PATH = shell_expand_path(get_config(p, DEFAULTS, 'log_ ANSIBLE_NOCOLOR = get_config(p, DEFAULTS, 'nocolor', 'ANSIBLE_NOCOLOR', None, boolean=True) ANSIBLE_NOCOWS = get_config(p, DEFAULTS, 'nocows', 'ANSIBLE_NOCOWS', None, boolean=True) 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") PARAMIKO_RECORD_HOST_KEYS = get_config(p, 'paramiko_connection', 'record_host_keys', 'ANSIBLE_PARAMIKO_RECORD_HOST_KEYS', True, boolean=True) ZEROMQ_PORT = int(get_config(p, 'fireball_connection', 'zeromq_port', 'ANSIBLE_ZEROMQ_PORT', 5099)) ACCELERATE_PORT = int(get_config(p, 'accelerate', 'accelerate_port', 'ACCELERATE_PORT', 5099)) diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index 02d47e0b1ec..649429c3c99 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -61,7 +61,7 @@ class Connection(object): else: self.common_args += ["-o", "ControlMaster=auto", "-o", "ControlPersist=60s", - "-o", "ControlPath=%s/ansible-ssh-%%h-%%p-%%r" % self.cp_dir] + "-o", "ControlPath=%s" % (C.ANSIBLE_SSH_CONTROL_PATH % dict(directory=self.cp_dir))] cp_in_use = False cp_path_set = False @@ -72,7 +72,7 @@ class Connection(object): cp_path_set = True if cp_in_use and not cp_path_set: - self.common_args += ["-o", "ControlPath=%s/ansible-ssh-%%h-%%p-%%r" % self.cp_dir] + self.common_args += ["-o", "ControlPath=%s" % (C.ANSIBLE_SSH_CONTROL_PATH % dict(directory=self.cp_dir))] if not C.HOST_KEY_CHECKING: self.common_args += ["-o", "StrictHostKeyChecking=no"] From 848a9667362539277a5953f5536b874f59c357d5 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 18 Sep 2013 21:10:32 -0500 Subject: [PATCH 2/2] Adding example section to ansible.cfg for the control_path setting --- examples/ansible.cfg | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/ansible.cfg b/examples/ansible.cfg index 1fb54b6213e..57e721a77be 100644 --- a/examples/ansible.cfg +++ b/examples/ansible.cfg @@ -108,6 +108,17 @@ filter_plugins = /usr/share/ansible_plugins/filter_plugins # paramiko on older platforms rather than removing it #ssh_args = -o ControlMaster=auto -o ControlPersist=60s +# The path to use for the ControlPath sockets. This defaults to +# "%(directory)s/ansible-ssh-%%h-%%p-%%r", however on some systems with +# very long hostnames or very long path names (caused by long user names or +# deeply nested home directories) this can exceed the character limit on +# file socket names (108 characters for most platforms). In that case, you +# may wish to shorten the string below. +# +# Example: +# control_path = %(directory)s/%%h-%%r +#control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r + # if True, make ansible use scp if the connection type is ssh # (default is sftp) #scp_if_ssh = True