Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

AWS EC2 inventory generator for Ansible

Project Description

# ec2ansible: EC2 inventory generator for Ansible

[![Build Status](]( [![Downloads](]( [![MIT License](](

`ec2ansible` is a cli tool written in Python (2.7+) for generating realtime AWS EC2 inventory for [Ansible](

There is an [official script]( doing the similar thing. But usually when we are provisioning a server, we only care about its **role**, eg. web server, database server, proxy server, etc, instead of its availability zone, AMI ID, nor instance type. `ec2ansible` groups your EC2 servers into Ansible inventory hierarchically based on the `Role` tag associated with them.

## Use Case
Asumming we have two main types of servers in the us-east-1 region: web servers and worker servers. And we have totally 5 servers as follow:
- Apache
- Nginx reverse proxy
- HAProxy reverse proxy
- Gearman worker
- Celery worker

Firstly we will add a `Role` tag for each of them with the following values:
- web_apache
- web_proxy_nginx
- web_proxy_haproxy
- worker_gearman
- worker_celery

Here is a sample grouping generated by `ec2ansible`:

use1 (us-east-1)
└─── web
│ web_apache
└─── web_proxy
│ web_proxy_nginx
│ web_proxy_haproxy
└─── worker
│ worker_gearman
│ worker_celery

## Installation
`ec2ansible` is available via [pypi]( and can be installed with easy_install or [pip](
pip install ec2ansible

## Usage
1. Save [ec2ansible-sample.ini](/hehachris/ec2ansible/blob/master/ec2ansible-sample.ini) to `~/.ec2ansible` and modify it if needed
2. Specify `/usr/local/bin/ec2ansible` as the inventory for Ansible

ansible web_apache -i /usr/local/bin/ec2ansible -u ec2-user -m ping
or set in `ansible.cfg`
hostfile = /usr/local/bin/ec2ansible

Release History

This version
History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(5.3 kB) Copy SHA256 Hash SHA256
Source None May 1, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting