Reputation: 3113
I have amazon ec2 instance which i configure with Ansible and its working fine.
Now i want to put that as part of autoscaling group so that i can scale them as i want.
But my problem is i don't have any Launch configuration which sets up instance . I do all stuff by Ansible.
How can i configure auto scaling that after new instance is created then it is configured by ansible.
Upvotes: 3
Views: 3603
Reputation: 1782
It's my own Script and working fine.
https://github.com/kernelv5/AWS_Automation/tree/master/AutoScaling/AutoScalingAMIUpdate
Upvotes: -1
Reputation: 166
In my experience there are two approaches you could take here.
Create an AMI from an instance that has been fully provisioned by ansible. Then use this AMI in your launch configuration.
The other option is to use a stock AMI and have ansible provision each new host that is launched by the autoscaling group using cloud-init.
The second approach is lacking in many ways compared to the first approach in my opinion. It can take much longer to scale up when ansible needs to run every time. You also risk something going wrong during the provisioning, preventing the instance from joining the group, causing further delays. You also run the risk of there being drift between instances (depending on what you are having ansible do and if anything external changes between Autoscaling events).
If you decide to create a fully provisioned AMI for your ASG you can do it manually from an instance you already have created. However if you expect to want to rebuild the image regularly you may want to look into a tool like packer to help you create images in an automated way.
Upvotes: 9