Pass obj=data to AnsibleParserError for context in IncludeRole. Fixes #31374 (#39805)

pull/39811/head
Matt Martz 7 years ago committed by GitHub
parent 1663b64e18
commit 5ec34f65d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -112,12 +112,12 @@ class IncludeRole(TaskInclude):
# name is needed, or use role as alias # name is needed, or use role as alias
ir._role_name = ir.args.get('name', ir.args.get('role')) ir._role_name = ir.args.get('name', ir.args.get('role'))
if ir._role_name is None: if ir._role_name is None:
raise AnsibleParserError("'name' is a required field for %s." % ir.action) raise AnsibleParserError("'name' is a required field for %s." % ir.action, obj=data)
# validate bad args, otherwise we silently ignore # validate bad args, otherwise we silently ignore
bad_opts = my_arg_names.difference(IncludeRole.VALID_ARGS) bad_opts = my_arg_names.difference(IncludeRole.VALID_ARGS)
if bad_opts: if bad_opts:
raise AnsibleParserError('Invalid options for %s: %s' % (ir.action, ','.join(list(bad_opts)))) raise AnsibleParserError('Invalid options for %s: %s' % (ir.action, ','.join(list(bad_opts))), obj=data)
# build options for role includes # build options for role includes
for key in my_arg_names.intersection(IncludeRole.FROM_ARGS): for key in my_arg_names.intersection(IncludeRole.FROM_ARGS):

Loading…
Cancel
Save