SlideShare a Scribd company logo
Ansible fest Presentation slides
Who are we?
Jim Vanns
Aaron Carey
Production Engineers at ILM London
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
Step 1:
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
Concise Ansible Dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get -y install python python-pip python-dev
RUN pip install -U ansible==1.9.4 boto apache-libcloud httplib2
ADD ansible.cfg /etc/ansible/ansible.cfg
ADD ec2.py /etc/ansible/ec2.py
ADD ec2.ini /etc/ansible/ec2.ini
ADD gce.py /etc/ansible/gce.py
ADD gce.ini /etc/ansible/gce.ini
WORKDIR /srv/ansible
ADD ansible .
Step 2: Deploy cloud hosts
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!
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
Cloud Start Role
---
- include: "{{ cloud_provider }}.yml"
Cloud Start Role
- name: Launch instance
ec2:
key_name: "{{ key_name }}"
instance_type: "{{ instance_type }}"
image: "{{ image }}"
wait: yes
vpc_subnet_id: "{{ vpc_subnet_id }}"
group_id: "{{ security_group_id }}"
region: "{{ region }}"
instance_tags:
ansible: base
count: "{{ count }}"
assign_public_ip: "{{ public_ip }}"
register: ec2
- name: Add instances to launched group
add_host: hostname={{ item.private_ip }} groupname=launched_cloud_default
with_items: ec2.instances
- name: Add instances to parameter group
add_host: hostname={{ item.private_ip }} groupname={{ launch_group }}
with_items: ec2.instances
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
Taking it further...
Parallelise the provisioning
Take advantage of host groups where you can
Use ansible environment variables to target hosts and groups
Ansible fest Presentation slides
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]
Step 3: Mesos
Our Mesos Architecture
Zookeeper*
Mesos Master*
Mesos Agents*
Consul
Marathon (The scheduler’s scheduler)
Mesos-consul
Deploying Zookeeper
- name: Set zookeeper ID facts
gather_facts: True
hosts: tag_zookeeper_server_{{ consul_domain }}
user: ilm-user
tasks:
- set_fact: zkid={{ item.0 | int + 1 }}
when: hostvars[item.1]['ansible_hostname'] == ansible_hostname
with_indexed_items: groups['tag_zookeeper_server_{{ consul_domain }}']
- name: Apply zookeeper role
gather_facts: True
hosts: tag_zookeeper_server_{{ consul_domain }}
sudo: True
user: ilm-user
roles:
- zookeeper
Zookeeper Role
- name: Register zookeeper name with consul
uri: >
url=http://127.0.0.1:8500/v1/agent/service/register
HEADER_Content-Type=application/json
method=PUT
body_format=json
body='{
"Name": "zookeeper",
"Tags": [
"zookeeper",
"{{ zkid }}"
],
"Port": 2181
}'
- name: Register individual zookeeper node with consul
uri: >
url=http://127.0.0.1:8500/v1/agent/service/register
method=PUT
body_format=json
HEADER_Content-Type=application/json
body='{
"Name": "zookeeper-{{ zkid }}",
"Tags": [
"zookeeper",
"{{ zkid }}"
],
"Port": 2181
}'
Zookeeper Role
- name: Run zookeeper container
docker:
name: zookeeper
image: "mesoscloud/zookeeper:3.4.6-ubuntu-14.04"
state: started
net: host
restart_policy: always
volumes:
- /mnt/data/log:/tmp/zookeeper
env:
MYID: "{{ zkid }}"
SERVERS: "zookeeper-1,zookeeper-2,zookeeper-3"
Mesos Containers
- name: Run mesos-master container
docker:
name: mesos-master
image: "mesosphere/mesos-master:{{ img_version }}"
state: started
net: host
restart_policy: always
volumes:
- /mnt/data/log:/var/log
env:
MESOS_ZK: "zk://zookeeper:2181/mesos"
MESOS_CLUSTER: "{{ cluster_name }}"
MESOS_QUORUM: "1"
MESOS_LOG_DIR: "/var/log/mesos"
MESOS_WORK_DIR: "/var/lib/mesos"
MESOS_HOSTNAME: "mesos-master"
Submit tasks to Marathon
- name: Launch docker-registry
hosts: "tag_build_docker_{{ consul_domain }}"
gather_facts: False
tasks:
- name: Submit docker-registry job to marathon
uri: >
url=http://marathon:8080/v2/apps
HEADER_Content-Type=application/json
method=POST
status_code=200,201,409
body_format=json
body='{
"args": [ ],
"container": {
"type": "DOCKER",
"docker": {
"network": "HOST",
"image": "registry:2.2",
"forcePullImage": true,
"parameters":
[
{ "key": "env", "value": "REGISTRY_STORAGE=s3" }
]
}
},
"id": "docker-registry",
"instances": 1,
"cpus": 2,
"mem": 4096
}'
Done

More Related Content

What's hot (20)

PDF
Ansible - Swiss Army Knife Orchestration
bcoca
 
PDF
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
PDF
Configuration Management in Ansible
Bangladesh Network Operators Group
 
PPTX
Best practices for ansible
George Shuklin
 
PPTX
Introduction to Ansible
CoreStack
 
ODP
Bootstrap your Cloud Infrastructure using puppet and hashicorp stack
Bram Vogelaar
 
PDF
Ansible - Introduction
Stephane Manciot
 
PDF
IT Automation with Ansible
Rayed Alrashed
 
PPTX
Vagrant, Ansible, and OpenStack on your laptop
Lorin Hochstein
 
PPT
Ansible presentation
John Lynch
 
PPTX
Introduction to ansible
Omid Vahdaty
 
PDF
Ansible leveraging 2.0
bcoca
 
PDF
Ansible for beginners ...?
shirou wakayama
 
PDF
Hacking ansible
bcoca
 
PDF
Fabric workshop(1) - (MOSG)
Soshi Nemoto
 
PDF
More tips n tricks
bcoca
 
PDF
Testing your infrastructure with litmus
Bram Vogelaar
 
PDF
Automation with ansible
Khizer Naeem
 
PDF
Puppet and the HashiStack
Bram Vogelaar
 
PPTX
Ansible presentation
Kumar Y
 
Ansible - Swiss Army Knife Orchestration
bcoca
 
Ansible is the simplest way to automate. MoldCamp, 2015
Alex S
 
Configuration Management in Ansible
Bangladesh Network Operators Group
 
Best practices for ansible
George Shuklin
 
Introduction to Ansible
CoreStack
 
Bootstrap your Cloud Infrastructure using puppet and hashicorp stack
Bram Vogelaar
 
Ansible - Introduction
Stephane Manciot
 
IT Automation with Ansible
Rayed Alrashed
 
Vagrant, Ansible, and OpenStack on your laptop
Lorin Hochstein
 
Ansible presentation
John Lynch
 
Introduction to ansible
Omid Vahdaty
 
Ansible leveraging 2.0
bcoca
 
Ansible for beginners ...?
shirou wakayama
 
Hacking ansible
bcoca
 
Fabric workshop(1) - (MOSG)
Soshi Nemoto
 
More tips n tricks
bcoca
 
Testing your infrastructure with litmus
Bram Vogelaar
 
Automation with ansible
Khizer Naeem
 
Puppet and the HashiStack
Bram Vogelaar
 
Ansible presentation
Kumar Y
 

Viewers also liked (11)

PPTX
Cyansible
Alan Norton
 
PPTX
ILM - Pipeline in the cloud
Aaron Carey
 
PPTX
Dynamic Scheduling - Federated clusters in mesos
Aaron Carey
 
PDF
Ansible 2 and Ansible Galaxy 2
Jeff Geerling
 
PDF
Ansible + Drupal: A Fortuitous DevOps Match
Jeff Geerling
 
PPTX
SIGGRAPH Presentation 2016 Slides
Aaron Carey
 
PDF
DevOps for Humans - Ansible for Drupal Deployment Victory!
Jeff Geerling
 
PPTX
Ansible presentation
Suresh Kumar
 
PDF
Ansible
Vishal Yadav
 
PDF
V2 and beyond
jimi-c
 
PDF
AnsibleBuilding a Docker-ized Microservice In Node, Using Ansible - AnsibleF...
Irakli Nadareishvili
 
Cyansible
Alan Norton
 
ILM - Pipeline in the cloud
Aaron Carey
 
Dynamic Scheduling - Federated clusters in mesos
Aaron Carey
 
Ansible 2 and Ansible Galaxy 2
Jeff Geerling
 
Ansible + Drupal: A Fortuitous DevOps Match
Jeff Geerling
 
SIGGRAPH Presentation 2016 Slides
Aaron Carey
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
Jeff Geerling
 
Ansible presentation
Suresh Kumar
 
Ansible
Vishal Yadav
 
V2 and beyond
jimi-c
 
AnsibleBuilding a Docker-ized Microservice In Node, Using Ansible - AnsibleF...
Irakli Nadareishvili
 
Ad

Similar to Ansible fest Presentation slides (20)

PDF
Managing Terraform Module Versioning and Dependencies
Nebulaworks
 
PPTX
Dive into DevOps | March, Building with Terraform, Volodymyr Tsap
Provectus
 
PPTX
Automating aws infrastructure and code deployments using Ansible @WebEngage
Vishal Uderani
 
PDF
AWS DevOps - Terraform, Docker, HashiCorp Vault
Grzegorz Adamowicz
 
PDF
Ansible party in the [Google] clouds
Esther Lozano
 
PDF
Deploying Plone on AWS
T. Kim Nguyen
 
PDF
To AWS with Ansible
☁️ Gerben Geijteman
 
PDF
Przemysław Iwanek - ABC AWS, budowanie infrastruktury przy pomocy Terraform
jzielinski_pl
 
PDF
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila
 
PPTX
An intro to Docker, Terraform, and Amazon ECS
Yevgeniy Brikman
 
PDF
Ansible with AWS
Allan Denot
 
PDF
Ansible inside
Ideato
 
PPTX
Configuring Your First Hadoop Cluster On EC2
benjaminwootton
 
PDF
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
PDF
Scaling and Embracing Failure: Clustering Docker with Mesos
Rob Gulewich
 
PDF
Running Open Source Platforms on AWS (November 2016)
Julien SIMON
 
PDF
Ansible at work
Bas Meijer
 
PDF
2013 PyCon SG - Building your cloud infrastructure with Python
George Goh
 
PPTX
Deep Dive on Amazon Elastic Container Service (ECS) I AWS Dev Day 2018
AWS Germany
 
PDF
Getting Started with ECS: An Easy Way to Run Docker Containers - AWS Summit A...
Tung Nguyen
 
Managing Terraform Module Versioning and Dependencies
Nebulaworks
 
Dive into DevOps | March, Building with Terraform, Volodymyr Tsap
Provectus
 
Automating aws infrastructure and code deployments using Ansible @WebEngage
Vishal Uderani
 
AWS DevOps - Terraform, Docker, HashiCorp Vault
Grzegorz Adamowicz
 
Ansible party in the [Google] clouds
Esther Lozano
 
Deploying Plone on AWS
T. Kim Nguyen
 
To AWS with Ansible
☁️ Gerben Geijteman
 
Przemysław Iwanek - ABC AWS, budowanie infrastruktury przy pomocy Terraform
jzielinski_pl
 
Artem Zhurbila - docker clusters (solit 2015)
Artem Zhurbila
 
An intro to Docker, Terraform, and Amazon ECS
Yevgeniy Brikman
 
Ansible with AWS
Allan Denot
 
Ansible inside
Ideato
 
Configuring Your First Hadoop Cluster On EC2
benjaminwootton
 
Automated Deployment and Configuration Engines. Ansible
Alberto Molina Coballes
 
Scaling and Embracing Failure: Clustering Docker with Mesos
Rob Gulewich
 
Running Open Source Platforms on AWS (November 2016)
Julien SIMON
 
Ansible at work
Bas Meijer
 
2013 PyCon SG - Building your cloud infrastructure with Python
George Goh
 
Deep Dive on Amazon Elastic Container Service (ECS) I AWS Dev Day 2018
AWS Germany
 
Getting Started with ECS: An Easy Way to Run Docker Containers - AWS Summit A...
Tung Nguyen
 
Ad

Recently uploaded (20)

PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

Ansible fest Presentation slides

  • 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
  • 6. Concise Ansible Dockerfile FROM ubuntu:14.04 RUN apt-get update && apt-get -y install python python-pip python-dev RUN pip install -U ansible==1.9.4 boto apache-libcloud httplib2 ADD ansible.cfg /etc/ansible/ansible.cfg ADD ec2.py /etc/ansible/ec2.py ADD ec2.ini /etc/ansible/ec2.ini ADD gce.py /etc/ansible/gce.py ADD gce.ini /etc/ansible/gce.ini WORKDIR /srv/ansible ADD ansible .
  • 7. Step 2: Deploy cloud hosts
  • 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
  • 10. Cloud Start Role --- - include: "{{ cloud_provider }}.yml"
  • 11. Cloud Start Role - name: Launch instance ec2: key_name: "{{ key_name }}" instance_type: "{{ instance_type }}" image: "{{ image }}" wait: yes vpc_subnet_id: "{{ vpc_subnet_id }}" group_id: "{{ security_group_id }}" region: "{{ region }}" instance_tags: ansible: base count: "{{ count }}" assign_public_ip: "{{ public_ip }}" register: ec2 - name: Add instances to launched group add_host: hostname={{ item.private_ip }} groupname=launched_cloud_default with_items: ec2.instances - name: Add instances to parameter group add_host: hostname={{ item.private_ip }} groupname={{ launch_group }} with_items: ec2.instances
  • 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
  • 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]
  • 17. Our Mesos Architecture Zookeeper* Mesos Master* Mesos Agents* Consul Marathon (The scheduler’s scheduler) Mesos-consul
  • 18. Deploying Zookeeper - name: Set zookeeper ID facts gather_facts: True hosts: tag_zookeeper_server_{{ consul_domain }} user: ilm-user tasks: - set_fact: zkid={{ item.0 | int + 1 }} when: hostvars[item.1]['ansible_hostname'] == ansible_hostname with_indexed_items: groups['tag_zookeeper_server_{{ consul_domain }}'] - name: Apply zookeeper role gather_facts: True hosts: tag_zookeeper_server_{{ consul_domain }} sudo: True user: ilm-user roles: - zookeeper
  • 19. Zookeeper Role - name: Register zookeeper name with consul uri: > url=http://127.0.0.1:8500/v1/agent/service/register HEADER_Content-Type=application/json method=PUT body_format=json body='{ "Name": "zookeeper", "Tags": [ "zookeeper", "{{ zkid }}" ], "Port": 2181 }' - name: Register individual zookeeper node with consul uri: > url=http://127.0.0.1:8500/v1/agent/service/register method=PUT body_format=json HEADER_Content-Type=application/json body='{ "Name": "zookeeper-{{ zkid }}", "Tags": [ "zookeeper", "{{ zkid }}" ], "Port": 2181 }'
  • 20. Zookeeper Role - name: Run zookeeper container docker: name: zookeeper image: "mesoscloud/zookeeper:3.4.6-ubuntu-14.04" state: started net: host restart_policy: always volumes: - /mnt/data/log:/tmp/zookeeper env: MYID: "{{ zkid }}" SERVERS: "zookeeper-1,zookeeper-2,zookeeper-3"
  • 21. Mesos Containers - name: Run mesos-master container docker: name: mesos-master image: "mesosphere/mesos-master:{{ img_version }}" state: started net: host restart_policy: always volumes: - /mnt/data/log:/var/log env: MESOS_ZK: "zk://zookeeper:2181/mesos" MESOS_CLUSTER: "{{ cluster_name }}" MESOS_QUORUM: "1" MESOS_LOG_DIR: "/var/log/mesos" MESOS_WORK_DIR: "/var/lib/mesos" MESOS_HOSTNAME: "mesos-master"
  • 22. Submit tasks to Marathon - name: Launch docker-registry hosts: "tag_build_docker_{{ consul_domain }}" gather_facts: False tasks: - name: Submit docker-registry job to marathon uri: > url=http://marathon:8080/v2/apps HEADER_Content-Type=application/json method=POST status_code=200,201,409 body_format=json body='{ "args": [ ], "container": { "type": "DOCKER", "docker": { "network": "HOST", "image": "registry:2.2", "forcePullImage": true, "parameters": [ { "key": "env", "value": "REGISTRY_STORAGE=s3" } ] } }, "id": "docker-registry", "instances": 1, "cpus": 2, "mem": 4096 }'
  • 23. Done