mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
YAML
67 lines
1.6 KiB
YAML
9 years ago
|
- hosts: testhost
|
||
|
vars:
|
||
|
- test1:
|
||
|
key1: val1
|
||
|
tasks:
|
||
|
- name: check that envvar does not exist
|
||
|
shell: echo $key1
|
||
|
register: test_env
|
||
|
|
||
9 years ago
|
- name: assert no val in stdout
|
||
|
assert:
|
||
9 years ago
|
that:
|
||
9 years ago
|
- '"val1" not in test_env.stdout_lines'
|
||
9 years ago
|
|
||
|
- name: check that envvar does exist
|
||
|
shell: echo $key1
|
||
|
environment: "{{test1}}"
|
||
|
register: test_env2
|
||
|
|
||
9 years ago
|
- name: assert val1 in stdout
|
||
|
assert:
|
||
9 years ago
|
that:
|
||
9 years ago
|
- '"val1" in test_env2.stdout_lines'
|
||
9 years ago
|
|
||
|
- hosts: testhost
|
||
|
vars:
|
||
|
- test1:
|
||
|
key1: val1
|
||
|
- test2:
|
||
|
key1: not1
|
||
|
other1: val2
|
||
|
environment: "{{test1}}"
|
||
|
tasks:
|
||
|
- name: check that play envvar does exist
|
||
|
shell: echo $key1
|
||
9 years ago
|
register: test_env3
|
||
9 years ago
|
|
||
9 years ago
|
- name: assert val1 in stdout
|
||
|
assert:
|
||
9 years ago
|
that:
|
||
9 years ago
|
- '"val1" in test_env3.stdout_lines'
|
||
9 years ago
|
|
||
|
- name: check that task envvar does exist
|
||
|
shell: echo $key1; echo $other1
|
||
9 years ago
|
register: test_env4
|
||
9 years ago
|
environment: "{{test2}}"
|
||
|
|
||
9 years ago
|
- name: assert all vars appear as expected
|
||
|
assert:
|
||
9 years ago
|
that:
|
||
9 years ago
|
- '"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}}"
|