mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
add a -T option for setting ssh timeout in seconds
This commit is contained in:
parent
2773234c3f
commit
d15172abdc
2 changed files with 4 additions and 1 deletions
|
@ -59,6 +59,8 @@ class Cli(object):
|
||||||
help="try to print output on one line")
|
help="try to print output on one line")
|
||||||
parser.add_option('-t', '--tree', dest='tree', default=None,
|
parser.add_option('-t', '--tree', dest='tree', default=None,
|
||||||
help="if specified, a directory name to save output to, one file per host")
|
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()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -82,6 +84,7 @@ class Cli(object):
|
||||||
remote_user=options.remote_user,
|
remote_user=options.remote_user,
|
||||||
remote_pass=sshpass,
|
remote_pass=sshpass,
|
||||||
host_list=options.host_list,
|
host_list=options.host_list,
|
||||||
|
timeout=options.timeout,
|
||||||
forks=options.forks,
|
forks=options.forks,
|
||||||
pattern=options.pattern,
|
pattern=options.pattern,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
|
|
@ -117,7 +117,7 @@ class Runner(object):
|
||||||
try:
|
try:
|
||||||
# try paramiko
|
# try paramiko
|
||||||
ssh.connect(host, username=self.remote_user, allow_agent=True,
|
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 ]
|
return [ True, ssh ]
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
# it failed somehow, return the failure string
|
# it failed somehow, return the failure string
|
||||||
|
|
Loading…
Reference in a new issue