Ansible Dynamic Inventory For AWS Resources

0 68
  1. Make sure you have Ansible on Amazon Linux 2 AMI, here the reference link
  2. Install PIP using:
    sudo pip install boto -y
  3. Make sure you have IAM role created with EC2fullAccess policy and attached to your ansible EC2 instance
  4. Download these file
    1. EC2.py
    2. EC2.ini
  5. Add executing permissions to ec2.py script
    chmod 755 ec2.py
  6. Test the script
    ./ec2.py --list
  7. List out servers which are running on us-east-1 region:
    ansible -i ec2.py us-east-1 --list-hosts
  8. Similarly, you can get details based on EC2 tags

Leave A Reply

Your email address will not be published.