diff options
Diffstat (limited to 'test/integration/targets/lookup_env')
-rw-r--r-- | test/integration/targets/lookup_env/aliases | 1 | ||||
-rwxr-xr-x | test/integration/targets/lookup_env/runme.sh | 12 | ||||
-rw-r--r-- | test/integration/targets/lookup_env/tasks/main.yml | 15 |
3 files changed, 28 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_env/aliases b/test/integration/targets/lookup_env/aliases new file mode 100644 index 0000000..b598321 --- /dev/null +++ b/test/integration/targets/lookup_env/aliases @@ -0,0 +1 @@ +shippable/posix/group3 diff --git a/test/integration/targets/lookup_env/runme.sh b/test/integration/targets/lookup_env/runme.sh new file mode 100755 index 0000000..698d6bf --- /dev/null +++ b/test/integration/targets/lookup_env/runme.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -ex + +unset USR +# this should succeed and return 'nobody' as var is undefined +ansible -m debug -a msg="{{ lookup('env', 'USR', default='nobody')}}" localhost |grep nobody +# var is defined but empty, so should return empty +USR='' ansible -m debug -a msg="{{ lookup('env', 'USR', default='nobody')}}" localhost |grep -v nobody + +# this should fail with undefined +ansible -m debug -a msg="{{ lookup('env', 'USR', default=Undefined)}}" localhost && exit 1 || exit 0 diff --git a/test/integration/targets/lookup_env/tasks/main.yml b/test/integration/targets/lookup_env/tasks/main.yml new file mode 100644 index 0000000..daaeb35 --- /dev/null +++ b/test/integration/targets/lookup_env/tasks/main.yml @@ -0,0 +1,15 @@ +- name: get HOME environment var value + shell: "echo $HOME" + register: home_var_value + +- name: use env lookup to get HOME var + set_fact: + test_val: "{{ lookup('env', 'HOME') }}" + +- debug: var=home_var_value.stdout +- debug: var=test_val + +- name: compare values + assert: + that: + - "test_val == home_var_value.stdout" |