2014-05-09 18:42:45 +02:00
|
|
|
---
|
|
|
|
- hosts: testhost
|
|
|
|
vars:
|
2015-12-02 06:11:12 +01:00
|
|
|
- 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!') }}"
|
2014-05-09 18:42:45 +02:00
|
|
|
vars_files:
|
2015-12-02 06:11:12 +01:00
|
|
|
- vars/test_var_precedence.yml
|
2014-05-09 18:42:45 +02:00
|
|
|
roles:
|
2015-12-02 06:11:12 +01:00
|
|
|
- { role: test_var_precedence, param_var: "param_var" }
|
2014-05-09 18:42:45 +02:00
|
|
|
tasks:
|
2015-12-02 06:11:12 +01:00
|
|
|
- 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"'
|
2014-09-10 00:41:58 +02:00
|
|
|
|
|
|
|
- hosts: inven_overridehosts
|
|
|
|
vars_files:
|
2015-12-02 06:11:12 +01:00
|
|
|
- "test_var_precedence.yml"
|
2014-09-10 00:41:58 +02:00
|
|
|
roles:
|
2015-12-02 06:11:12 +01:00
|
|
|
- role: test_var_precedence_inven_override
|
|
|
|
foo: bar
|
2014-09-10 00:41:58 +02:00
|
|
|
|