mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
Merge pull request #4626 from ryanpetrello/more-cli-doc-examples
cli: add support for loading JSON/YAML w/ the ansible-like @ syntax Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
45f9457abe
@ -44,17 +44,10 @@ the output of) a playbook from that repository:
|
|||||||
-f jq --filter '.id')
|
-f jq --filter '.id')
|
||||||
awx job_templates launch $TEMPLATE_ID --monitor
|
awx job_templates launch $TEMPLATE_ID --monitor
|
||||||
|
|
||||||
Importing an SSH Key
|
Updating a Job Template with Extra Vars
|
||||||
--------------------
|
|
||||||
|
|
||||||
DOCUMENT ME
|
|
||||||
|
|
||||||
Creating a Job Template with Extra Vars
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
DOCUMENT ME
|
.. code:: bash
|
||||||
|
|
||||||
Granting Membership to a Team or Organization
|
awx job_templates modify 1 --extra_vars "@vars.yml"
|
||||||
---------------------------------------------
|
awx job_templates modify 1 --extra_vars "@vars.json"
|
||||||
|
|
||||||
DOCUMENT ME
|
|
||||||
|
@ -80,6 +80,8 @@ class ResourceOptionsParser(object):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
def json_or_yaml(v):
|
def json_or_yaml(v):
|
||||||
|
if v.startswith('@'):
|
||||||
|
v = open(v[1:]).read()
|
||||||
try:
|
try:
|
||||||
return json.loads(v)
|
return json.loads(v)
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -124,6 +126,15 @@ class ResourceOptionsParser(object):
|
|||||||
if param['type'] == 'id' and not kwargs.get('help'):
|
if param['type'] == 'id' and not kwargs.get('help'):
|
||||||
kwargs['help'] = 'the ID of the associated {}'.format(k)
|
kwargs['help'] = 'the ID of the associated {}'.format(k)
|
||||||
|
|
||||||
|
if param['type'] == 'json' and method != 'list':
|
||||||
|
help_parts = []
|
||||||
|
if kwargs.get('help'):
|
||||||
|
help_parts.append(kwargs['help'])
|
||||||
|
else:
|
||||||
|
help_parts.append('a JSON or YAML string.')
|
||||||
|
help_parts.append('You can optionally specify a file path e.g., @path/to/file.yml')
|
||||||
|
kwargs['help'] = ' '.join(help_parts)
|
||||||
|
|
||||||
# SPECIAL CUSTOM LOGIC GOES HERE :'(
|
# SPECIAL CUSTOM LOGIC GOES HERE :'(
|
||||||
# There are certain requirements that aren't captured well by our
|
# There are certain requirements that aren't captured well by our
|
||||||
# HTTP OPTIONS due to $reasons
|
# HTTP OPTIONS due to $reasons
|
||||||
|
Loading…
Reference in New Issue
Block a user