This playbook allows you to providion a docker-swarm on Amazon EC2 and provides a simple teardown playbook to remove the cluster. The deploy.yml playbook creates a swarm-admin instance, as the control point for the swarm, and a consul node for key/value needed for docker networking.
- Ansible 1.9+
- python >= 2.6
- boto
EVs for provisioing on EC2 are located at vars/external_vars.yml
. Docker-Machine, used to create the swarm, needs a couple extra EVs for provisioing a swarm. Add your specifcs to this file.
Running the playbook: $ ansible-playbook deploy.yml
does the following:
- Creates an instance called "Admin-Swarm" with the security group, "swarm-admin".
- Installs Docker-Engine, Docker-Machine and Docker-Compose on the Admin-Swarm node
- Creates a swarm-master node and the number of swarm-nodes specified in the EVs
- Copies the Public key to swarm-master and nodes
First, export your creds on the command line:
export AWS_ACCESS_KEY_ID='AK123'
export AWS_SECRET_ACCESS_KEY='abc123'
Run the playbook: $ ansible-playbook -i ec2.py teardown.yml
. It does the following:
- Runs ec2 dynamic inventory script and finds node with tag_role_admin
- Terminates the consul, swarm-master and swarm nodes
- Terminates Admin-Swarm instance