From 06dcb4ad7a252315ba6dc38b3d46e82ba5ea2c40 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 1 May 2023 10:20:08 -0400 Subject: =?UTF-8?q?Don't=20include=20a=20default=20for=20cli=20as=20it=20o?= =?UTF-8?q?verrides=20config=20with=20lesser=20pr=E2=80=A6=20(#80650)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Don't include a default for CLI as it overrides config with lesser precedence connection plugins should already use the same config entries (and more) than DEFAULT_TIMEOUT. --- changelogs/fragments/timeout_config_fix.yml | 5 +++++ lib/ansible/cli/arguments/option_helpers.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/timeout_config_fix.yml diff --git a/changelogs/fragments/timeout_config_fix.yml b/changelogs/fragments/timeout_config_fix.yml new file mode 100644 index 0000000000..5cebe81bf6 --- /dev/null +++ b/changelogs/fragments/timeout_config_fix.yml @@ -0,0 +1,5 @@ +bugfixes: + - connection timeouts defined in ansible.cfg will now be properly used, the --timeout cli option was obscuring them by always being set. +breaking_changes: + - Any plugin using the config system and the `cli` entry to use the `timeout` from the command line, will see the value change if the use had configured it in any of the lower precedence methods. + If relying on this behaviour to consume the global/generic timeout from the DEFAULT_TIMEOUT constant, please consult the documentation on plugin configuration to add the overlaping entries. diff --git a/lib/ansible/cli/arguments/option_helpers.py b/lib/ansible/cli/arguments/option_helpers.py index a3efb1e268..e3f661111f 100644 --- a/lib/ansible/cli/arguments/option_helpers.py +++ b/lib/ansible/cli/arguments/option_helpers.py @@ -250,8 +250,8 @@ def add_connect_options(parser): help='connect as this user (default=%s)' % C.DEFAULT_REMOTE_USER) connect_group.add_argument('-c', '--connection', dest='connection', default=C.DEFAULT_TRANSPORT, help="connection type to use (default=%s)" % C.DEFAULT_TRANSPORT) - connect_group.add_argument('-T', '--timeout', default=C.DEFAULT_TIMEOUT, type=int, dest='timeout', - help="override the connection timeout in seconds (default=%s)" % C.DEFAULT_TIMEOUT) + connect_group.add_argument('-T', '--timeout', default=None, type=int, dest='timeout', + help="override the connection timeout in seconds (default depends on connection)") # ssh only connect_group.add_argument('--ssh-common-args', default=None, dest='ssh_common_args', -- cgit v1.2.1