* include_tasks: fix traceback if no file specified (#54044)
(cherry picked from commit c5609c51bf
)
* fix typo
This commit is contained in:
parent
6e4c344a6b
commit
ae5e6b5aef
3 changed files with 13 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- include_tasks - Fixed an unexpected exception if no file was given to include.
|
|
@ -67,7 +67,7 @@ class TaskInclude(Task):
|
||||||
raise AnsibleParserError('Invalid options for %s: %s' % (task.action, ','.join(list(bad_opts))), obj=data)
|
raise AnsibleParserError('Invalid options for %s: %s' % (task.action, ','.join(list(bad_opts))), obj=data)
|
||||||
|
|
||||||
if not task.args.get('_raw_params'):
|
if not task.args.get('_raw_params'):
|
||||||
task.args['_raw_params'] = task.args.pop('file')
|
task.args['_raw_params'] = task.args.pop('file', None)
|
||||||
|
|
||||||
apply_attrs = task.args.get('apply', {})
|
apply_attrs = task.args.get('apply', {})
|
||||||
if apply_attrs and task.action != 'include_tasks':
|
if apply_attrs and task.action != 'include_tasks':
|
||||||
|
|
|
@ -42,3 +42,13 @@
|
||||||
|
|
||||||
- name: include_tasks + action
|
- name: include_tasks + action
|
||||||
action: include_tasks tasks1.yml
|
action: include_tasks tasks1.yml
|
||||||
|
|
||||||
|
- name: test fail as expected without file
|
||||||
|
include_tasks:
|
||||||
|
ignore_errors: yes
|
||||||
|
register: res
|
||||||
|
|
||||||
|
- name: verify fail as expected without file
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- res.msg == 'No include file was specified to the include'
|
||||||
|
|
Loading…
Reference in a new issue