From a9b5b1bf55728b5d9dd38dc614be491a2c4217f0 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 9 Sep 2014 15:41:58 -0700 Subject: [PATCH] Test that we can override variables set in inventory when the vars_file name is templated Fixes #8903 --- test/integration/inventory | 7 +++++++ .../test_var_precedence_inven_override/tasks/main.yml | 5 +++++ test/integration/test_var_precedence.yml | 8 ++++++++ 3 files changed, 20 insertions(+) create mode 100644 test/integration/roles/test_var_precedence_inven_override/tasks/main.yml diff --git a/test/integration/inventory b/test/integration/inventory index 6a64a919db..59bb395205 100644 --- a/test/integration/inventory +++ b/test/integration/inventory @@ -6,6 +6,13 @@ testhost2 ansible_ssh_host=127.0.0.1 ansible_connection=local # by (preferred) group_vars/ and host_vars/ variables # and are used in testing of variable precedence +[inven_overridehosts] +invenoverride ansible_ssh_host=127.0.0.1 ansible_connection=local + +[inven_overridehosts:vars] +foo=foo +var_dir=vars + [arbitrary_parent:children] local diff --git a/test/integration/roles/test_var_precedence_inven_override/tasks/main.yml b/test/integration/roles/test_var_precedence_inven_override/tasks/main.yml new file mode 100644 index 0000000000..942ae4ec05 --- /dev/null +++ b/test/integration/roles/test_var_precedence_inven_override/tasks/main.yml @@ -0,0 +1,5 @@ +--- +- debug: var=foo +- assert: + that: + - 'foo == "bar"' diff --git a/test/integration/test_var_precedence.yml b/test/integration/test_var_precedence.yml index 722993e02f..bbe89a872c 100644 --- a/test/integration/test_var_precedence.yml +++ b/test/integration/test_var_precedence.yml @@ -26,3 +26,11 @@ - 'vars_files_var == "vars_files_var"' - 'vars_files_var_role == "vars_files_var_role3"' - 'registered_var == "this is from set_fact"' + +- hosts: inven_overridehosts + vars_files: + - "{{ var_dir }}/test_var_precedence.yml" + roles: + - role: test_var_precedence_inven_override + foo: bar +