Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

41

description

Bryan talks about how to use Ansible and Vagrant to test and provision a Riak cluster. In case you didn't know Riak is a database based on the Dynamo paper written by Google. It aims to scale linearly in terms of size and performance. The ideal initial setup is a 5 node cluster. Bryan will show how easy it is to roll those 5 nodes out along with some tips and tricks for performance tuning. Video: http://youtu.be/WVaZxaJ9NOA DevOps Exchange Meetup Group: http://bit.ly/doxlonmeetup

Transcript of Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Page 1: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON
Page 2: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Ansible, Vagrant and Riak

Bryan Hunt

Basho Technologies

2

Page 3: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Introduction and overview

Page 4: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON
Page 5: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

• Basho CSE (Client Services Engineer)

• Support Riak and Riak CS for EMEA customers

• Linux since 90’s

• Mac since 2013

• Ansible since March 2013

• Vagrant since December 2013

• Delft aficionado

Who am I ?

Page 6: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Who are Basho?

• The creators and developers of Riak & Riak CS

• Founded in 2008 by ex-Akamai staff

• Experts in distributed systems

• Offices across the USA, EMEA & Japan

• Providing Professional Services, Customer Support

Page 7: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

• Ansible user

• Curious about Riak

• Vagrant user

• All or any of the above

Who are you?

Page 8: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

• OSX or Linux

• Vagrant

• Ansible

• Virtualbox

Requirements

Page 9: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

What is Riak? (in 2 minutes or less)

• Distributed Key-Value store

• Written in Erlang

• 2i, MapReduce, Link Walking, Solr Integration

• 2.0 out soon

Page 10: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

What is Riak?Riak is a fast, reliable, distributed and highly

available key-value store.

Bucket

key

key

key

key value

value

value

value

Page 11: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

What is Riak?

Page 12: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Alternate models for Riak local deployment

Page 13: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON
Page 14: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

make devrel NODES=3•Compiling on the host machine

•Requires C compiler

•Requires Erlang installation

•No VM required

•Supported by Makefile

•Low overhead

•Fast

Page 15: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Development OS

ClientHAProxyRiak 2

Riak 1

Riak 3

Page 16: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Riak VM per instance•Requires a lot of RAM

•Can be slower to start a cluster

•Fairly realistic

•Build on a Linux box, nicer than OSX toolchain

Page 17: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Host OS

Vagrant

Virtualbox

Linux VM

Riak 1

Linux VM

Riak 2

Linux VM

Riak 3

HAProxy

Client

Page 18: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Riak CS

•Lots more moving parts

•Minimal cluster requires 7 services on 3 machines

•Riak (storage)

•Riak CS (S3 API implementation)

•Stanchion (serialises user/bucket operations)

Page 19: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Host OS

HAProxy

HAProxy

Vagrant

Virtualbox

Linux VM 2

Riak 2

Riak CS

Linux VM 3

Riak CS

Stanchion

Riak 3

Linux VM 1

Riak 1

Riak CS

Page 20: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

(Magnus Gjoen 2011)

Page 21: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Deployment

Page 22: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Riak CS deploy (phase 1)• Install package on each machine

• Apply configuration on each machine

• Start each node

Page 23: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Linux VM 3

Riak CS 3

Stanchion

Riak 3

Linux VM 2

Riak 2 Riak CS 2

Linux VM 1

Riak 1

Riak CS 1

Installation Phase

1

2

3

12

1

2ansible-playbook

Page 24: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Riak Cluster Creation

•bin/riak-admin cluster join riak<n>@192.168.1.10

•bin/riak-admin cluster plan

•bin/riak-admin cluster commit

For each node in the ring

Page 25: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Linux VM 3

Riak 3

Linux VM 2

Riak 2

Linux VM 1

Riak 1

2 (join riak2)

1 (join riak1)

Page 26: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

What is Ansible

• Open-source

• Orchestration engine

• Configuration manager

• Software deployer

• Started in Feb 2012

Page 27: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

What made me interested in Ansible?

• Didn’t want to install a client before provisioning a box

• Didn’t like running a http server as root (http://bit.ly/webmin_goodies)

• Minimal syntax, Ansible uses YAML

• Wanted things to occur in a specific sequence

• Liked the idea of using the SSH protocol

• Liked the idea of pushing changes to servers

Page 28: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Why does Basho use the Ansible/Vagrant combo?

• Simple to configure and provision

• Reduces Amazon expenditure

• Quickly deploy new versions onto local VM

• Reproduce strange customer configurations

• Provision Virtualbox images for training/demo’s

Page 29: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Ansible Roles

•Self contained reusable modules

•Can have dependencies upon other roles

•Similar to Chef recipes or Puppet modules

•Stored at https://galaxy.ansible.com/

Page 30: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Ansible Riak Roles

•Created by James Martin (now at Ansible)

•http://bit.ly/galaxy_basho

•Actively maintained and developed by Basho

•Volunteers?

Page 31: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Ansible Modules

shell mount

yum service

riakapt

Ansible Riak Roles

riakcs

riakcs-packages

riak-common

riak stanchion

depends

depends depends depends

Page 32: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Ansible

Inventory

reads

reads

provisions

PlaybooksPlaybooks

Playbooks

host1host1host1host1

Ansible basic workings

Page 33: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Ansible minimal example

Page 34: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Ansible example using Role

Page 35: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Walkthrough

Building a Riak CS cluster

Page 36: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Structure of example apps

•Vagrantfile

•form_cluster.yml

•hosts

•roles

•roles.txt

•setup_riak.yml

Page 37: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Vagrant file ensuring roles

Page 38: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON
Page 39: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON
Page 40: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Future goals

• Create a reusable set of base boxes

• Create a Vagrant script for each release

• Create new roles for Ansible 2.0

Page 41: Ansible, Vagrant and Riak- Bryan Hunt at #DOXLON

Try it out!

• http://bit.ly/ansible-riak-example

• http://bit.ly/ansible-riakcs-example

• https://galaxy.ansible.com

• https://www.vagrantup.com