Could not find out why variables not being picked up in Ansible 2.3.1.0.
File structure:
.
├── ansible.cfg
├── group_vars
│ └── test1.yml
├── hosts
├── host_vars
│ └── test1
├── roles
│ └── install
│ └── tasks
│ └── main.yml
├── testing.retry
└── testing.yml
group_vars/test1.yml
:
---
test_var: "This is from host_vars file"
content of host_vars/test1
:
---
test_var: "This is from host_vars file"
Content of roles/install/tasks/main.yml
:
---
- name: Debug
debug: var=test_var
Result is:
ansible-playbook -i hosts testing.yml
PLAY [This is testing] *****************************************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************************************
ok: [localhost]
TASK [install : Debug] *****************************************************************************************************************************************************
ok: [localhost] => {
"test_var": "VARIABLE IS NOT DEFINED!"
}
PLAY RECAP *****************************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
Expect output:
test_var = This is from host_vars file