1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/environment/test_environment.yml

77 lines
2 KiB
YAML
Raw Normal View History

2015-08-21 06:37:17 +02:00
- hosts: testhost
vars:
- test1:
key1: val1
2017-04-12 18:59:41 +02:00
environment:
PATH: '{{ansible_env.PATH + ":/lola"}}'
lola: 'ido'
2015-08-21 06:37:17 +02:00
tasks:
2017-04-12 18:59:41 +02:00
- name: ensure special case with ansible_env is skipped but others still work
assert:
that:
- lookup('env', 'PATH') == ansible_env.PATH
- "'/lola' not in ansible_env.PATH"
- ansible_env.lola == 'ido'
2015-08-21 06:37:17 +02:00
- name: check that envvar does not exist
shell: echo $key1
register: test_env
- name: assert no val in stdout
assert:
2015-08-21 06:37:17 +02:00
that:
- '"val1" not in test_env.stdout_lines'
2015-08-21 06:37:17 +02:00
- name: check that envvar does exist
shell: echo $key1
environment: "{{test1}}"
register: test_env2
- name: assert val1 in stdout
assert:
2015-08-21 06:37:17 +02:00
that:
- '"val1" in test_env2.stdout_lines'
2015-08-21 06:37:17 +02:00
- hosts: testhost
vars:
- test1:
key1: val1
- test2:
key1: not1
other1: val2
environment: "{{test1}}"
tasks:
- name: check that play envvar does exist
shell: echo $key1
register: test_env3
2015-08-21 06:37:17 +02:00
- name: assert val1 in stdout
assert:
2015-08-21 06:37:17 +02:00
that:
- '"val1" in test_env3.stdout_lines'
2015-08-21 06:37:17 +02:00
- name: check that task envvar does exist
shell: echo $key1; echo $other1
register: test_env4
2015-08-21 06:37:17 +02:00
environment: "{{test2}}"
- name: assert all vars appear as expected
assert:
2015-08-21 06:37:17 +02:00
that:
- '"val1" not in test_env4.stdout_lines'
- '"not1" in test_env4.stdout_lines'
- '"val2" in test_env4.stdout_lines'
- block:
- name: check that task envvar does exist in block
shell: echo $key1; echo $other1
register: test_env5
- name: assert all vars appear as expected in block
assert:
that:
- '"val1" not in test_env5.stdout_lines'
- '"not1" in test_env5.stdout_lines'
- '"val2" in test_env5.stdout_lines'
environment: "{{test2}}"