# localhost getting all variables from different groups.

**URL:** <https://forum.ansible.com/t/localhost-getting-all-variables-from-different-groups/24252>\
**Category:** Ansible Project\
**Tags:** kubernetes\
**Created:** [April 19, 2017, 6:46pm UTC](https://forum.ansible.com/t/localhost-getting-all-variables-from-different-groups/24252 "2017-04-19T18:46:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Snoby](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Matt\_Snoby](https://forum.ansible.com/u/Matt_Snoby)\
**Post date:** [April 19, 2017, 6:46pm UTC](https://forum.ansible.com/t/localhost-getting-all-variables-from-different-groups/24252/1 "2017-04-19T18:46:49Z")

</div>

Hello,  
I’m looking for advice on how to improve my implementation of my playbook. I know the way I have designed it is very different from the normal way of doing playbooks. I have a playbook that controls deploying configuration to 4 different kubernetes clusters. I use kubectl in a command shell to execute the commands to do deployments. Here is my inventory file:

`

# Inventory File

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 20, 2017, 5:35pm UTC](https://forum.ansible.com/t/localhost-getting-all-variables-from-different-groups/24252/2 "2017-04-20T17:35:15Z")

</div>

Yes, localhost will get them all and the last one is being used.

Since you are not using hostnames in the inventory why not just use some fake hostname instead of localhost and keep ansible\_connection=local.

Since ansible\_connection is local it will still run on the localhost.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 20, 2017, 5:39pm UTC](https://forum.ansible.com/t/localhost-getting-all-variables-from-different-groups/24252/3 "2017-04-20T17:39:51Z")

</div>

This will work:

east.k.tropo.com  
east2.k.tropo.com  
k8s.int.ops.tropo.com  
k8s.k.dub.tropo.com  
test.c.tropo.com  
[group\_vars:all]  
ansible\_connection=local

Just remember that the host is the main object for ansible plays,  
groups are just properties of the host and a convenient way to bulk  
assign vars. Groups are not their own entity outside of inventory  
definition.
