mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Allow --user for playbooks, no need for port setting as can specify in inventory file now.
This commit is contained in:
@@ -64,7 +64,8 @@ class PlayBook(object):
|
||||
verbose = False,
|
||||
callbacks = None,
|
||||
runner_callbacks = None,
|
||||
stats = None):
|
||||
stats = None,
|
||||
sudo = False):
|
||||
|
||||
if playbook is None or callbacks is None or runner_callbacks is None or stats is None:
|
||||
raise Exception('missing required arguments')
|
||||
@@ -83,6 +84,7 @@ class PlayBook(object):
|
||||
self.override_hosts = override_hosts
|
||||
self.extra_vars = extra_vars
|
||||
self.stats = stats
|
||||
self.sudo = sudo
|
||||
self.sudo_pass = sudo_pass
|
||||
|
||||
self.basedir = os.path.dirname(playbook)
|
||||
@@ -529,7 +531,7 @@ class PlayBook(object):
|
||||
handlers = pg.get('handlers', [])
|
||||
user = pg.get('user', self.remote_user)
|
||||
port = pg.get('port', self.remote_port)
|
||||
sudo = pg.get('sudo', False)
|
||||
sudo = pg.get('sudo', self.sudo)
|
||||
transport = pg.get('connection', self.transport)
|
||||
|
||||
self.callbacks.on_play_start(pattern)
|
||||
|
||||
@@ -279,7 +279,7 @@ class SortedOptParser(optparse.OptionParser):
|
||||
self.option_list.sort(key=methodcaller('get_opt_string'))
|
||||
return optparse.OptionParser.format_help(self, formatter=None)
|
||||
|
||||
def base_parser(constants=C, usage="", output_opts=False, port_opts=False, runas_opts=False, async_opts=False, connect_opts=False):
|
||||
def base_parser(constants=C, usage="", output_opts=False, runas_opts=False, async_opts=False, connect_opts=False):
|
||||
''' create an options parser for any ansible script '''
|
||||
|
||||
parser = SortedOptParser(usage)
|
||||
@@ -301,11 +301,6 @@ def base_parser(constants=C, usage="", output_opts=False, port_opts=False, runas
|
||||
dest='timeout',
|
||||
help="override the SSH timeout in seconds (default=%s)" % constants.DEFAULT_TIMEOUT)
|
||||
|
||||
if port_opts:
|
||||
parser.add_option('-p', '--port', default=constants.DEFAULT_REMOTE_PORT, type='int',
|
||||
dest='remote_port',
|
||||
help="override the remote ssh port (default=%s)" % constants.DEFAULT_REMOTE_PORT)
|
||||
|
||||
if output_opts:
|
||||
parser.add_option('-o', '--one-line', dest='one_line', action='store_true',
|
||||
help='condense output')
|
||||
|
||||
Reference in New Issue
Block a user