2. Who are we?
Jim Vanns
Aaron Carey
Production Engineers at ILM London
3. What we’re covering
● Deploying a Mesos cluster in the cloud using
Ansible
● Running services on Mesos using Ansible
● Differences between AWS/GCE modules
● Tips we’ve learnt along the way
5. Ansible Dockerfile (example follows)
Fix the ansible version
Install a custom dynamic inventory file (or two)
Consider your credentials and security
Install (bake-in a ‘git archive’) your playbooks
8. Requirements
Cloud Agnostic (Work with both AWS and GCE)
Split provisioning and bootstrapping into roles
Need a way to determine which are new hosts
Need a way to group hosts during and after provisioning
Tagging!
9. Cloud Start Role
# Launch the primary (master/leader) nameserver
- name: Launch a bootstrap consul server
hosts: localhost
connection: local
gather_facts: False
vars:
cloud_provider: ec2
count: 3
service_name: Consul
launch_group: tag_consul_server_{{ consul_domain }}
tags:
consul: server_{{ consul_domain }}
roles:
- cloud_start
12. Cloud Start Role
- name: Tag instances
ec2_tag: resource={{item.id}} state=present region={{region}}
with_items: ec2.instances
args:
tags:
"{{ tags }}"
- name: Wait for sshd to come up
wait_for: host={{ item.private_ip }}
port=22
state=started
delay=60
timeout=300
connect_timeout=2
with_items: ec2.instances
13. Taking it further...
Parallelise the provisioning
Take advantage of host groups where you can
Use ansible environment variables to target hosts and groups
14.
15. AWS vs GCE
AWS - Tags are key-value pairs
GCE - Tags are string labels, Metadata are key-value pairs
We used a custom (slightly modified) GCE inventorytags = node.extra['tags']
for t in tags:
tag = 'tag_%s' % t
if groups.has_key(tag): groups[tag].append(name)
else: groups[tag] = [name]
if 'items' in node.extra['metadata']:
for item in node.extra['metadata']['items']:
tag = 'tag_%s_%s' % (item['key'], item['value'])
if groups.has_key(tag): groups[tag].append(name)
else: groups[tag] = [name]