mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 05:15:02 -02:30
Fail the task if extra_vars is set on launch but ask_extra_vars is not set to True on the Job Template
This commit is contained in:
@@ -122,9 +122,17 @@ def update_fields(module, p):
|
|||||||
params = p.copy()
|
params = p.copy()
|
||||||
|
|
||||||
params_update = {}
|
params_update = {}
|
||||||
|
job_template = params.get('job_template')
|
||||||
extra_vars = params.get('extra_vars')
|
extra_vars = params.get('extra_vars')
|
||||||
|
try:
|
||||||
|
ask_extra_vars = tower_cli.get_resource('job_template').get(name=job_template)['ask_variables_on_launch']
|
||||||
|
except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
|
||||||
|
module.fail_json(msg='Failed to get ask_extra_vars parameter, job template not found: {0}'.format(excinfo), changed=False)
|
||||||
|
|
||||||
if extra_vars:
|
if extra_vars and ask_extra_vars is not True:
|
||||||
|
module.fail_json(msg="extra_vars is set on launch but the Job Template does not have ask_extra_vars set to True.")
|
||||||
|
|
||||||
|
elif extra_vars:
|
||||||
params_update['extra_vars'] = [json.dumps(extra_vars)]
|
params_update['extra_vars'] = [json.dumps(extra_vars)]
|
||||||
|
|
||||||
params.update(params_update)
|
params.update(params_update)
|
||||||
|
|||||||
Reference in New Issue
Block a user