# Group ec2 instances and local machines together

**URL:** <https://forum.ansible.com/t/group-ec2-instances-and-local-machines-together/21498>\
**Category:** Ansible Project\
**Created:** [May 19, 2016, 10:59pm UTC](https://forum.ansible.com/t/group-ec2-instances-and-local-machines-together/21498 "2016-05-19T22:59:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Braun](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@Alex\_Braun](https://forum.ansible.com/u/Alex_Braun)\
**Post date:** [May 19, 2016, 10:59pm UTC](https://forum.ansible.com/t/group-ec2-instances-and-local-machines-together/21498/1 "2016-05-19T22:59:20Z")

</div>

I want to run a playbook with some group\_vars on some Amazon EC2 instances and on some local machines. Is there some way that I can group EC2 instances (by tag) and local machines under the same inventory group?

For instance:

inventory/dev.yml

```auto
macbookpro ansible_ssh_host=1.2.3.4

[dev]
macbookpro # some local machine (not necessarily localhost)
tag_branch_dev # EC2 tag

```

playbooks/setup-dev.yml

```auto
- hosts: dev
roles:
- role: users
become: true

```

---

<div class="post-metadata">

**Author:** ![alexey.vazhnov](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@alexey.vazhnov](https://forum.ansible.com/u/alexey.vazhnov)\
**Post date:** [May 20, 2016, 12:56pm UTC](https://forum.ansible.com/t/group-ec2-instances-and-local-machines-together/21498/2 "2016-05-20T12:56:21Z")

</div>

Yes, just put your static inventory and EC2 dynamic inventory script in one folder.

---

<div class="post-metadata">

**Author:** ![Josh\_Smift1](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Josh\_Smift1](https://forum.ansible.com/u/Josh_Smift1)\
**Post date:** [May 20, 2016, 2:03pm UTC](https://forum.ansible.com/t/group-ec2-instances-and-local-machines-together/21498/3 "2016-05-20T14:03:04Z")

</div>

We wrote a sort of meta-inventory script to do this kind of thing;  
[https://github.com/caredotcom/ansible-quartermaster](https://github.com/caredotcom/ansible-quartermaster) might be useful (as  
is, as an example, as a warning, etc :^).

(Wanting AWS things things with tag\_whatever\_foo, and static things in  
group 'foo', to both end up in the same Ansible group, was a big motivation.)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
