Add location on include_tasks fail inside include (#83876)

Adds the datastore details to the parser error when attempting to
include tasks that contain include_tasks without a filename set. This
change will now display the exact location of the include_tasks that
failed like any normal syntax error.
This commit is contained in:
Jordan Borean
2024-09-02 06:21:30 +10:00
committed by GitHub
parent 4346430003
commit 1503805b70
5 changed files with 23 additions and 1 deletions
@@ -0,0 +1,5 @@
- name: ping task
ansible.builtin.ping:
- name: invalid include_task definition
ansible.builtin.include_tasks:
@@ -148,3 +148,9 @@ test "$(grep out.txt -ce 'In imported role')" = 3
# https://github.com/ansible/ansible/issues/73657
ansible-playbook issue73657.yml 2>&1 | tee issue73657.out
test "$(grep -c 'SHOULD_NOT_EXECUTE' issue73657.out)" = 0
# https://github.com/ansible/ansible/issues/83874
ansible-playbook test_null_include_filename.yml 2>&1 | tee test_null_include_filename.out
test "$(grep -c 'ERROR! No file specified for ansible.builtin.include_tasks' test_null_include_filename.out)" = 1
test "$(grep -c 'The error appears to be in '\''.*/include_import/null_filename/tasks.yml'\'': line 4, column 3.*' test_null_include_filename.out)" = 1
test "$(grep -c '\- name: invalid include_task definition' test_null_include_filename.out)" = 1
@@ -0,0 +1,7 @@
- name: Test include failure with invalid included include_task
hosts: localhost
gather_facts: false
tasks:
- ansible.builtin.include_tasks:
file: null_filename/tasks.yml