inventory group name variable

1,997 views
Skip to first unread message

Mauricio Castro

unread,
Oct 23, 2017, 8:35:18 AM10/23/17
to Ansible Project
I am kindda new to Ansible and I've been trying to find this information everywhere, but I can't seen to get what I really need, which is:

given a inventory with a group name [xyz] for example, while running ansible with that inventory and pointing to that group specifically like:

> ansible -i my_inventory xyz -m debug -a "msg='the group I am using is {{ ????_does _this_variable_exist_predefined_anywhere_??? }}'"

help?

Kai Stian Olstad

unread,
Oct 23, 2017, 9:15:53 AM10/23/17
to ansible...@googlegroups.com
It's not possible to get that information.

--
Kai Stian Olstad

Mauricio Castro

unread,
Oct 23, 2017, 9:27:09 AM10/23/17
to Ansible Project
Thanks so much Kai, I've been eagerly searching these next few moments and found out it's really nowhere, but good came out of that and I realized I can do a "dynamic inventory" and pass it on as ".py" to -i option of ansible!!! (http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html)

I will try that from the docs and see how it goes: "
ansible -i openstack.py all -m ping"

this could save my day and add some fun to my inventories
.

Thank you for your prompt answer.

Brian Coca

unread,
Oct 23, 2017, 10:03:04 AM10/23/17
to Ansible Project
Ansible has hosts and tasks as the primary objects, groups are only
used in inventory to allow for host selection and convenient variable
assignment. Once we start task execution, they are just 'labels'
associated with a host, the variable `group_names` contains all the
groups of the current host.

Also, hosts are always at least part of 2 groups, one of them being
'all' (implicit localhost being the exception).


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages