access to host_vars and group_vars from new Inventory plugin

9 views
Skip to first unread message

Artem Gromov

unread,
Oct 19, 2019, 9:56:58 AM10/19/19
to Ansible Development
Hi,

I am trying to develop custom inventory plugin.

And I wonder if its possible to access vars defined in host_vars and group_vars from parse method of this plugin.

All i can get are vars 'inventory_file', 'inventory_dir' and nothing like vars from host_vars files.

Artem Gromov

unread,
Oct 19, 2019, 9:57:49 AM10/19/19
to Ansible Development
I am using
ansible 2.8.1
  config file = /home/artgromov/arcadia/logbroker/juggler/ansible-juggler/ansible.cfg
  configured module search path = [u'/home/artgromov/arcadia/logbroker/juggler/ansible-juggler/plugins/library']
  ansible python module location = /home/artgromov/.local/share/virtualenvs/ansible-juggler-GeUFfaTC/lib/python2.7/site-packages/ansible
  executable location = /home/artgromov/.local/share/virtualenvs/ansible-juggler-GeUFfaTC/bin/ansible
  python version = 2.7.15 (default, Oct 15 2018, 15:26:09) [GCC 8.2.1 20180801 (Red Hat 8.2.1-2)]

Brian Coca

unread,
Nov 11, 2019, 4:40:29 PM11/11/19
to Artem Gromov, Ansible Development
You have access to host and group vars defined by previous inventory
sources, but the host_vars/group_vars files are not available, since
those are processed after all inventory is defined.

You could call the vars plugins directly but it is not something I advise.



--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages