acandid.ec2_inventory

Ansible Role: ec2_inventory

=========

A simple Ansible role creates the inventory file using AWS regions and tags.

  • Create inventory file;

Requirements

Install: python-boto
python-boto3
pip install boto3

Attention

If the public DNS is dynamic, the ansible_host option is only filled when the server is started.

Create inventory groups using tags modify as you use them in your environment.

In my case I used it as follows in ec2_instances_facts.yml.

filters:
  "tag:Environment": Production


filters:
  "tag:Environment": Homologation


filters:
  "tag:Environment": Development

Role Variables

Variables below are required

Variable File Comments
ec2_inventory_region: vars/main.yml Inform AWS Region
aws_access_key vars/credentials.yml Inform AWS Access Key
aws_secret_key vars/credentials.yml Inform AWS Secret Key
ec2_inventory_path defaults/main.yml Inform path where the inventory will be saved
ec2_inventory_name defaults/main.yml Inform inventory name
ec2_inventory_path_key defaults/main.yml Inform the path that is the key

Dependencies

Example Playbook


  • hosts: localhost

    gather_facts: no

    roles:

    • /path/ec2_inventory

...

Official documentation of the modules of this role

https://docs.ansible.com/ansible/latest/modules/ec2_instance_info_module.html https://docs.ansible.com/ansible/latest/modules/debug_module.html https://docs.ansible.com/ansible/latest/modules/template_module.html

Contributing

Issues, feature requests, ideas are appreciated and can be posted in the Issues section.

Author Information

LinkedIn: https://br.linkedin.com/in/almircandido

About

Create the inventory file using AWS regions and tags.

Install
ansible-galaxy install acandid.ec2_inventory
GitHub repository
License
Unknown
Downloads
127