Code Monkey home page Code Monkey logo

ansible-dynamic-inventory's Introduction

Python Script to Generate Dynamic Inventory Of AWS Ec2-instances.

This Python script will generate inventory for ansible based on Ec2 tags.

Script Requirements

  • python3
  • boto3
  • Latest Version of ansible

HowTo Run This Script.

  • Configure awscli with user credentials.
  • While Creating ec2 instance add a Tag with Key called "Ansible" and colon separated values as group name.

Eg: Key=Ansible Value=centos:webserver

The above tag will put that instance under two groups, centos and webserver

  • Accessing Dynamic Groups From ansible.
[management-node]$ ansible -i inventory.py  centos -m ping
[management-node]$ ansible -i inventory.py  webserver -m ping

Customisation Options

This section will cover all the variable and their usage in the script.


  • REGIONS

This option controls the list of regions that you want to scan for the dynamic inventory. By default the script will only works within the 'us-east-1' region.

Adding 'us-east-1' and 'us-east-2' for scanning.

REGIONS = ['us-east-1', 'us-east-2']


  • SCAN_ALL_REGION

If you enable this option then the script will scan for instances in all aws regions. If this options is enabled it will ignore the REGIONS value. By default this option will be set to false.

Enabling All Region Scaning.

SCAN_ALL_REGION = True


  • AWS Credentials

By default script will fetch aws credentials from .aws/credentials file. you can override this option by setting

ACCESS_KEY = 'YourAccessKey'  
SECRET_KEY = 'YourSecretKey'

ansible-dynamic-inventory's People

Contributors

fujiclado avatar

Stargazers

Juan David Bolaños avatar  avatar

Watchers

 avatar Nithin C Raju avatar

Forkers

muralikshetty

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.