Hi all,
I have a bunch of playbooks which only define what needs to be done, and i had split my inventory in some logical groups, so each inventory file is a complete definition of this group and to run run any playbook, i would simply use the desired inventory file.
The hosts part of my playbook is defined by a variable and this variable is defined by a file which i will always find next to any of my inventory. So i would simply load this file in my playbooks like this:
`
vars_file
- “{{inventory_dir}}/host_definition.yaml”
`
It worked perfectly fine till now, but i see that this is going to break in Ansible 2.4 as inventory_dir is now a host var so i cannot use it to load host variables.
So my questions:
- Any alternative to get path of inventory file at the global level ?
- I want to keep the target host list defined (and thus loaded with) in the inventory. I understand the whole situation where Ansible needs to know the host vars before loading the variables within, but i would like to load a global variable from within inventory files. Is this possible ?
Note: In the release notes of Ansible 2.4 ( https://github.com/ansible/ansible/blob/stable-2.4/CHANGELOG.md#24-dancing-days---2017-09-19 ) there is a mention about change in include_dir which i think should be inventory_dir
The include_dir
var is not a global anymore, as we now allow multiple inventory sources, it is now host dependant. This means it cannot be used wherever host vars are not permitted, for example in task/handler names.