- Install and setup Ansible Server
- Install boto (version>=2.24.0)
- IAM Programmatic access user in AWS with EC2 access.
- Get the ec2.ini and ec2.py file.
To get help on dynamic inventory please follow Ansible Official Document
-
Create IAM Programmatic access user with EC2 full access on AWS console
IAM
-->users
-->Add user
-
Export IAM user credentials on Ansible server.
export AWS_ACCESS_KEY_ID='XXXXX' export AWS_SECRET_ACCESS_KEY='XXXXX'
-
To export keys permanently make sure that you have installed pip and boto and add credentials ~/.boto 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 ap-south-1a AZ
ansible -i ec2.py ap-south-1a --list-hosts