Ansible Playbook to create Autoscaling group, Load balancer and website/application from Git.
This Ansible Playbook can be used to create AWS Auto Scaling Group, Load Balancer, Key Pair and Security Group and create desired number of EC2 instances with autoscaling group for the GIT website or application.
- This Playbook is uses Dynamic Inventory for managing the instances created by Autoscaling.
- We can manage the playbook easily using the variables file and Vars_prompt which will ask for desired key name, desired security group name and instance type.
- The playbook checks for chanages in Git files and update the EC2 instances one by one. The Ec2 updation process is done using second play and it uses Serial key word to run the updation one by one. This ensures that the website/application is always up and running even during updation process.
- ec2_key
- ec2_group
- ec2_elb_lb
- ec2_lc
- ec2_asg
- ec2_instance_info
- add_host
- git
- pause
- file
The variables used in this playbook are given below. You can edit these variables from file autoscaling_vars.yml ,
region: "Desired region name" #Eg: ap-south-1
zone1: "Desired zone name" #Eg: ap-south-1a
zone2: "Desired zone name" #Eg: ap-south-1b
ami: "Desired AMI" #Eg: ami-010aff33ed5991201
access_key: "your IAM access key"
secret_key: "your IAM secret key"
git_url: "Git hub URL for the desired application/website"
health_time: 25
asg_min: 2
asg_max: 2
asg_desired: 2
yum install git unzip -y
git clone https://github.com/MarkAntonyGit/Ansible-AutoScaling.git
cd Ansible-AutoScaling
vim autoscaling_vars.yml <<--------- make necessary changes
ansible-playbook playbook_ansible_autoscaling.yml
-- Play
-- Sample Website Updation
-------- ----------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------------