Extendable Python module for ansible EC2 inventories
Project description
Ansible EC2 inventory
=====================
This Python module is based on the [original Ansible EC2 inventory
script](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py)
that is linked in the [Ansible
docs](http://docs.ansible.com/ansible/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script).
The Python module in this repo fixes a few issues by being
- installable via `pip` / PyPi: no need to place code from the Ansible
repo in your inventory.
- extendable for your needs: the class `Ec2Inventory` can be used as a
base class for customizations.
Installation
------------
pip install ansible-ec2-inventory
Usage
-----
### As a script
ansible-ec2-inventory --config ec2.ini
*Note:* if you want to provide a boto profile, prefix the command with
`AWS_PROFILE=myprofile`.
### As a Python module
Example:
~~~~ {.python}
from ansible_ec2_inventory import Ec2Inventory
import json
def main():
# get path of ec2.ini
path = os.path.dirname(os.path.realpath(__file__))
# get inventory
ec2inventory = Ec2Inventory(configfile=path + '/ec2.ini')
data = ec2inventory.get_inventory()
# print json
print(json.dumps(data, sort_keys=True, indent=2))
if __name__ == '__main__':
main()
~~~~
=====================
This Python module is based on the [original Ansible EC2 inventory
script](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py)
that is linked in the [Ansible
docs](http://docs.ansible.com/ansible/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script).
The Python module in this repo fixes a few issues by being
- installable via `pip` / PyPi: no need to place code from the Ansible
repo in your inventory.
- extendable for your needs: the class `Ec2Inventory` can be used as a
base class for customizations.
Installation
------------
pip install ansible-ec2-inventory
Usage
-----
### As a script
ansible-ec2-inventory --config ec2.ini
*Note:* if you want to provide a boto profile, prefix the command with
`AWS_PROFILE=myprofile`.
### As a Python module
Example:
~~~~ {.python}
from ansible_ec2_inventory import Ec2Inventory
import json
def main():
# get path of ec2.ini
path = os.path.dirname(os.path.realpath(__file__))
# get inventory
ec2inventory = Ec2Inventory(configfile=path + '/ec2.ini')
data = ec2inventory.get_inventory()
# print json
print(json.dumps(data, sort_keys=True, indent=2))
if __name__ == '__main__':
main()
~~~~
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for ansible-ec2-inventory-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e0a2f9a17e2aa932e47c75c90c007de2313ef36f8d18e0bf4b77e83a54e6245 |
|
MD5 | aca0ef2d6bf87f1965f99b390c874695 |
|
BLAKE2b-256 | ef30bf5ebcfb15d0e5b26a6dbfb57bd04e7bd1d4154c8cf29e3bdbda2bf9fa08 |