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