diff options
author | Sloane Hertel <shertel@redhat.com> | 2017-12-08 10:13:22 -0500 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-01-24 08:51:05 -0800 |
commit | deaa9a21f9b5cdc65791cf4c8ef46c2353ae108d (patch) | |
tree | 8e5fb44a05bd4b4f6fa34b89d8fcd897322166a9 /test/integration/targets/environment/test_environment.yml | |
parent | 6233daaa446993e4820f0eaa83ffdeb673dbcced (diff) | |
download | ansible-deaa9a21f9b5cdc65791cf4c8ef46c2353ae108d.tar.gz |
Fix using loops with environment and add tests (#32796)
(cherry picked from commit 7bb35e8781b46cb6024a6e45e76cb663185fe10d)
Diffstat (limited to 'test/integration/targets/environment/test_environment.yml')
-rw-r--r-- | test/integration/targets/environment/test_environment.yml | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/test/integration/targets/environment/test_environment.yml b/test/integration/targets/environment/test_environment.yml index e35a438582..f8e49ac8d0 100644 --- a/test/integration/targets/environment/test_environment.yml +++ b/test/integration/targets/environment/test_environment.yml @@ -74,3 +74,93 @@ - '"not1" in test_env5.stdout_lines' - '"val2" in test_env5.stdout_lines' environment: "{{test2}}" + +- name: test setting environment while using loops + hosts: testhost + environment: + foo: outer + tasks: + - name: verify foo==outer + command: /bin/echo $foo + loop: + - 1 + register: test_foo + + - name: assert foo==outer + assert: + that: + - "{{ test_foo.results[0].stdout == 'outer' }}" + + - name: set environment on a task + environment: + foo: in_task + command: /bin/echo $foo + loop: + - 1 + register: test_foo + + - name: assert foo==in_task + assert: + that: + - "test_foo.results[0].stdout == 'in_task'" + + - name: test that the outer env var is set appropriately still + command: /bin/echo $foo + loop: + - 1 + register: test_foo + + - name: assert foo==outer + assert: + that: + - "{{ test_foo.results[0].stdout == 'outer' }}" + + - name: set environment on a block + environment: + foo: in_block + block: + - name: test the environment is set in the block + command: /bin/echo $foo + loop: + - 1 + register: test_foo + + - name: assert foo==in_block + assert: + that: + - "test_foo.results[0].stdout == 'in_block'" + + - name: test setting environment in a task inside a block + environment: + foo: in_block_in_task + command: /bin/echo $foo + loop: + - 1 + register: test_foo + + - name: assert foo==in_block_in_task + assert: + that: + - "test_foo.results[0].stdout == 'in_block_in_task'" + + - name: test the environment var is set to the parent value + command: /bin/echo $foo + loop: + - 1 + register: test_foo + + - name: assert foo==in_block + assert: + that: + - "test_foo.results[0].stdout == 'in_block'" + + - name: test the env var foo has the initial value + command: /bin/echo $foo + loop: + - 1 + register: test_foo + + - name: assert foo==outer + assert: + that: + - "{{ test_foo.results[0].stdout == 'outer' }}" |