diff --git a/test/integration/Makefile b/test/integration/Makefile index d35731956a..50a56502f9 100644 --- a/test/integration/Makefile +++ b/test/integration/Makefile @@ -21,7 +21,7 @@ VAULT_PASSWORD_FILE = vault-password CONSUL_RUNNING := $(shell python consul_running.py) -all: parsing test_var_precedence unicode test_templating_settings non_destructive destructive includes check_mode test_hash test_handlers test_group_by test_vault test_tags test_lookup_paths +all: parsing test_var_precedence unicode test_templating_settings environment non_destructive destructive includes check_mode test_hash test_handlers test_group_by test_vault test_tags test_lookup_paths parsing: ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario5 @@ -38,6 +38,9 @@ unicode: test_templating_settings: ansible-playbook test_templating_settings.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) +environment: + ansible-playbook test_environment.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) $(TEST_FLAGS) + non_destructive: ansible-playbook non_destructive.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) diff --git a/test/integration/test_environment.yml b/test/integration/test_environment.yml new file mode 100644 index 0000000000..560661628e --- /dev/null +++ b/test/integration/test_environment.yml @@ -0,0 +1,52 @@ +- hosts: testhost + vars: + - test1: + key1: val1 + roles: + - { role: prepare_tests } + tasks: + - name: check that envvar does not exist + shell: echo $key1 + register: test_env + + - assert: + that: + - '"val1" not in test_env.stdout' + + - name: check that envvar does exist + shell: echo $key1 + environment: "{{test1}}" + register: test_env2 + + - assert: + 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 + register: test_env + + - assert: + that: + - '"val1" in test_env.stdout' + + - name: check that task envvar does exist + shell: echo $key1; echo $other1 + register: test_env2 + environment: "{{test2}}" + + - assert: + that: + - '"val1" not in test_env2.stdout' + - '"not1" in test_env2.stdout' + - '"val2" in test_env2.stdout'