How can I use ec2.py and localhost at the same time
amazon-ec2, amazon-web-services, ansible
Solution
I was trying to solve a similar issue.
I had a bunch of hosts which accepted connections from the Ansible host. For security reasons the Ansible host was not allowed to connect to itself. However, I needed to run the Common play on all host.
I specified all hosts, excluded the Ansible host, and then added localhost:
- name: Common
hosts: "tag_name_*:!tag_name_ansible:localhost"
roles:
- common
Adding localhost worked fine even when using the EC2 inventory script. I am using Ansible 1.7 with an up-to-date EC2 inventory script.
Problem
How can I use the ec2.py to get a dynamic list of ec2 hosts and also use localhost as a host. I have googled over and over and can't seem to find a good solution. I have come across some close answers but all seem to require breaking your tasks down into two separate playbooks that can't be run at the same time.