# Can't run playbook against multiple nodes using ec2.py and AWS tags

**URL:** <https://forum.ansible.com/t/cant-run-playbook-against-multiple-nodes-using-ec2-py-and-aws-tags/20317>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [January 22, 2016, 3:33pm UTC](https://forum.ansible.com/t/cant-run-playbook-against-multiple-nodes-using-ec2-py-and-aws-tags/20317 "2016-01-22T15:33:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexander.altanis](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@alexander.altanis](https://forum.ansible.com/u/alexander.altanis)\
**Post date:** [January 22, 2016, 3:33pm UTC](https://forum.ansible.com/t/cant-run-playbook-against-multiple-nodes-using-ec2-py-and-aws-tags/20317/1 "2016-01-22T15:33:29Z")

</div>

Hello,

I’m using the Amazon Dynamic inventory script from [here](http://docs.ansible.com/ansible/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script). I’ve created some instances on EC2, and have given all of them a custom tag called Purpose, with a value like NodePurpose, and instance names Node1, Node2 etc.

I’ve written a playbook with:

---

<div class="post-metadata">

**Author:** ![emmanuel.mayssat](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@emmanuel.mayssat](https://forum.ansible.com/u/emmanuel.mayssat)\
**Post date:** [January 22, 2016, 5:10pm UTC](https://forum.ansible.com/t/cant-run-playbook-against-multiple-nodes-using-ec2-py-and-aws-tags/20317/2 "2016-01-22T17:10:57Z")

</div>

Well…  
do you nodes have the same ssh key?  
is ubuntu your remote\_user ?  
is ~ubuntu/.ansible writable/readable?

Better yet, can you show us your playbook and the task it is failing on?  
Best,

---

<div class="post-metadata">

**Author:** ![alexander.altanis](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@alexander.altanis](https://forum.ansible.com/u/alexander.altanis)\
**Post date:** [January 25, 2016, 9:00am UTC](https://forum.ansible.com/t/cant-run-playbook-against-multiple-nodes-using-ec2-py-and-aws-tags/20317/3 "2016-01-25T09:00:49Z")

</div>

The nodes have the same ssh key, and the user is correct. In fact, when I try the playbook with --limit, and apply it on one node at a time, it works correctly. It’s only when I group nodes using a custom EC2 tag, that this happens.

Also, this has happened with several playbooks, and always during the “setup” task, before any of my own tasks. To demonstrate this, I wrote this ultra-simple playbook:

> * * *
> 
> - hosts: tag\_Purpose\_NodePurpose  
> gather\_facts: True  
> become: yes  
> tasks:
> - debug: msg=“This is just a demonstration”

It still happens. I got the following output (some stuff redacted):

[http://pastebin.com/m2Lu8yQC](http://pastebin.com/m2Lu8yQC)

I also ran the same playbook ONLY on the node that failed above, and it worked correctly.

---

<div class="post-metadata">

**Author:** ![alexander.altanis](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@alexander.altanis](https://forum.ansible.com/u/alexander.altanis)\
**Post date:** [January 25, 2016, 12:42pm UTC](https://forum.ansible.com/t/cant-run-playbook-against-multiple-nodes-using-ec2-py-and-aws-tags/20317/4 "2016-01-25T12:42:37Z")

</div>

I believe I figured out the problem. I had set my control\_path to this value in ansible.cfg:

> [ssh\_connection]  
> control\_path = %(directory)s/%%r

Which didn’t include %h (ie hostname), so connections overwrote each others’ control sockets (by default, ansible seems to re-use SSH connections as decribed [here](https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing)).

I tried both adding %h to the control path, and disabling multiplexing (ControlMaster=no), and both succeeded.

So, kids, include at least %h, %p and %r in the control path, as the [man page](http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/ssh_config.5) suggests, so that connections don’t get mixed up.
