Continuous deployment & AWS autoscaling using Ansible (+Docker ?) Continuous deployment & AWS autoscaling using Ansible (+Docker ?) docker docker

Continuous deployment & AWS autoscaling using Ansible (+Docker ?)


This question is very opinion based. But just to give you my take, I would just go with prebaking the AMIs with Ansible and then use CloudFormation to deploy your stacks with Autoscaling, Monitoring and your pre-baked AMIs. The advantage of this is that if you have most of the application stack pre-baked into the AMI autoscaling UP will happen faster.

Docker is another approach but in my opinion it adds an extra layer in your application that you may not need if you are already using EC2. Docker can be really useful if you say want to containerize in a single server. Maybe you have some extra capacity in a server and Docker will allow you to run that extra application on the same server without interfering with existing ones.

Having said that some people find Docker useful not in the sort of way to optimize the resources in a single server but rather in a sort of way that it allows you to pre-bake your applications in containers. So when you do deploy a new version or new code all you have to do is copy/replicate these docker containers across your servers, then stop the old container versions and start the new container versions.

My two cents.


A hybrid solution may give you the desired result. Store the head docker image in S3, prebake the AMI with a simple fetch and run script on start (or pass it into a stock AMI with user-data). Version control by moving the head image to your latest stable version, you could probably also implement test stacks of new versions by making the fetch script smart enough to identify which docker version to fetch based on instance tags which are configurable at instance launch.


You can also use AWS CodeDeploy with AutoScaling and your build server. We use CodeDeploy plugin for Jenkins.

This setup allows you to:

  1. perform your build in Jenkins
  2. upload to S3 bucket
  3. deploy to all the EC2s one by one which are part of the assigned AWS Auto-Scaling group.

All that with a push of a button!

Here is the AWS tutorial: Deploy an Application to an Auto Scaling Group Using AWS CodeDeploy