Slide 1

Slide 1 text

knowledge sharing talks

Slide 2

Slide 2 text

Distributing Uniform Development Environments with Vagrant

Slide 3

Slide 3 text

@yamilurbina DevOps at CodeRoad

Slide 4

Slide 4 text

The Problem(s)

Slide 5

Slide 5 text

First day at new team A new and wild developer appears! First task: install the app locally “Use the documentation they said, it will be easy, they said” What about this new technology I know nothing about?

Slide 6

Slide 6 text

Learning the insides of a new app can be a pain in the @$$. Problem #1

Slide 7

Slide 7 text

“Yeah, just play with it, but don’t modify anything just yet”

Slide 8

Slide 8 text

A new developer is allowed to see, but nothing more. Problem #2

Slide 9

Slide 9 text

Finally, the app is installed! but… • New dev: “hey, feature X is not working on my machine” • Older dev: “Oh, that version is not compatible with the app. Install v1.4.5” • Elder dev: “Also, your configuration file is outdated, we changed X setting months ago”

Slide 10

Slide 10 text

Configuration and versions become problematic. Problem #3

Slide 11

Slide 11 text

How do we solve this?

Slide 12

Slide 12 text

“well, developers should work on the same OS and with the same tools” an failed solution

Slide 13

Slide 13 text

The right tools for the developer varies from person to person (and even OS) Truth #1

Slide 14

Slide 14 text

“ok then, let’s virtualise every development environment” getting closer

Slide 15

Slide 15 text

The virtualisation ecosystem is diverse • Several solutions, different ways of managing settings, drives and memory • And that leads to even more differences between dev environments • They should be identical

Slide 16

Slide 16 text

“so we need a uniform virtualisation environment, that uses the same configuration to run an app”

Slide 17

Slide 17 text

WHAT IF I TELL YOU… YOU CAN RUN YOU APP IN A PROPERLY CONFIGURED DEV ENVIRONMENT?

Slide 18

Slide 18 text

The Solution

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Windows, Linux and OS X Vagrant acts as an intermediary between your virtualisation software and you Use you command line to start, stop and reboot your virtual machine Don’t worry about settings, Vagrant configures them for you

Slide 21

Slide 21 text

Packaged .box files Are virtual machines already configured for your app They have the same software as production Same configuration and settings Redistributable; edit it and package it again Lighter than other VMs (less than 4GB) 21

Slide 22

Slide 22 text

Use the same OS as production Using Ubuntu Server on production? Vagrant has the same machine version for you Install your app, dependencies and modify the proper settings there Package your own Vagrant machine and distribute it over HTTP

Slide 23

Slide 23 text

A Vagrantfile to rule them all A single configuration file manages memory, folders and ports Include it on your source tree to distribute it No need to open GUIs

Slide 24

Slide 24 text

Vagrant machines are indestructible Vagrant boots a VM copy that can be destroyed and rebuilt in a matter of minutes Perfect for noobies and new developers Also for experimenting, editing and pretty much doing whatever you want with it

Slide 25

Slide 25 text

What about my files? Sync folders from host to vm Use rsync to detect changes Or use scp on Windows Exclude files and folders (kind of like git)

Slide 26

Slide 26 text

Tell me more Imports a packaged .box file from the interwebz Vagrant creates a copy of the .box file Opens configured ports and local connections Starts the virtual machine That’s it

Slide 27

Slide 27 text

Open ports and connections • Using HTTP? no problem, map port 80 from vm to the local machine • And access it via localhost • It uses your machine’s local internet connection

Slide 28

Slide 28 text

Can I share my work? • Use your internal IP if you want to show it locally • Or, use vagrant share to create a public server • Anyone gets to see what you are working on

Slide 29

Slide 29 text

Some downsides • While RAM consumption is low, it can affect performance on not so new machines • Updating .box files is a manual task • If mismanaged, the .box size can become pretty large (>20GB)

Slide 30

Slide 30 text

Demo time you’ll see what I’m talking about

Slide 31

Slide 31 text

Instead of a non- productive new developer, we can get this:

Slide 32

Slide 32 text

First day at new team A new and wild developer appears! First task: boot Vagrant and experiment with the app New dev: “Oh, so that’s how it works!” Happiness :)

Slide 33

Slide 33 text

First week at new team New developer is now familiar with the app They can start making small changes with confidence Or big experiments without fear

Slide 34

Slide 34 text

And the new developer starts being productive sooner than expected

Slide 35

Slide 35 text

Questions?

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

@yamilurbina DevOps at CodeRoad

Slide 38

Slide 38 text

knowledge sharing talks