I'm teaching myself Ansible using the free tier of AWS. I'll be keeping my playbooks here.
Before I could begin, I had to configure an Ansible server running in my AWS VPC. I started with a RHEL 7 instance because I was already familiar with Red Hat. I also wanted to use the dynamic inventory I saw described in an AWS blog post. There was a sequence of prerequisites I needed to satisfy.
- Download EPEL RPM from EPEL wiki
- Install Boto from EPEL
- Install pip from EPEL
- Install AWS CLI using pip
- Create IAM role with read-only access
- Launch an instance with the new IAM role
- Download EC2 scripts from Ansible GitHub repo
- Configure command line environment according to instructions in blog post (and export
ANSIBLE_HOSTS
in~/.bash_profile
) - Edit
ec2.ini
to make AWS CLI use private DNS names and IPs
The time I spent configuring these prerequisites turned out to be worthwhile. A dynamic inventory allows me to refer to groups of AWS instances by their tags. I can also automatically apply my playbooks to new instances launched since the last time I ran Ansible.
References