From 8c6b3baf6fad1d6e7f80b2a9da92e409fa16197a Mon Sep 17 00:00:00 2001 From: Craig Tracey Date: Thu, 23 Jan 2014 12:49:07 -0500 Subject: [PATCH] Make default ANSIBLE_REMOTE_PORT None The ansible remote port should be None, not 22. Having a default value of 22 means that '-o Port 22' will be appended to the ssh connection all of the time. This is incorrect as when one would like to use something like an ssh configuration file (-F) that sets the port to something other than 22. Part of this change requires that we check that, in get_config, the value is not None before trying to cast it into an integer or float. --- lib/ansible/constants.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 460ae740360..ec06c21b9b2 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -36,9 +36,9 @@ def get_config(p, section, key, env_var, default, boolean=False, integer=False, value = _get_config(p, section, key, env_var, default) if boolean: return mk_boolean(value) - if integer: + if value and integer: return int(value) - if floating: + if value and floating: return float(value) return value @@ -114,7 +114,7 @@ DEFAULT_ASK_PASS = get_config(p, DEFAULTS, 'ask_pass', 'ANSIBLE_ASK_PA DEFAULT_PRIVATE_KEY_FILE = shell_expand_path(get_config(p, DEFAULTS, 'private_key_file', 'ANSIBLE_PRIVATE_KEY_FILE', None)) DEFAULT_SUDO_USER = get_config(p, DEFAULTS, 'sudo_user', 'ANSIBLE_SUDO_USER', 'root') DEFAULT_ASK_SUDO_PASS = get_config(p, DEFAULTS, 'ask_sudo_pass', 'ANSIBLE_ASK_SUDO_PASS', False, boolean=True) -DEFAULT_REMOTE_PORT = get_config(p, DEFAULTS, 'remote_port', 'ANSIBLE_REMOTE_PORT', 22, integer=True) +DEFAULT_REMOTE_PORT = get_config(p, DEFAULTS, 'remote_port', 'ANSIBLE_REMOTE_PORT', None, integer=True) DEFAULT_TRANSPORT = get_config(p, DEFAULTS, 'transport', 'ANSIBLE_TRANSPORT', 'smart') DEFAULT_SCP_IF_SSH = get_config(p, 'ssh_connection', 'scp_if_ssh', 'ANSIBLE_SCP_IF_SSH', False, boolean=True) DEFAULT_MANAGED_STR = get_config(p, DEFAULTS, 'ansible_managed', None, 'Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}')