Ansible Playbooks for setting up cloud services such as Mesos, Docker and Kubernetes.
Most of the stuff for Marathon, Mesos and Zookeeper is copied from the AnsibleShipyard repositories with few or no tweaks.
To try it out do:
-
Configure
~/.botoas described in Boto Config:[Credentials] aws_access_key_id = <your_access_key_here> aws_secret_access_key = <your_secret_key_here> -
Copy the
ec2.inifile to/etc/ansible/ec2.ini. -
Add your
*.pemfile to thessh-agent:$ ssh-agent bash $ ssh-add ~/.ssh/keypair.pem -
The AWS Command Line Interface must be installed, configured and the
awsexecutable be on the path. Used (until Ansible 2.2 is released) to create the NAT gateway. -
Run the playbook as
ansible-playbook -i ec2.py main.ymlto set up the EC2 instances. -
Run the playbook as
ansible-playbook -i ec2.py provision_cluster.ymlto provision the instances with Mesos, Docker, Zookeeper etc.
The following environment varibles can be configured for Ansible lookup
- AWS_EC2_KEY_PAIR: the name of the key pair to use when provisioning the cluster (EC2 instances etc.).
- AWS_EC2_LB_CERT: the
arnresource for the AWS ELB certificate. - AWS_S3_ELB_LOGS_BUCKET_NAME: the name of the S3 bucket where to store the ELB logs.
- DCOS_CONTROLLER_INSTALL_DEMOS:
true- install demo(s) (default),false- skip demo installation.
- DCOS_CONTROLLER_INSTALL_DEMO_SD_AND_LB_NGINX:
true- install demo setting up Nginx as described in Service discovery and load balancing with DCOS and marathon-lb: Part 1. - DCOS_CONTROLLER_INSTALL_TUTUM_HELLO_WORLD:
true- install Tutum hello-world demo.
To run a Docker container on Marathon:
docker.json
{
"id": "tutum-hello-world",
"cpus": 0.2,
"mem": 20.0,
"instances": 1,
"container": {
"type": "DOCKER",
"docker": {
"image": "tutum/hello-world",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 80, "hostPort": 0, "servicePort": 0, "protocol": "tcp" }
]
}
}
}
Post the container defintion to Marathon: curl -X POST localhost:8080/v2/apps -d @Desktop\docker.json -H "Content-type: application/json".