From d15172abdc52577e15af4a5190ac1b423c4f96c7 Mon Sep 17 00:00:00 2001 From: Christopher Johnston Date: Thu, 1 Mar 2012 16:54:17 -0800 Subject: [PATCH] add a -T option for setting ssh timeout in seconds --- bin/ansible | 3 +++ lib/ansible/runner.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/ansible b/bin/ansible index 909e62b40b0..82d99598e65 100755 --- a/bin/ansible +++ b/bin/ansible @@ -59,6 +59,8 @@ class Cli(object): help="try to print output on one line") parser.add_option('-t', '--tree', dest='tree', default=None, help="if specified, a directory name to save output to, one file per host") + parser.add_option('-T', '--timeout', default=C.DEFAULT_TIMEOUT, type='int', + dest='timeout', help="set the timeout in seconds for ssh") options, args = parser.parse_args() @@ -82,6 +84,7 @@ class Cli(object): remote_user=options.remote_user, remote_pass=sshpass, host_list=options.host_list, + timeout=options.timeout, forks=options.forks, pattern=options.pattern, verbose=True, diff --git a/lib/ansible/runner.py b/lib/ansible/runner.py index 8a343a37d68..e126494a85b 100755 --- a/lib/ansible/runner.py +++ b/lib/ansible/runner.py @@ -117,7 +117,7 @@ class Runner(object): try: # try paramiko ssh.connect(host, username=self.remote_user, allow_agent=True, - look_for_keys=True, password=self.remote_pass) + look_for_keys=True, password=self.remote_pass timeout=self.timeout) return [ True, ssh ] except Exception, e: # it failed somehow, return the failure string