mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Modification on top of skvidal's common options patch to keep options to command line tools sorted.
This commit is contained in:
23
bin/ansible
23
bin/ansible
@@ -47,12 +47,23 @@ class Cli(object):
|
||||
def parse(self):
|
||||
''' create an options parser for bin/ansible '''
|
||||
|
||||
parser = utils.base_parser(constants=C, runas_opts=True, async_opts=True,
|
||||
output_opts=True, usage='ansible <host-pattern> [options]')
|
||||
parser.add_option('-a', '--args', dest='module_args',
|
||||
help="module arguments", default=C.DEFAULT_MODULE_ARGS)
|
||||
parser.add_option('-m', '--module-name', dest='module_name',
|
||||
help="module name to execute", default=C.DEFAULT_MODULE_NAME)
|
||||
|
||||
options = {
|
||||
'-a' : dict(long='--args', dest='module_args',
|
||||
help="module arguments", default=C.DEFAULT_MODULE_ARGS),
|
||||
'-m' : dict(long='--module-name', dest='module_name',
|
||||
help="module name to execute", default=C.DEFAULT_MODULE_NAME)
|
||||
}
|
||||
|
||||
parser = utils.make_parser(
|
||||
options,
|
||||
usage='ansible <host-pattern> [options]',
|
||||
runas_opts=True,
|
||||
async_opts=True,
|
||||
output_opts=True,
|
||||
|
||||
)
|
||||
|
||||
|
||||
options, args = parser.parse_args()
|
||||
self.callbacks.options = options
|
||||
|
||||
@@ -32,13 +32,14 @@ def main(args):
|
||||
''' run ansible-playbook operations '''
|
||||
|
||||
# create parser for CLI options
|
||||
usage = "ans-playbook playbook.yml"
|
||||
parser = utils.base_parser(constants=C, usage=usage)
|
||||
parser.add_option('-e', '--extra-vars', dest='extra_vars',
|
||||
help='pass in extra key=value variables from outside the playbook')
|
||||
parser.add_option('-O', '--override-hosts', dest="override_hosts", default=None,
|
||||
help="run playbook against only hosts, ignorning the inventory file")
|
||||
|
||||
usage = "ansible-playbook playbook.yml [options]"
|
||||
options = {
|
||||
'-e' : dict(long='--extra-vars', dest='extra_vars',
|
||||
help='pass in extra key=value variables from outside the playbook'),
|
||||
'-O' : dict(long='--override-hosts', dest="override_hosts", default=None,
|
||||
help="run playbook against only hosts, ignorning the inventory file")
|
||||
}
|
||||
parser = utils.make_parser(options, constants=C, usage=usage)
|
||||
options, args = parser.parse_args(args)
|
||||
|
||||
if len(args) == 0:
|
||||
@@ -60,20 +61,13 @@ def main(args):
|
||||
runner_cb = callbacks.PlaybookRunnerCallbacks(stats)
|
||||
|
||||
pb = ansible.playbook.PlayBook(
|
||||
playbook=playbook,
|
||||
host_list=options.inventory,
|
||||
playbook=playbook,module_path=options.module_path,
|
||||
host_list=options.inventory, override_hosts=override_hosts,
|
||||
extra_vars=options.extra_vars,
|
||||
module_path=options.module_path,
|
||||
forks=options.forks,
|
||||
debug=options.debug,
|
||||
verbose=True,
|
||||
remote_pass=sshpass,
|
||||
remote_port=options.remote_port,
|
||||
callbacks=playbook_cb,
|
||||
runner_callbacks=runner_cb,
|
||||
stats=stats,
|
||||
forks=options.forks, debug=options.debug, verbose=True,
|
||||
remote_pass=sshpass, remote_port=options.remote_port,
|
||||
callbacks=playbook_cb, runner_callbacks=runner_cb, stats=stats,
|
||||
timeout=options.timeout,
|
||||
override_hosts=override_hosts,
|
||||
)
|
||||
try:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user