vars_files query

Greetings.

I'm running into something weird with vars_files and I thought I would
ask the list if it's a bug I should file or if I am just doing
something wrong. :wink:

I had:

  vars_files:
    - /srv/web/infra/ansible/vars/global.yml
    - $private/vars.yml
    - $vars/$ansible_distributiion.yml

and private and vars were both defined in global.yml and all worked.

Switching to new syntax:

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "{{ private }}/vars.yml"
   - "{{ vars }}/{{ ansible_distribution }}.yml"

results in the last vars file never loading. If I replace {{ vars }} by
the path it loads fine. If I replace the {{ ansible_distribution }}with
a hard coded one it loads ok. It's like it's not expanding multiple
variables in the same import line?

As a side note, at some points I see it mentioning that the distro vars
file is being imported, but not other times. When does ansible-playbook
note "importing ..." ?

Thanks for any thoughts...

kevin

There should be nothing about the different variable syntaxes making a difference here, fact loading is exactly the same and templating runs the same for each.

What I have caught though is a typo in your original:

  • $vars/$ansible_distributiion.yml

And also that vars is reserved.

https://github.com/ansible/ansible/blob/devel/lib/ansible/runner/init.py#L454

Ah, so it is... I was looking at:

http://www.ansibleworks.com/docs/playbooks_variables.html#id22
which doesn't mention vars as being reserved. ;(

I got it working... something was wacky with my git checkout I was
running from. I did a clean checkout and reconverted and everything
seems to be working now.

Thanks and sorry for the noise.

kevin

No problem.

And as for the docs error, while you can file a ticket on the docs, pull requests to the documentation source would also be accepted.

(In other news, we hope to make the newly restructured docs page site the default in a few days or less)