2015-08-21 04:37:17 +00:00
|
|
|
- hosts: testhost
|
|
|
|
vars:
|
|
|
|
- test1:
|
|
|
|
key1: val1
|
|
|
|
roles:
|
|
|
|
- { role: prepare_tests }
|
|
|
|
tasks:
|
|
|
|
- name: check that envvar does not exist
|
|
|
|
shell: echo $key1
|
|
|
|
register: test_env
|
|
|
|
|
2015-08-25 02:57:56 +00:00
|
|
|
- name: assert no val in stdout
|
|
|
|
assert:
|
2015-08-21 04:37:17 +00:00
|
|
|
that:
|
|
|
|
- '"val1" not in test_env.stdout'
|
|
|
|
|
|
|
|
- name: check that envvar does exist
|
|
|
|
shell: echo $key1
|
|
|
|
environment: "{{test1}}"
|
|
|
|
register: test_env2
|
|
|
|
|
2015-08-25 02:57:56 +00:00
|
|
|
- name: assert val1 in stdout
|
|
|
|
assert:
|
2015-08-21 04:37:17 +00:00
|
|
|
that:
|
|
|
|
- '"val1" in test_env2.stdout'
|
|
|
|
|
|
|
|
- hosts: testhost
|
|
|
|
tasks:
|
|
|
|
vars:
|
|
|
|
- test1:
|
|
|
|
key1: val1
|
|
|
|
- test2:
|
|
|
|
key1: not1
|
|
|
|
other1: val2
|
|
|
|
environment: "{{test1}}"
|
|
|
|
tasks:
|
|
|
|
- name: check that play envvar does exist
|
|
|
|
shell: echo $key1
|
2015-08-25 02:57:56 +00:00
|
|
|
register: test_env3
|
2015-08-21 04:37:17 +00:00
|
|
|
|
2015-08-25 02:57:56 +00:00
|
|
|
- name: assert val1 in stdout
|
|
|
|
assert:
|
2015-08-21 04:37:17 +00:00
|
|
|
that:
|
2015-08-25 02:57:56 +00:00
|
|
|
- '"val1" in test_env3.stdout'
|
2015-08-21 04:37:17 +00:00
|
|
|
|
|
|
|
- name: check that task envvar does exist
|
|
|
|
shell: echo $key1; echo $other1
|
2015-08-25 02:57:56 +00:00
|
|
|
register: test_env4
|
2015-08-21 04:37:17 +00:00
|
|
|
environment: "{{test2}}"
|
|
|
|
|
2015-08-25 02:57:56 +00:00
|
|
|
- name: assert all vars appear as expected
|
|
|
|
assert:
|
2015-08-21 04:37:17 +00:00
|
|
|
that:
|
2015-08-25 02:57:56 +00:00
|
|
|
- '"val1" not in test_env4.stdout'
|
|
|
|
- '"not1" in test_env4.stdout'
|
|
|
|
- '"val2" in test_env4.stdout'
|