mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ansible-playbook can load extra vars from a file, with "@" syntax
This commit is contained in:
parent
d1effecb2e
commit
c19c2c7295
1 changed files with 14 additions and 4 deletions
|
@ -94,10 +94,20 @@ def main(args):
|
|||
options.ask_sudo_pass = options.ask_sudo_pass or C.DEFAULT_ASK_SUDO_PASS
|
||||
( sshpass, sudopass ) = utils.ask_passwords(ask_pass=options.ask_pass, ask_sudo_pass=options.ask_sudo_pass)
|
||||
options.sudo_user = options.sudo_user or C.DEFAULT_SUDO_USER
|
||||
if options.extra_vars and options.extra_vars[0] in '[{':
|
||||
extra_vars = utils.json_loads(options.extra_vars)
|
||||
else:
|
||||
extra_vars = utils.parse_kv(options.extra_vars)
|
||||
|
||||
extra_vars = {}
|
||||
if options.extra_vars:
|
||||
if options.extra_vars.startswith("@"):
|
||||
# Argument is a JSON file
|
||||
with open(options.extra_vars[1:]) as fd:
|
||||
extra_vars = utils.json_loads(fd.read())
|
||||
elif options.extra_vars[0] in '[{':
|
||||
# Arguments as JSON
|
||||
extra_vars = utils.json_loads(options.extra_vars)
|
||||
else:
|
||||
# Arguments as Key-value
|
||||
extra_vars = utils.parse_kv(options.extra_vars)
|
||||
|
||||
only_tags = options.tags.split(",")
|
||||
skip_tags = options.skip_tags
|
||||
if options.skip_tags is not None:
|
||||
|
|
Loading…
Reference in a new issue