variable scope groups_vars overwrides host_vars?

63 views
Skip to first unread message

Steve Kieu

unread,
Nov 20, 2014, 8:47:11 PM11/20/14
to ansible...@googlegroups.com
Hi all,

I have read the http://docs.ansible.com/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable it does nto answer my question.

Basically I saw two unexpected (at least common sense speaking) behaviour.

example in my inventory hosts file

[base]
jibs

[base:vars]
DNS_SERVER=172.17.42.1

[jibs]
test-jibs ansible_ssh_host=192.168.0.100 ansible_ssh_user=root

[jibs:vars]
XX=VALUE

1. The host test-jibs in jibs groups does not inherit the base:vars

2. If I have a file named  test-jibs in the directory host_vars these variable is not used when the section [jibs:vars] has the same variable name - which is group_vars has more priority than host_vars.

Is it correct behaviour or am I wrong somewhere in my setup.

Kind regards

Brian Coca

unread,
Nov 20, 2014, 8:52:47 PM11/20/14
to ansible...@googlegroups.com
I think you want

[base:groups]
jibs

--
Brian Coca

Brian Coca

unread,
Nov 20, 2014, 8:56:37 PM11/20/14
to ansible...@googlegroups.com
as for the var priority, host_vars should trump group vars, if that is
not the case it is a bug.

I just tested with 1.7.2 and current devel and this works as expected.

what versions are you running? (ansible, python, OS)


--
Brian Coca

Brian Coca

unread,
Nov 20, 2014, 9:00:31 PM11/20/14
to ansible...@googlegroups.com
that was meant to be:

[base:children]
jibs
--
Brian Coca

Steve Kieu

unread,
Nov 20, 2014, 9:04:31 PM11/20/14
to ansible...@googlegroups.com

ansible 1.5.4 on ubuntuy 14.04

Steve Kieu

unread,
Nov 20, 2014, 9:04:57 PM11/20/14
to ansible...@googlegroups.com

Thanks - I will try

Steve Kieu

unread,
Nov 20, 2014, 10:09:10 PM11/20/14
to ansible...@googlegroups.com
Looks like a bug in the version 1.5.2 on Ubuntu. I upgrade it to 1.7.2 and the host vars is correct now.

I also use [base:children] syntax and it seems all good.

Thanks all for suggestions.

Kind regards
Reply all
Reply to author
Forward
0 new messages