Prerequisites:
- IAM User with the required permission
- Boto installed (Ansible uses the Boto Python library to handle AWS management)
- haproxy installed and configured for providing the configuration of loadbalancer instance
In this scenerio we shall launch 5 instances on AWS named
- ‘ansibleweb’, four instances, which serves as the webservers on the backend
- ‘load-balancer’ one instance, which is configured as the front end load balancer
ansible-playbook --ask-vault-pass instancelaunch.yml
To do this, we will be using files ec2.py and ec2.ini which are downloaded in a folder named dynamic_inventory which serves as the inventory for our ansible configuration file. These two downloaded files are then made executable.
wget https://raw.githubusercontent.com/ansible/ansible/stable-2.9/contrib/inventory/ec2.py
wget https://raw.githubusercontent.com/ansible/ansible/stable-2.9/contrib/inventory/ec2.ini
Note: In the ec2.py file edit the first line as #!/usr/bin/python3
ansible all --list-hosts
ansible-playbook --ask-vault-pass instancelaunch.yml