summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/var_precedence/test_var_precedence.yml
blob: 58584bfb3ef619be9ece2f334b56cba2325974ff (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
---
- hosts: testhost
  vars:
    - ansible_hostname: "BAD!"
    - vars_var: "vars_var"
    - param_var: "BAD!"
    - vars_files_var: "BAD!"
    - extra_var_override_once_removed: "{{ extra_var_override }}"
    - from_inventory_once_removed: "{{ inven_var | default('BAD!') }}"
  vars_files:
    - vars/test_var_precedence.yml
  roles:
    - { role: test_var_precedence, param_var: "param_var" }
  tasks:
    - name: register a result
      command: echo 'BAD!'
      register: registered_var
    - name: use set_fact to override the registered_var
      set_fact: registered_var="this is from set_fact"
    - debug: var=extra_var
    - debug: var=extra_var_override_once_removed
    - debug: var=vars_var
    - debug: var=vars_files_var
    - debug: var=vars_files_var_role
    - debug: var=registered_var
    - debug: var=from_inventory_once_removed
    - assert:
        that: item
      with_items:
          - 'extra_var == "extra_var"'
          - 'extra_var_override == "extra_var_override"'
          - 'extra_var_override_once_removed == "extra_var_override"'
          - 'vars_var == "vars_var"'
          - 'vars_files_var == "vars_files_var"'
          - 'vars_files_var_role == "vars_files_var_role3"'
          - 'registered_var == "this is from set_fact"'
          - 'from_inventory_once_removed == "inventory_var"'

- hosts: inven_overridehosts
  vars_files:
    - "test_var_precedence.yml"
  roles:
    - role: test_var_precedence_inven_override
      foo: bar