inventory_dir is still present as a global variable in Ansible 2.4 ?

Hi All,

I am trying to understand the changes with Ansible 2.4 that affects the usage of inventory_dir variable.

Earlier i was using a static host file and in my playbooks, i was heavily relying on inventory_dir to load variable files which in turn was loading the target hosts. I understand the purpose of making the inventory_dir as a hostvar, what i did not understand is how can i still access inventory_dir directly as a global variable in my playbooks ?

To show what i mean, i created a little demo:

hosts.info

`

[locals]
local1 localhost ansible_connection=local
local2 localhost ansible_connection=local

`

varsFile.yaml

`

#This doesn’t work anymore
#moreVars: “{{ inventory_dir ~ ‘moreVars.yaml’ }}”

#This also works
#moreVars: “{{hostvars[groups.all.0].inventory_dir}}/moreVars.yaml”

#This works and this is what i was using before 2.4
moreVars: “{{inventory_dir}}/moreVars.yaml”

`

moreVars.yaml

`

#Prior to 2.4, this is how i defined target hosts. I understand this will not work anymore

targetHosts: locals

who: MORE_VARS

`

playbook.yaml

`

Please see http://docs.ansible.com/ansible/latest/porting_guide_2.4.html#inventory for information about the change to inventory_dir