a note about tags, aws, and ansible

I had a difficult time finding this information anywhere. I’m sure it exist, but here’s what’s going on.

Assuming you have ansible-playbook -i ec2.py someplaybook.yml working, (test it with ./ec2.py –list) then you may want to address some of your instances by tags.

Here’s the skinny, let’s say create an instance and give it a key pair tag name / webserver-us-east-1a, ansible is looking for “tag_Name_webserver-us-east-1a” not just “webserver-us-east-1a” in the hosts section of your playbook. Here’s an example below:


# webserver deploy

– hosts: “tag_Name_webserver-us-east-1a”
sudo: True
remote_user: ubuntu
gather_facts: True
– nginx
– common

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s