Ansible Galaxy

Once you’ve got your feet wet with Ansible, head over here ( ) to read up on Ansible Galaxy. It’s a kin to Puppet Forge, but it’s also a CLI tool that lets you create roles quicker.

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 someplaybook.yml working, (test it with ./ –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

Getting rolling with Ansible on OSX 10.9.5

If you’re trying to leverage Ansible on OSX to control AWS instances with the API extension (and who isn’t these days 😛 ) and you get something like this back:

ansible-playbook -i inventory/ playbook.yml
Traceback (most recent call last):
File “/usr/local/bin/ansible-playbook”, line 28, in
import ansible.playbook
File “/Library/Python/2.7/site-packages/ansible/playbook/”, line 20, in
import ansible.runner
File “/Library/Python/2.7/site-packages/ansible/runner/”, line 32, in
import jinja2
File “/Library/Python/2.7/site-packages/jinja2/”, line 33, in
from jinja2.environment import Environment, Template
File “/Library/Python/2.7/site-packages/jinja2/”, line 13, in
from jinja2 import nodes
File “/Library/Python/2.7/site-packages/jinja2/”, line 18, in
from jinja2.utils import Markup
File “/Library/Python/2.7/site-packages/jinja2/”, line 520, in
from markupsafe import Markup, escape, soft_unicode
ImportError: No module named markupsafe

‘And boom goes the dynamite’

A few things:

Install Xcode from the App Store. This is key, run Xcode. Running if for the first time finished the install process.

Second, install from pip like this: sudo CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install ansible

Even if you’ve installed it with other method, such as homebrew, run the above command.

Get the and ec2.ini files from here: (note, you can get docker, vmware, nova, etc here too)

I didn’t have issues with ansible and my DigitalOcean vms running on CentOS 6.5, controlling a bunch of CentOS 6.5 machines. And, didn’t have issues with ansible on my Mac Pro (10.9.3) controlling my CentOS DigitalOcean VMs, but when I tried to use the API, things got ugly.

Honorable mention, do these things too because their needed or will save you headache.

put this in your ~/.bash_profile or ~/.bashrc

export AWS_ACCESS_KEY=your-aws-access-key-id
export AWS_SECRET_KEY=your-aws-secret-key

put this in your ~/.boto file (you need to make this file)
export AWS_ACCESS_KEY=your-aws-access-key-id
export AWS_SECRET_KEY=your-aws-secret-key

sudo pip install boto
sudo pip install pycrypto (this will blowup if you haven’t run Xcode at least once. If you plan to use the vault feature with Ansible, then you’ll need to upgrade the pycrpto 10.9.5 ships with)

I personally have lost a lot of time on digging around looking for Ansible OSX related answers. Hopefully this helps someone.