I have the following ansible setup:
ansible_test/playbooks/roles/main/main.yml
- name: hello world
hosts: all
tasks:
- name: hello!
shell: echo "test"
- name: display config
debug:
msg: "testvar is {{ hostvars['localhost']['testvar'] }}"
ansible_test/playbooks/inventory/hosts
[main]
localhost
[main:vars]
testvar=99
ansible-test/playbooks/inventory/group_vars/all/main.yml
testvar: 77
Now, when I modify the hosts file to the following:
[main]
localhost testvar=88
[main:vars]
testvar=99
I get an output of "testvar is 88". However, when I remove this, I get "testvar is 77" instead of the expected "testvar is 99".
When I add "testvar: 101" to a file: ansible_test/playbooks/inventory/host_vars/localhost.yml, I get an output of "testvar is 101".
I am running the command:
/usr/bin/ansible-playbook -i playbooks/inventory/hosts playbooks/roles/main/main.yml --connection=local -vvvv
Why is this? Shouldn't this host-group definition still take precedence over group_vars?
