On 31. juli 2017 04:49, Darshan Shroff wrote:
Ansible FAQ clarifies
"‘inventory_hostname’ is a magic variable that indicates the current host
you are looping over in the host loop."
Is there a similar concept of *inventory_groupname* that can be made
available to be used inside a playbook ?
Unfortunately not.
e.g. If we are running a playbook in this manner
ansible-playbook -i inventory/prod site.yml --limit service_a
And 'prod' inventory is defined as below
[service_a]
host1
host2
[service_b]
host2
host3
Then is it feasible to reference the group name - service_a - inside
site.yml in this manner - {{ inventory_groupname }}
You'll need to provide that with --extra-vars
ansible-playbook -i inventory/prod site.yml --limit service_a
--extra-vars mylimit=service_a
I think this should work so you don't have to specify both limit and mylimit
ansible-playbook -i inventory/prod site.yml -e mylimit=service_a
site.yml
---
- hosts: all:&{{ mylimit | default('all') }}
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7a391634-cb81-6cc4-e380-4e772ce2aa04%40olstad.com.
For more options, visit https://groups.google.com/d/optout.