summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/environment/test_environment.yml
blob: e72224ba76e0a8d68886cc728b6af3acfb049318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
- hosts: testhost
  vars:
    - test1:
        key1: val1
  tasks:
    - name: check that envvar does not exist
      shell: echo $key1
      register: test_env

    - name: assert no val in stdout
      assert:
        that:
            - '"val1" not in test_env.stdout_lines'

    - name: check that envvar does exist
      shell: echo $key1
      environment: "{{test1}}"
      register: test_env2

    - name: assert val1 in stdout
      assert:
        that:
            - '"val1" in test_env2.stdout_lines'

- 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

    - name: assert val1 in stdout
      assert:
        that:
            - '"val1" in test_env3.stdout_lines'

    - name: check that task envvar does exist
      shell: echo $key1; echo $other1
      register: test_env4
      environment: "{{test2}}"

    - name: assert all vars appear as expected
      assert:
        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}}"