diff options
author | Sloane Hertel <shertel@redhat.com> | 2020-06-30 09:31:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-30 09:31:58 -0400 |
commit | 30e70f4b6356e692c7ade3dd95f2e55d07f3e8f5 (patch) | |
tree | 8382a915c728296a1f4253c5094d260afd5c8412 /test | |
parent | cc2cee6980dc53378b16d42c7988524c5e1be83b (diff) | |
download | ansible-30e70f4b6356e692c7ade3dd95f2e55d07f3e8f5.tar.gz |
Handle post_validate templating errors and fix tests (#70240)
* Handle unexpected templating errors
* Fixes #70050
Fix up tests that weren't running and add tests for graceful templating error handling
Diffstat (limited to 'test')
4 files changed, 35 insertions, 2 deletions
diff --git a/test/integration/targets/templating_lookups/runme.sh b/test/integration/targets/templating_lookups/runme.sh index e681070d77..e958bcfb64 100755 --- a/test/integration/targets/templating_lookups/runme.sh +++ b/test/integration/targets/templating_lookups/runme.sh @@ -2,7 +2,7 @@ set -eux -ANSIBLE_ROLES_PATH=../ UNICODE_VAR=café ansible-playbook runme.yml "$@" +ANSIBLE_ROLES_PATH=./ UNICODE_VAR=café ansible-playbook runme.yml "$@" ansible-playbook template_lookup_vaulted/playbook.yml --vault-password-file template_lookup_vaulted/test_vault_pass "$@" diff --git a/test/integration/targets/templating_lookups/runme.yml b/test/integration/targets/templating_lookups/runme.yml index 85328d2e98..a27337bb21 100644 --- a/test/integration/targets/templating_lookups/runme.yml +++ b/test/integration/targets/templating_lookups/runme.yml @@ -1,4 +1,4 @@ - hosts: localhost gather_facts: no roles: - - { role: templating_lookups } + - { role: template_lookups } diff --git a/test/integration/targets/templating_lookups/template_lookups/tasks/errors.yml b/test/integration/targets/templating_lookups/template_lookups/tasks/errors.yml new file mode 100644 index 0000000000..da57631a8d --- /dev/null +++ b/test/integration/targets/templating_lookups/template_lookups/tasks/errors.yml @@ -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 diff --git a/test/integration/targets/templating_lookups/template_lookups/tasks/main.yml b/test/integration/targets/templating_lookups/template_lookups/tasks/main.yml index cfeea2d56c..f240a2340d 100644 --- a/test/integration/targets/templating_lookups/template_lookups/tasks/main.yml +++ b/test/integration/targets/templating_lookups/template_lookups/tasks/main.yml @@ -86,3 +86,5 @@ assert: that: - password1 != password2 + +- include_tasks: ./errors.yml |