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.
Prevent vars premature templating (ansible#56117)
Avoid premature vars templating * added tests * avoid 'is template' warning in vars, since we want them for latter templating
- Loading branch information
Showing
6 changed files
with
38 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- we don't really need to template vars on definition as we do this on demand in templating. |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
shippable/posix/group3 |
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,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
# this should succeed since we override the undefined variable | ||
ansible-playbook undefined.yml -i inventory -v "$@" -e '{"mytest": False}' | ||
|
||
# this should still work, just show that var is undefined in debug | ||
ansible-playbook undefined.yml -i inventory -v "$@" | ||
|
||
# this should work since we dont use the variable | ||
ansible-playbook undall.yml -i inventory -v "$@" |
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,6 @@ | ||
- hosts: localhost | ||
gather_facts: false | ||
tasks: | ||
- debug: | ||
vars: | ||
mytest: '{{ und }}' |
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,13 @@ | ||
- hosts: localhost | ||
gather_facts: false | ||
tasks: | ||
- name: show defined/undefined var | ||
debug: var=mytest | ||
vars: | ||
mytest: '{{ und }}' | ||
register: var_undefined | ||
|
||
- name: ensure either mytest is defined or debug finds it to be undefined | ||
assert: | ||
that: | ||
- mytest is defined or 'VARIABLE IS NOT DEFINED!' in var_undefined['mytest'] |