mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-24 13:04:00 -07:00
go back to using a normal optparser to add options instead of the dict
interface. add very small subclass of OptionParser to sort the options so mdehaan is happy
This commit is contained in:
parent
6749903e57
commit
8ae71cc7b1
3 changed files with 49 additions and 82 deletions
23
bin/ansible
23
bin/ansible
|
|
@ -47,23 +47,12 @@ class Cli(object):
|
|||
def parse(self):
|
||||
''' create an options parser for bin/ansible '''
|
||||
|
||||
|
||||
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,
|
||||
|
||||
)
|
||||
|
||||
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, args = parser.parse_args()
|
||||
self.callbacks.options = options
|
||||
|
|
|
|||
|
|
@ -32,14 +32,13 @@ def main(args):
|
|||
''' run ansible-playbook operations '''
|
||||
|
||||
# create parser for CLI options
|
||||
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)
|
||||
usage = "ans-playbook playbook.yml"
|
||||
parser = utils.base_parser(constants=C, usage=usage)
|
||||
parser.add_option('-e', '--extra-vars', dest='extra_vars',
|
||||
help='arguments to pass to the inventory script')
|
||||
parser.add_option('-O', '--override-hosts', dest="override_hosts", default=None,
|
||||
help="run playbook against these hosts regardless of inventory settings")
|
||||
|
||||
options, args = parser.parse_args(args)
|
||||
|
||||
if len(args) == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue