forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle post_validate templating errors and fix tests (ansible#70240)
* Handle unexpected templating errors * Fixes ansible#70050 Fix up tests that weren't running and add tests for graceful templating error handling
- Loading branch information
Showing
5 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
- hosts: localhost | ||
gather_facts: no | ||
roles: | ||
- { role: templating_lookups } | ||
- { role: template_lookups } |
31 changes: 31 additions & 0 deletions
31
test/integration/targets/templating_lookups/template_lookups/tasks/errors.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
- name: Task that fails due to templating error for plugin option | ||
debug: msg="{{ 5 / 0 | int }}" | ||
ignore_errors: true | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result.failed | ||
- result.exception | ||
|
||
- name: Loop that fails due to templating error in first entry and ignores errors | ||
debug: msg="{{ 5 / item }}" | ||
ignore_errors: true | ||
register: result | ||
loop: [0, 0, 1] | ||
|
||
- debug: var=result | ||
|
||
- assert: | ||
that: | ||
- result.results[0].failed | ||
- result.results[0].exception | ||
- result.results[0].item == 0 | ||
|
||
- result.results[1].failed | ||
- result.results[1].exception | ||
- result.results[1].item == 0 | ||
|
||
- not result.results[2].failed | ||
- result.results[2].exception is undefined | ||
- result.results[2].item == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,3 +86,5 @@ | |
assert: | ||
that: | ||
- password1 != password2 | ||
|
||
- include_tasks: ./errors.yml |