diff options
author | Matt Martz <matt@sivel.net> | 2023-06-13 18:37:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-13 18:37:17 +0200 |
commit | 73e04ef2d6103bad2519b55f04a9c2865b8c93fe (patch) | |
tree | 8aed82123cd5abc3499f1d463e1161fcf02016da /test | |
parent | Improved return docs (#81006) (diff) | |
download | ansible-73e04ef2d6103bad2519b55f04a9c2865b8c93fe.tar.xz ansible-73e04ef2d6103bad2519b55f04a9c2865b8c93fe.zip |
Don't mutate templar.environment, only overlay on local myenv (#81005)
Diffstat (limited to 'test')
4 files changed, 43 insertions, 29 deletions
diff --git a/test/integration/targets/template/arg_template_overrides.j2 b/test/integration/targets/template/arg_template_overrides.j2 new file mode 100644 index 0000000000..17a79b9146 --- /dev/null +++ b/test/integration/targets/template/arg_template_overrides.j2 @@ -0,0 +1,4 @@ +var_a: << var_a >> +var_b: << var_b >> +var_c: << var_c >> +var_d: << var_d >> diff --git a/test/integration/targets/template/in_template_overrides.yml b/test/integration/targets/template/in_template_overrides.yml deleted file mode 100644 index 3c2d4d9900..0000000000 --- a/test/integration/targets/template/in_template_overrides.yml +++ /dev/null @@ -1,28 +0,0 @@ -- hosts: localhost - gather_facts: false - vars: - var_a: "value" - var_b: "{{ var_a }}" - var_c: "<< var_a >>" - tasks: - - set_fact: - var_d: "{{ var_a }}" - - - block: - - template: - src: in_template_overrides.j2 - dest: out.txt - - - command: cat out.txt - register: out - - - assert: - that: - - "'var_a: value' in out.stdout" - - "'var_b: value' in out.stdout" - - "'var_c: << var_a >>' in out.stdout" - - "'var_d: value' in out.stdout" - always: - - file: - path: out.txt - state: absent diff --git a/test/integration/targets/template/runme.sh b/test/integration/targets/template/runme.sh index 30163af7db..eaaa6aa6a5 100755 --- a/test/integration/targets/template/runme.sh +++ b/test/integration/targets/template/runme.sh @@ -39,7 +39,7 @@ ansible-playbook 72262.yml -v "$@" ansible-playbook unsafe.yml -v "$@" # ensure Jinja2 overrides from a template are used -ansible-playbook in_template_overrides.yml -v "$@" +ansible-playbook template_overrides.yml -v "$@" ansible-playbook lazy_eval.yml -i ../../inventory -v "$@" diff --git a/test/integration/targets/template/template_overrides.yml b/test/integration/targets/template/template_overrides.yml new file mode 100644 index 0000000000..50cfb8f14b --- /dev/null +++ b/test/integration/targets/template/template_overrides.yml @@ -0,0 +1,38 @@ +- hosts: localhost + gather_facts: false + vars: + output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}" + var_a: "value" + var_b: "{{ var_a }}" + var_c: "<< var_a >>" + tasks: + - set_fact: + var_d: "{{ var_a }}" + + - template: + src: in_template_overrides.j2 + dest: '{{ output_dir }}/in_template_overrides.out' + + - template: + src: arg_template_overrides.j2 + dest: '{{ output_dir }}/arg_template_overrides.out' + variable_start_string: '<<' + variable_end_string: '>>' + + - command: cat '{{ output_dir }}/in_template_overrides.out' + register: in_template_overrides_out + + - command: cat '{{ output_dir }}/arg_template_overrides.out' + register: arg_template_overrides_out + + - assert: + that: + - "'var_a: value' in in_template_overrides_out.stdout" + - "'var_b: value' in in_template_overrides_out.stdout" + - "'var_c: << var_a >>' in in_template_overrides_out.stdout" + - "'var_d: value' in in_template_overrides_out.stdout" + + - "'var_a: value' in arg_template_overrides_out.stdout" + - "'var_b: value' in arg_template_overrides_out.stdout" + - "'var_c: << var_a >>' in arg_template_overrides_out.stdout" + - "'var_d: value' in arg_template_overrides_out.stdout" |