mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make sudo and su command line arguments mutually exclusive
This commit is contained in:
parent
4088243deb
commit
c95be4ceaa
2 changed files with 15 additions and 0 deletions
|
@ -67,6 +67,14 @@ class Cli(object):
|
||||||
if len(args) == 0 or len(args) > 1:
|
if len(args) == 0 or len(args) > 1:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# su and sudo command line arguments need to be mutually exclusive
|
||||||
|
if (options.su or options.su_user or options.ask_su_pass) and \
|
||||||
|
(options.sudo or options.sudo_user or options.ask_sudo_pass):
|
||||||
|
parser.error("Sudo arguments ('--sudo', '--sudo-user', and '--ask-sudo-pass') "
|
||||||
|
"and su arguments ('-su', '--su-user', and '--ask-su-pass') are "
|
||||||
|
"mutually exclusive")
|
||||||
|
|
||||||
return (options, args)
|
return (options, args)
|
||||||
|
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
|
|
|
@ -83,6 +83,13 @@ def main(args):
|
||||||
parser.print_help(file=sys.stderr)
|
parser.print_help(file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
# su and sudo command line arguments need to be mutually exclusive
|
||||||
|
if (options.su or options.su_user or options.ask_su_pass) and \
|
||||||
|
(options.sudo or options.sudo_user or options.ask_sudo_pass):
|
||||||
|
parser.error("Sudo arguments ('--sudo', '--sudo-user', and '--ask-sudo-pass') "
|
||||||
|
"and su arguments ('-su', '--su-user', and '--ask-su-pass') are "
|
||||||
|
"mutually exclusive")
|
||||||
|
|
||||||
inventory = ansible.inventory.Inventory(options.inventory)
|
inventory = ansible.inventory.Inventory(options.inventory)
|
||||||
inventory.subset(options.subset)
|
inventory.subset(options.subset)
|
||||||
if len(inventory.list_hosts()) == 0:
|
if len(inventory.list_hosts()) == 0:
|
||||||
|
|
Loading…
Reference in a new issue