mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add support for -c, --connection argument to specify connection type
Adds support to specify connection type to use. The option -c, --connection is added when connect_opts is set to True. connect_opts is added to make_parser() and base_parser_options().
This commit is contained in:
parent
896f8de446
commit
1391481523
1 changed files with 12 additions and 3 deletions
|
@ -273,14 +273,15 @@ def parse_kv(args):
|
|||
options[k]=v
|
||||
return options
|
||||
|
||||
def make_parser(add_options, constants=C, usage="", output_opts=False, runas_opts=False, async_opts=False):
|
||||
def make_parser(add_options, constants=C, usage="", output_opts=False, runas_opts=False, async_opts=False, connect_opts=False):
|
||||
''' create an options parser w/ common options for any ansible program '''
|
||||
|
||||
options = base_parser_options(
|
||||
constants=constants,
|
||||
output_opts=output_opts,
|
||||
runas_opts=runas_opts,
|
||||
async_opts=async_opts
|
||||
async_opts=async_opts,
|
||||
connect_opts=connect_opts
|
||||
)
|
||||
options.update(add_options)
|
||||
|
||||
|
@ -293,7 +294,7 @@ def make_parser(add_options, constants=C, usage="", output_opts=False, runas_opt
|
|||
parser.add_option(n, long, **data)
|
||||
return parser
|
||||
|
||||
def base_parser_options(constants=C, output_opts=False, runas_opts=False, async_opts=False):
|
||||
def base_parser_options(constants=C, output_opts=False, runas_opts=False, async_opts=False, connect_opts=False):
|
||||
''' creates common options for ansible programs '''
|
||||
|
||||
options = {
|
||||
|
@ -329,6 +330,14 @@ def base_parser_options(constants=C, output_opts=False, runas_opts=False, async_
|
|||
dest='remote_user', help='connect as this user'),
|
||||
})
|
||||
|
||||
if connect_opts:
|
||||
options.update({
|
||||
'-c' : dict(long='--connection', dest='connection',
|
||||
choices=C.DEFAULT_TRANSPORT_OPTS,
|
||||
default=C.DEFAULT_TRANSPORT,
|
||||
help="connection type to use")
|
||||
})
|
||||
|
||||
if async_opts:
|
||||
options.update({
|
||||
'-P' : dict(long='--poll', default=constants.DEFAULT_POLL_INTERVAL, type='int',
|
||||
|
|
Loading…
Reference in a new issue