Bummer! This is just a preview. You need to be signed in with a Pro account to view the entire video.
Start a free Basic trial
to watch this video
Personal Cloud Development with Vagrant
49:20 with Tim AmblerYou're part of a development team that's creating a complex web app. The back-end infrastructure runs on a combination of Node.JS, MongoDB, Redis, and Memcached. There's even some MySQL thrown in for good measure. Oh - and don't forget about the CRON jobs that trigger various routine maintenance tasks (removing temporary files, sending queued emails, etc...). You're on OS X. Steve is running Windows 8. Bill is running Debian, but don't worry about Bill - he can't do anything right now because he's busy re-compiling his kernel because.... oh, forget it. The point is this - how can a team of developers, each with their own unique environments, be expected to work together effectively when the underlying architecture that runs the thing they're working on is complex, or even unsettled? With Vagrant - that's how. To gain the most benefit from this talk, attendees should have a basic familiarity with the Linux command line.
-
0:00
[MUSIC]
-
0:13
As I just said, my name is Tim Ambler.
-
0:14
Over the course of this talk,
-
0:15
I'm gonna be taking a look at one of my favorite subjects, which is Vagrant.
-
0:20
The idea that technology changes quickly is a pretty well worn aphorism, but
-
0:25
it's well worn because it's true.
-
0:28
And over the course of the past couple days we've been exposed to a lot of
-
0:31
that changing technology.
-
0:34
Concepts such as full stack JavaScript node, CSS3 animations, Angular Directives.
-
0:41
In the grand scheme of things,
-
0:42
these are pretty bleeding edge, but if I had to put together a list of
-
0:46
the top innovations that have occurred in the last few years in web development,
-
0:50
Vagrant would definitely be at the top of that list for me.
-
0:56
So a bit of background.
-
0:57
My first exposure to Vagrant was around early 2012.
-
1:01
I was serving as one of two lead developers for
-
1:03
a local startup here in Nashville.
-
1:06
At the time, the company's onboarding process for
-
1:08
new developers looked a little something like this.
-
1:14
The steps required to set up your computer so
-
1:16
you could actually start contributing were pretty tedious.
-
1:19
For starters, you had to get Apache installed, then you had to
-
1:22
install a specific version of PHP along with a specific version from MySQL and a,
-
1:27
a, a whole host of other supporting tools that I won't bother getting onto.
-
1:31
Then you go and you import the latest version of the database that happened to
-
1:34
be floating around the office.
-
1:36
To top it all off,
-
1:37
the process of completing all of these steps was dramatically different
-
1:41
depending on whether you have to be on OSX, Windows, or Linux.
-
1:46
It's also worth noting that at this point our back-end infrastructure really wasn't
-
1:50
all that complicated compared to some setups that I've seen.
-
1:53
It would eventually go on to become much more complex as we started
-
1:56
distributing work across multiple servers, but that said this relatively simple
-
2:02
setup was giving us enough headaches during the onboarding process as is.
-
2:05
It was not about to scale.
-
2:07
[BLANK_AUDIO]
-
2:10
When a new developer joined the team, inevitably, what you would see was
-
2:13
this multiple day long process, that looked a lot like a game of telephone.
-
2:17
Where the last person to join the team was forced to impart the knowledge that was
-
2:21
passed on to him by the last person to join, and on and on down the line.
-
2:27
And all of this was just to get you started.
-
2:30
So heaven forbid that something significant actually change,
-
2:32
which it frequently did, and you had to rinse and repeat all over again.
-
2:38
Eventually, after watching one too many people jump through these hoops,
-
2:41
we got the bright idea that there must be a better way.
-
2:44
And sure enough there was.
-
2:45
And for us that better way was Vagrant.
-
2:50
So what is Vagrant anyway?
-
2:52
Well regardless of whether you actually use these tools on a day to
-
2:55
day basis I'm sure that everyone here has at least a passing familiarity with
-
3:01
virtualization products such as VMWare, Parallels, and Virtualbox.
-
3:07
These products are what make it possible for
-
3:09
us to run the latest copy of Windows 8 on OS 10 or vice versa.
-
3:14
These tools have been around for some time, this is nothing new.
-
3:17
But the big innovation that Vagrant brought to the table was the notion that,
-
3:20
hey, wouldn't it be really cool if someone created a utility that allowed you to
-
3:25
write scripts that could then tell these tools what to do?
-
3:29
Scripts that you can share and reuse.
-
3:31
Scripts that can take this messy hairball of pain that is server deployment and
-
3:35
turn it into something manageable and maybe even enjoyable.
-
3:39
And well, Vagrant does that.
-
3:41
So in essence,
-
3:42
Vagrant makes you the conductor of your own personal deployment symphony.
-
3:47
It lets you write scripts and
-
3:48
telling your computer how to make other virtual computers.
-
3:51
You can then interact with as the developer.
-
3:55
In hindsight, it's a pretty simple concept.
-
3:57
It makes you stop and go, well, why didn't I think of that?
-
4:00
But usually the best ideas are like that.
-
4:03
So the notion of being able to take, of being able to create custom servers and
-
4:07
you can then share with your colleagues is pretty awesome in it's own right.
-
4:11
But Vagrant actually takes it one step further.
-
4:15
In addition to running these custom servers in your own environment,
-
4:18
Vagrant also allows you to take those same servers and
-
4:21
launch them remotely on a number of well known cloud platforms.
-
4:25
For example Amazon Web Services, Digital Ocean,
-
4:28
and then Rackspace just to name a few.
-
4:30
So in other words,
-
4:32
when you're actually ready to watch Vagrant helps you alleviate the hassle
-
4:35
involved in actually getting your product out the door in front of other people.
-
4:40
So to summarize everything we've covered so far into under one sentence,
-
4:46
Vagrant takes this and it combines it with these to give you this.
-
4:51
[BLANK_AUDIO]
-
4:56
So now that we've covered a few of the basics about what Vagrant actually is,
-
4:59
let's take at look at how Vagrant can have an impact on specific roles
-
5:02
within the development process.
-
5:04
[BLANK_AUDIO]
-
5:07
For starters, if you're a developer, Vagrant helps you isolate your
-
5:11
dependencies in the configuration within a single consistent, sharable,
-
5:16
disposable environment.
-
5:18
And importantly it doesn't force you to sacrifice any of
-
5:21
the development tools that you're familiar with along the way.
-
5:24
You don't have to SSH into some remote server file VIM for
-
5:28
example if that's not your thing, you can use whatever text editor prefer.
-
5:35
It also relieves you of the tedium of having to juggle different
-
5:38
configurations across multiple projects.
-
5:40
So, if you happen to find yourself working on a project that relies on PHP for
-
5:44
example and you don't happen to have the required version on your Mac.
-
5:48
You don't have to worry about it.
-
5:51
Finally, every developer has at one point tried to
-
5:54
track down Bubba the colleague whose response is well it works on my machine.
-
5:59
Vagrant alleviates that problem, because with Vagrant,
-
6:01
there is no such thing as my machine.
-
6:04
You're all working in an identical environment.
-
6:08
If you're and operations engineer, they can you provide you with a disposable
-
6:11
sandbox in which you can create and test infrastructure management scripts.
-
6:17
If you want to, say, experiment with running the latest version of MongoDB or
-
6:21
mess around with Reddits for example.
-
6:23
Vagrant lets you do that locally, and
-
6:25
then with the same scripts, remotely on your cloud provider of choice.
-
6:31
And finally, if you're a designer,
-
6:34
Vagrant let's you focus on what you do best, design.
-
6:38
Vagrant ensures that you have access to the same running environment that
-
6:42
the developers on your project do the same, but
-
6:44
without forcing you to dig through the underlying details.
-
6:48
And as a technology stack, the powers of project changes as in inevitably will,
-
6:53
your environment will track right along with it.
-
6:56
Without requiring you or anyone else to fiddle with your computer settings.
-
7:02
So that takes care of our initial introduction of vagrant.
-
7:05
Why don't we get our hands dirty, dirty with some actual examples.
-
7:10
First a few obvious prerequisites, you'll want to install virtualbox.
-
7:15
I mentioned this earlier in the presentation.
-
7:18
This is a free alternative to paid products such as VMware and parallels.
-
7:23
While Vagrant supports VMware and Parallels, most of the examples that we'll
-
7:27
be looking at today are designed with the expectation that you're using VirtualBox.
-
7:32
And since one of our main goals is to create an development
-
7:35
environment that can be shared with anyone the fact
-
7:38
that VirtualBox is free provides us with a solid baseline from which we can be
-
7:42
sure others can operate it without having to buy anything.
-
7:46
You'll also want to install Vagrant, obviously.
-
7:49
Both of these come with a simple installation wither, wizard and
-
7:52
take only a couple of clicks.
-
7:53
Nothing out of the ordinary here.
-
7:55
And finally I'll be using some custom configuration scripts that
-
8:00
I found personally to really ease the transition into Vagrant.
-
8:04
And you can find those on GitHub.
-
8:06
And obviously, you'll have access to this slide after this presentation.
-
8:09
[BLANK_AUDIO]
-
8:15
[SOUND] Okay, so, let's assume for
-
8:17
the moment that you are completely new to Vagrant.
-
8:21
You just installed VirtualBox, you just installed Vagrant, now what do you do?
-
8:27
Once we started by creating our first virtual server.
-
8:31
I'm going to go to my desktop and I'm going to create a folder called mybox.
-
8:38
I'm going to CD into that.
-
8:39
And then I'm gonna type Vagrant init hashicorp/precise32.
-
8:48
And I'll tell you what this means here in a moment.
-
8:53
In order to explain what I'm doing here I'm going to have to
-
8:55
take a very brief detour.
-
9:01
The people behind Vagrant and
-
9:02
the Vagrant community at large provide a large number of order called base boxes.
-
9:06
These are very basic,
-
9:08
generic servers without a lot of extra stuff installed that you might not want.
-
9:13
These are great resources on which you can build your own custom foundation.
-
9:17
You can find base boxes for Ubuntu, Debian, and CentOS, just to name a few.
-
9:23
Pretty much every well-known distro is represented.
-
9:25
And if it's not, you can create your own, which we'll get to in a later example.
-
9:30
But going back to the current example.
-
9:33
When we typed Vagrant init hashicorp/precise32, we were referencing
-
9:38
one of these pre-existing base boxes that the community has made available.
-
9:44
It's actually possible to pull in a base box from any URL, but
-
9:48
a recent addition to Vagrant is a website that you can find at vagrantcloud.com and
-
9:52
I'll pull that up in my browser now.
-
9:56
I've explored this a little bit and didn't find much of value here.
-
9:59
Essentially Vagrantcloud is Vagrant's official site for posting and
-
10:03
sharing boxes, but it's entirely optional.
-
10:07
They attempt to monetize this by charging you for the ability to host private boxes.
-
10:11
But again, you can host things anywhere.
-
10:13
So the important thing to note here is that hashicorp/precise32 is
-
10:19
just a shorthand notation that,
-
10:20
when used, references a box that has been shared on Vagrant Cloud.
-
10:29
So, that being said,
-
10:30
going back to our first example, we ran Vagrant init specifying base box to use.
-
10:36
In this example we're using Ubuntu precise 32,
-
10:39
which is a pretty good generic default, a good place to get started.
-
10:44
If we take a look at the contents of this folder now,
-
10:47
[SOUND] you'll see that we have one file, and it's called vagrant file.
-
10:52
This is the configuration file that tells our bots how to behave.
-
10:55
[SOUND] This is what the default vagrant file that vagrant creates looks like.
-
11:05
It's in here that we can specify settings such as our box's IP address,
-
11:10
forwarded ports, allocated RAM, host name, and other things of that nature.
-
11:16
It's written in Ruby which I'm not a big fan of but we'll come back and
-
11:20
talk about configuration a bit more in our next example.
-
11:25
For now, I'm just going to clear this screen here.
-
11:28
I'm going to type Vagrant up.
-
11:34
This will boot up our new server.
-
11:36
We'll see some status messages printed out to the console that keep us posted as to
-
11:40
what's going on.
-
11:42
When the process finishes, our server is ready for use.
-
11:46
Vagrant provides a shortcut for
-
11:47
signing into the server, which we'll use here in a second.
-
11:50
You just have to type Vagrant SSH and now we're signed in.
-
12:00
I'll type a few commands here just to give you a lay of the land.
-
12:04
But again this is just a standard Ubuntu precise 32 server.
-
12:09
It doesn't have anything running locally.
-
12:11
Not a lot of services installed.
-
12:13
It doesn't do much because we haven't told it how to yet.
-
12:16
But, again we'll touch on that in our next example as well.
-
12:21
When we're done with this box, you can do a couple of things with it.
-
12:26
First of all, I'm going to exit out.
-
12:28
Now I'm back to the console I'm on that.
-
12:31
We could put to sleep with vagrant suspend.
-
12:37
We can bring it back up by simply typing vagrant up again.
-
12:47
It should just take a second.
-
12:51
Now it's back up.
-
12:52
We could SSH back into it if we like.
-
12:57
Or when we're completely done with it, we can type Vagrant destroy.
-
13:03
It's gonna ask me to confirm.
-
13:05
And the effect of this is that it's as if we never started it up in the first place.
-
13:09
[BLANK_AUDIO]
-
13:13
So now that we've walked through this example of setting up a default box,
-
13:17
let's start doing some stuff that is actually useful.
-
13:21
But before we do, as I mentioned a few minutes ago, let's come back and
-
13:25
talk about configuration for a moment.
-
13:28
I mentioned that Vagrant is configured with a single file named vagrant file
-
13:33
that's written in Ruby.
-
13:33
I'll show you the contents of that again.
-
13:41
I'm personally not a fan of Ruby but
-
13:44
regardless of how you feel about it I think that one thing is for sure.
-
13:47
It's not a universal language.
-
13:50
And by that all I really mean is that it's not as quickly grasped by
-
13:54
everyone as something like say, JSON.
-
13:57
And when it comes to configuration that's what I want.
-
14:00
I want a format that is immediately approachable by everyone,
-
14:03
regardless of whether they've used Ruby or not.
-
14:07
And for that reason I've gotten in the habit of having my own personal data file.
-
14:13
I've configured it such that all it does is it parses the contents of
-
14:16
another JSON configuration file and
-
14:19
uses that to set all the various Vagrant settings that you'd like to use.
-
14:24
This is what that actually looks like.
-
14:26
[BLANK_AUDIO]
-
14:33
Really straightforward.
-
14:34
[BLANK_AUDIO]
-
14:38
So right off the bat you'll notice that we have a servers array that can take one or
-
14:42
more objects, each of which describes a virtual server to be created.
-
14:47
Most of the examples that we'll be working with involve spinning up a single server
-
14:51
but we do have the option of defining multiple servers that can work together.
-
14:55
And we will eventually work with an example that does just that.
-
14:59
I'm assigning the server a custom host name.
-
15:02
As a result, when the box is ready I'll be able to access it directly,
-
15:06
at the modernweb.site domain name.
-
15:13
I'm also no longer referencing the hashicorp/precise32 base box that
-
15:18
we used in our last example.
-
15:20
I'm actually referencing a box of my own creation that I have made available in
-
15:24
my public Dropbox folder.
-
15:27
We'll talk a bit more about how that works here in a minute.
-
15:30
A timezone setting allows us to automatically set
-
15:34
the appropriate timezone on our new server.
-
15:36
And scripts that's a little bit more in depth,
-
15:39
we're gonna hit that in a later example as well.
-
15:42
One final thing to take note of you'll notice that we have a paths object that we
-
15:47
specify as well.
-
15:48
It's here that we can specify one or more mappings that will enable us to
-
15:53
map files on my map to paths on the server.
-
15:58
In this example,
-
15:59
these settings will result in the files on my map that are located within
-
16:02
the repos/modernwebsite folder being available on this server at /opt/site.
-
16:09
This is important because this will allow us to keep working with
-
16:14
these files on our host computer.
-
16:16
And again in my case on my Mac using my preferred editor, which happens to be bba.
-
16:23
As I make changes they will be immediately reflected on the virtual server as well.
-
16:27
[SOUND] So, with that being said, let's setup our next server.
-
16:34
But at this time, this, this time, let's get a little more sophisticated with it.
-
16:39
Before we do that,
-
16:40
though, I need to talk about one other Vagrant concept known as repackaging.
-
16:46
I've already mentioned base boxes.
-
16:48
These are generic boxes without any extras added on to them.
-
16:53
No additional services or programs like Apache or Nginx, MongoDB or
-
16:58
Node are installed for you.
-
17:00
These boxes provide you with a clean slate from which you can work.
-
17:05
Now, let's imagine for a moment that you've spun up one of the base boxes.
-
17:09
You've signed in. You've installed Node.
-
17:11
You've installed MongoDB and a few other dependencies that you want.
-
17:16
Now you've got to use this box as current state, as your baseline moving forward.
-
17:21
Obviously you don't wanna have to do this manually every time you spin up the box
-
17:25
because that defeats the whole point of what we're trying to accomplish here.
-
17:29
So how do you go about doing that?
-
17:32
There are a couple ways to do this, but
-
17:34
one of the easiest that I've found is the repackaging process.
-
17:38
Repackaging allows you to take a Vagrant server you have running,
-
17:42
then repackage it as a brand new base box that you can then share with others.
-
17:48
And I'll show you what that looks like right now.
-
17:50
[BLANK_AUDIO]
-
18:02
So, several minutes ago, I destroyed this example server that we were looking at.
-
18:07
I'm actually gonna bring it back up and once it's up I'm gonna sign in again and
-
18:11
I'm going to install Nginx.
-
18:13
This is a pretty popular lightweight web server.
-
18:21
Box is ready.
-
18:23
Vagrant SSH.
-
18:24
Sign in.
-
18:27
Just a couple of steps that I have to walk through to get Nginx installed.
-
18:35
This should only take about 30 seconds.
-
18:36
[BLANK_AUDIO]
-
18:51
Almost done.
-
18:52
All right, so now that I've updated Ubuntu, I'm gonna install Vagrant.
-
18:55
I'm, I'm, I'm, I'm sorry, I'm gonna install Nginx now.
-
18:57
[BLANK_AUDIO]
-
19:07
Done.
-
19:09
Okay, so what have I done here?
-
19:10
I booted up a brand new base sever, signed in, and installed Nginx.
-
19:16
So now I'm gonna exit out.
-
19:17
And I'm gonna type vagrant package --out then I'm gonna give it a target file and
-
19:24
in this example I'm just gonna save it to my desktop.
-
19:28
[BLANK_AUDIO]
-
19:35
So what it's gonna do now, it's gonna shut down the server,
-
19:38
it's gonna export it out to a .box file which you can then host anywhere you like.
-
19:43
In the next several examples that we look at, I'm using such a box.
-
19:46
I've got it in a public Dropbox folder.
-
19:48
This usually takes anywhere from two to three minutes.
-
19:52
It varies a little bit.
-
19:54
We're not gonna sit here and watch this.
-
19:55
So I'm gonna go ahead and cancel out of that.
-
19:56
[BLANK_AUDIO]
-
20:04
And that's it.
-
20:07
Just real quick before we move onto the next example.
-
20:09
I'm gonna pull up my public Dropbox folder for a second.
-
20:12
[BLANK_AUDIO]
-
20:18
This is the base box that I'll be using in the next couple of examples.
-
20:22
It's 1.7 gigs.
-
20:25
Obviously the size is gonna vary based on what you install on your server, but
-
20:28
this is fairly typical.
-
20:36
[NOISE] All right, so, our next example.
-
20:40
Now that we have a solid grasp on what repackaging is and
-
20:43
how that works, we can move forward.
-
20:46
For this time around though I'll be setting up a box that we already set up
-
20:49
with a solid set of dependencies that I find myself often [INAUDIBLE].
-
20:53
I package it for use, reuse, and,
-
20:55
and place the result in box file integrated within my DropBox folder.
-
21:00
A link to that box will be included with the slide that you get
-
21:02
after the presentation.
-
21:05
I'll also be using my preferred Vagrant file, but reads its
-
21:07
configuration setting from a jSON file instead of making you learn Ruby.
-
21:11
[NOISE] All right.
-
21:19
So, let me just bring up our next server.
-
21:22
[NOISE] This is the configuration
-
21:28
file that we're gonna be
-
21:33
using as the server spins up.
-
21:40
It's got a guest IP of 10.0.320.
-
21:44
I'm assigning it a domain name of modernweb.site.
-
21:50
I'm assigning a name to this base box that I'm using, and
-
21:55
I do that because what's that gonna tell Vagrant to do is, as we move forward and
-
21:59
create other servers on top of this, it's gonna match that name of the URL.
-
22:03
I've already downloaded this, I don't need it again.
-
22:06
I'm also specifying the pads that map to this particular folder right
-
22:12
here to slash up slash site on this service that we're creating.
-
22:17
We're gonna be in the central time zone.
-
22:20
And also gonna have it spin up my local web browser and
-
22:24
point it to a specific URL when it's ready.
-
22:28
You also notice here that I'm specifying an apt script to run.
-
22:34
So what this is doing is it's looking in a scripts folder, that I've included.
-
22:38
And it's using, in the scripts that I
-
22:41
specify in this configuration file to provision this server.
-
22:46
So if you take a look at apt, at app I’m sorry.
-
22:50
All its going to do is its going to cd into slash opt slash site.
-
22:56
That’s that’s again that’s the folder that maps to my local fo
-
23:00
folder on my mac where I happen to have a project.
-
23:03
It's going to start a, a node instance.
-
23:04
I actually need to put in my password here.
-
23:10
It's asking me for my password because the way in
-
23:13
which these folder passes are set up is via NFS and it, it wants to know my
-
23:18
administrator's password to modify some user setting from my back.
-
23:23
[BLANK_AUDIO]
-
23:26
And so, here we are.
-
23:28
Server's running.
-
23:28
The ma, the mappings were set up.
-
23:33
Once the box was ready, it ran, it looped through the app scripts that we set up.
-
23:37
And it started a running node instance.
-
23:39
It then immediately opened a tab in my web browser that took me
-
23:44
to this project on [UNKNOWN] 3,000.
-
23:47
That's a pretty simple example of a Vagrant project.
-
23:51
Now I can move onto
-
23:58
something a little
-
24:05
more advanced.
-
24:11
[NOISE] Give me just one second here.
-
24:16
All right.
-
24:17
So. I’m going to take the example that we
-
24:21
just ran through.
-
24:22
I’m gonna stand up again, but this has been modified in a minor way.
-
24:28
I I don't know how many people here are using their own production or
-
24:30
how you're doing that.
-
24:32
Typically when I do that I often find myself not directing traffic
-
24:37
directly to that running node instance.
-
24:39
That's usually abstracted behind something like say, for example, Nginx.
-
24:45
And this script that we're running right now is actually going to allow us
-
24:48
to do that.
-
24:49
[BLANK_AUDIO]
-
24:54
So a few minutes ago we looked at this slash apt script.
-
24:59
Very, very basic.
-
25:00
Just a couple line that you can see here.
-
25:01
It's just seeding and, and slash up slight.
-
25:04
It's running forever start index.js.
-
25:06
Those of you that are familiar with node and have, have used Forever before,
-
25:09
you know exactly what that is But if we look at this Nginx script that I've
-
25:14
got right here, this starts to get quite a bit more complicated.
-
25:17
I'm not gonna run through the contents of this.
-
25:19
It's really not that important.
-
25:21
But, basically the concept that I'm,
-
25:24
I'm trying to push here is the fact that you could create these batch scripts
-
25:29
that you can run programmatically whenever you boot up a box.
-
25:33
And these scripts, then instruct the server on how to do it's thing.
-
25:38
How to set it up, how to do things that you want it to do.
-
25:42
So you can see, I'm no longer hitting the sever at port 3,000,
-
25:45
I'm hitting it at port 80.
-
25:48
And it will do that, because I've now got
-
25:52
this running node inst, that I was going to.
-
25:57
[BLANK_AUDIO]
-
26:01
So what I'm gonna do next is I'm gonna destroy this intens-,
-
26:03
. instance and run through another example.
-
26:09
[BLANK_AUDIO]
-
26:14
One thing that I frequently find myself running into when I'm working on a project
-
26:21
that has Vagrant is, so I've created this box that I've given to my colleagues.
-
26:27
You know, they're coming in at the beginning of the day.
-
26:29
They spin it up.
-
26:30
They start working on the project.
-
26:31
That's all well and good.
-
26:32
But when the box is up and running.
-
26:35
And they go into the app that we're building.
-
26:38
They need to have a, a basic set of data to power the thing.
-
26:43
We need a shared schema we can reimport over and over.
-
26:48
I'm going to show you how I typically go about doing that in this example.
-
26:52
I'm just going to hit Vagrant up again.
-
26:54
[BLANK_AUDIO]
-
26:58
And if we take a look at this data script that I'm now using right here.
-
27:02
My scripts configuration, I'm just running app and data.
-
27:05
In here, these are just some basic Bash commands where I'm,
-
27:11
I'm telling MySQL to create a new database.
-
27:14
I'm importing some data from a couple of FLAC files.
-
27:17
And as a result, when the server's up running, we can launch the app and
-
27:21
it's going to work exactly how we expect it to.
-
27:27
This should just take a second.
-
27:28
When it's done, I'm gonna sign in for the SQL portal [UNKNOWN] Mongo and
-
27:32
show you what the data base are set up like we'd expect them to be.
-
27:44
Should take just a second.
-
27:51
By the way, if anyone has any questions as we're looking at this,
-
27:54
feel free to throw them out there, I'd love to hear them.
-
27:56
[BLANK_AUDIO]
-
28:02
All right. So the server's up and running.
-
28:04
It's ready.
-
28:08
I'm gonna grab SQL Pro over here now.
-
28:10
[BLANK_AUDIO]
-
28:15
And you can see we've got our database set up just like we want it.
-
28:18
It's got some sample data that we can use.
-
28:20
This app is good to go and it's ready to be used.
-
28:29
All right, well that illustrated it, and I'll destroy this box again.
-
28:33
[BLANK_AUDIO]
-
28:41
And now I'm going to show you that I referenced earlier in the presentation.
-
28:45
So, everything that we've looked at so far has shown how you can setup
-
28:49
a single server, but one of the, the more exciting things that,
-
28:55
that I find about vagrant is that you can use this thing not to just create these
-
28:58
really simple servers, you know, one-off things that do their thing.
-
29:03
You can actually use Vagrant to create really, pretty sophisticated deployments
-
29:07
comprised of multiple servers that can talk to each other.
-
29:11
That, you know, have a,
-
29:12
a really nice separation of concerns where you get the server a that can do
-
29:15
each one thing, you get the server b that does this specific thing, and
-
29:19
they work together, together, to create this really nice distributed product.
-
29:24
And what we're gonna do now is show an example of how that works.
-
29:28
So, again, in all the other examples that we've looked at in
-
29:31
our configuration files, we should find a single server right here.
-
29:34
What we're gonna do now is actually to find two to find two servers here.
-
29:42
I'm calling one ModernWeb1, and I'm calling the other ModernWeb2.
-
29:47
This first one has an IP of 10.0.3.20.
-
29:50
I just gave this second one 10.0.3.21.
-
29:53
I'm gonna hit the, I'm gonna give the first a domain name of modernweb1.site,
-
29:58
second one will have moderweb2.site.
-
30:01
Other than that they're pretty much identical.
-
30:05
So, when I type vagrant up again it's now gonna loop through both of
-
30:10
these definitions and
-
30:12
create two identical running servers here on my Mac that I can interact with.
-
30:17
[BLANK_AUDIO]
-
30:21
This should take just about 30 seconds or so.
-
30:27
Scrolling back here through the right now.
-
30:30
I'm looking at some of the questions that we got here.
-
30:34
Aaron Bigs,
-
30:35
How did you get your Vagrant to read your JSON instead of the Ruby Vagrant file?
-
30:39
While this is loading up, I"ll show you that right quick.
-
30:44
Again, I've got the sources I've given up,
-
30:45
I'm going to give everybody access to it after the presentation.
-
30:49
But this is what my Vagrant file looks like.
-
30:51
If you scroll down here there's not much more than what you see.
-
30:56
I've broken everything down into a couple other
-
30:59
smaller Ruby library files that I'm then pulling in.
-
31:03
But to answer your specific question, how I'm loading that from a JavaScript,
-
31:07
I'm sorry, from a JSON file.
-
31:16
The Vagrant file, it's just a Ruby file, that's all it is.
-
31:19
So all I did basically, and
-
31:21
again, I'm not really a big Ruby guy, so I had to do a little bit of research and
-
31:25
I ended up doing this, but I'm just saying require JSON, which is a Ruby construct.
-
31:31
Now I'm looking through and
-
31:33
I'm saying if config.json loaded up, then I've got that, that hash object.
-
31:39
I can then loop through in Vagrant and spray.
-
31:45
The server's not quite ready yet, but it almost is.
-
31:52
You are back in port 3,000.
-
31:53
Is that correct?
-
31:54
I think it is.
-
31:55
I, I think I had the first example, not the first example.
-
31:57
Maybe it was the second example where I installed Nginx and
-
32:00
was putting everything on port 80.
-
32:02
I'm not necessarily doing that every single time now.
-
32:08
All right, and our two servers are now up and running.
-
32:11
You'll notice that since I got my Vagrant file set up to automatically load
-
32:17
in my browser, any URLs that I set with open URL, it did that for me.
-
32:24
So here I've got modernwebtwo.site, modernwebone.site, and
-
32:29
to illustrate how these things are, are, are capable of talking to
-
32:32
each other I'll just show you real quick, I can ping both of them from my Mac.
-
32:36
[SOUND] As mentioned earlier,
-
32:38
I gave this one an IP of 10.0.3.20, you can see that here.
-
32:44
Same deal with modernwebtwo.site.
-
32:46
[SOUND] 10.0.3.21.
-
32:51
And I can SSH directly into either of these boxes by typing vagrant, ssh, and
-
32:57
then specifying the ID that we assigned in a very specific box.
-
33:02
So I can say vagrant ssh moderweb1.
-
33:05
And that's gonna take me in.
-
33:07
And that command Vagrant SSH, that's just shorthand, something that Vagrant
-
33:12
opens up for you, but obviously these are actual running servers.
-
33:16
So, if you just want to use SSH and provide a, an ID list or
-
33:19
a hostname, you can just as easily do that.
-
33:22
But now that I'm signed in to modernweb1.site I
-
33:26
can actually ping together a box from more than this server.
-
33:33
You can see in here again it's getting that same IP address 10.0.3.21.
-
33:37
So that pretty much wraps up this particular example.
-
33:44
What you're seeing here though I feel is pretty powerful.
-
33:46
I mean you can use this to create some really pretty sophisticated deployments.
-
33:51
The number of servers you spin up simultaneously is, is
-
33:53
really only limited by the capabilities of the computer that you happen to be using.
-
34:00
How can we get local configuration examples?
-
34:03
They are not in our GitHub vagrant repo.
-
34:05
Okay I haven't actually pushed those up yet.
-
34:07
I put those together just for
-
34:08
today's example and I haven't, again I haven't pushed them up yet
-
34:11
but I will be happy to do that after we, we get off the presentation.
-
34:15
It's no problem at all.
-
34:18
All right, so with that being done, I'm gonna exit out.
-
34:22
And I'm going to destroy both of those boxes.
-
34:25
Vagrant destroy.
-
34:27
It's gonna confirm both of them for me.
-
34:28
[BLANK_AUDIO]
-
34:34
Done. And so
-
34:35
I have no servers running right now.
-
34:37
It's, it's as though, you know, I, I haven't done anything.
-
34:40
Our box is back to its pristine state.
-
34:45
So our next example is going to involve ultimately what could potentially
-
34:52
be one of the coolest accidents of Vagrant which is the ability to take one of
-
34:56
your script technicians and use that to deploy jQuery remote [UNKNOWN].
-
35:01
So, I'm just going to repeat the process that we've done now a few times.
-
35:06
I'm going to copy this configuration over, put it in our config.default.json file.
-
35:12
And you'll notice it's a little bit different from some of the ones that
-
35:16
we've gotten used already, but I am specifying a couple extra [UNKNOWN].
-
35:21
I'm saying provider Visual Ocean.
-
35:24
I'm also passing some provider settings.
-
35:27
So I'm, I'm giving this a name, and
-
35:29
we'll sign into my Digital Ocean account here in a second.
-
35:31
You'll see this pop up I've got a token here.
-
35:34
And for those of you that are paying attention,
-
35:36
this is just a temporary token and
-
35:37
that I am gonna wipe out after we get off the call.
-
35:40
image, specifying, you know,
-
35:42
the picture I want to use, the region that I want to put it in.
-
35:45
I don't know how many of you here are familiar with Digital Ocean,
-
35:47
but they are absolutely fantastic in my estimation.
-
35:51
The pricing is significantly cheaper than what you're gonna find on
-
35:54
Amazon Web Services.
-
35:56
They do occasionally have a couple of hiccups in terms of reliability, but
-
36:00
they're getting better every day.
-
36:03
I can also specify what region that I want to put this server in.
-
36:06
So much like Amazon Web Services or any other, you know,
-
36:10
well known cloud provider, they've got servers all around the country,
-
36:14
all around the world and you can specify what region you want to put it in.
-
36:17
So let's say for example I'm creating this fairly sophisticated deployment and
-
36:22
I'm expecting a lot of traffic.
-
36:24
I could have one server running on the east coast.
-
36:26
I could have one running on the west coast.
-
36:29
They have a San Francisco region that you can tap into.
-
36:33
So, with this in here now, I'm going to boot this up.
-
36:41
Francois they are great.
-
36:42
Yeah I love Digital Ocean.
-
36:44
How long can you keep the servers up?
-
36:46
For days, hours, months?
-
36:47
You can keep it up for as long as you want.
-
36:48
You can keep it up until they go out of business.
-
36:50
Which I don't expect because they're pretty well funded.
-
36:53
And it's not a fly by night operation.
-
36:56
If you haven't heard of Digital Ocean before check them out.
-
36:59
They're, they're really getting a lot of traction.
-
37:02
[BLANK_AUDIO]
-
37:05
All right, so
-
37:06
this might take a little bit more than one of the inside of our previous examples.
-
37:11
Obviously on having to communicate with Digital Ocean and,
-
37:13
and now send out some outbound traffic that I haven't had to before.
-
37:17
But it really shouldn't take that long.
-
37:20
While it's doing that I'm just gonna jump back over to make up the migration file.
-
37:24
Just like in all the previous examples, I'm specifying some paths here.
-
37:29
And it's going to map these local folders to this Digital Ocean
-
37:32
server that I create.
-
37:33
There's going to be one slight difference here.
-
37:36
If I'm making changes to these files now.
-
37:38
After the server gets created it's not going to be immediately reflected.
-
37:42
As a matter of fact, it's not going to be reflected at all.
-
37:45
All it's doing here in this case is it's just pushing them out to
-
37:48
the server when it's ready.
-
37:49
Just a one way push.
-
37:50
There is no back and forth.
-
37:52
[BLANK_AUDIO]
-
37:55
Great. Okay.
-
37:56
So creating a new droplet.
-
37:58
droplet, again if you're not familiar with Digital Ocean,
-
38:01
this is just their terminology for an instance.
-
38:04
Just marketing speak.
-
38:06
Assigned IP address.
-
38:07
It's almost ready.
-
38:08
You can see it's Rsyncing the folder out, and at this point we can probably already
-
38:13
go ahead and, and look at my Digital, Digital Ocean cap and see this pop up.
-
38:18
Yep, there it is right there.
-
38:19
[BLANK_AUDIO]
-
38:24
And the server's ready.
-
38:25
[BLANK_AUDIO]
-
38:31
I could have just as easily SSH'd into this thing by,
-
38:34
by going directly to this IP address right here.
-
38:37
But just as in all the previous examples, since Vagrant graded this thing and
-
38:41
is, and is aware of it, I can type Vagrant SSH,
-
38:44
and it's just going to basically alias that.
-
38:47
And do an SSH into this remote server, but
-
38:50
again I could just as easily SSH directly into the IP if I wanted to.
-
38:55
So I'm gonna exit out of that.
-
38:58
Destroy it just as we had in all of our previous examples.
-
39:01
[BLANK_AUDIO]
-
39:04
And I've got a couple of other examples here that I
-
39:07
want to run through real quick.
-
39:09
That I feel are, are, are gonna illustrate some pretty useful things that I've
-
39:13
come to rely on pretty frequently.
-
39:15
The first one is,
-
39:16
is going to be an example of how you can use mbrak within Vagrant.
-
39:19
I don't know if any of you are familiar with that.
-
39:21
This is a fantastic service.
-
39:23
I don't know if Brian Neimeyer is on the call right now or
-
39:25
not, but I believe he's the one who actually introduced this to me.
-
39:30
So what I'm gonna do now is I'm just gonna go back to our previous example.
-
39:33
The first one that we did.
-
39:35
I'm just gonna spin up a really basic box.
-
39:37
[BLANK_AUDIO]
-
39:45
Since I'm really not doing much here or
-
39:47
running any additional scripts this should just take a second.
-
39:50
[BLANK_AUDIO]
-
40:05
I appreciate everybody showing me a little bit of patience here.
-
40:07
Obviously the topic at hand it's not the kind of thing where you can
-
40:10
just spin these up instantaneously.
-
40:11
It does take a couple seconds, but big picture really not a lot of time.
-
40:15
[BLANK_AUDIO]
-
40:18
Almost done.
-
40:19
[BLANK_AUDIO]
-
40:28
Almost.
-
40:28
[BLANK_AUDIO]
-
40:37
It's asking me for my password again.
-
40:41
Again, it asked me for my password so it can set up these path mappings.
-
40:44
[BLANK_AUDIO]
-
40:49
All right, so I've created a new instance of this really basic server.
-
40:52
I, I haven't installed node on it or, or, or done a lot fancy things with it.
-
40:56
I just booted up this really basic server.
-
40:59
And now I'm gonna SSH into it.
-
41:02
When it was ready it opened up the stat in my browser and took me to the site.
-
41:05
And so you can see here obviously it does have engine X.
-
41:08
So it's got something running on port 80.
-
41:10
So what I'm gonna do now is illustrate how you can use this
-
41:14
really nice service called Ngrok.
-
41:15
And that's N-G-R-O-K.
-
41:17
I'm just gonna say Ngrok, I'm gonna get port 80.
-
41:22
And what it's actually going to do now is it's going to
-
41:24
create what's called a reverse SSH tunnel.
-
41:27
And that's just a, a fancy phrase which means anybody on the,
-
41:32
on the public internet can now hit this URL right here.
-
41:35
And it's going to route that traffic to port 80 on my box.
-
41:40
And importantly, you'll note that I didn't have to do anything else.
-
41:44
I didn't have to, you know, mess around with the settings on the router,
-
41:48
I didn't have to open up a specific port.
-
41:50
It just works.
-
41:53
It's really nice too because if we go to our browser and hit that URL.
-
41:58
Go.
-
41:59
[BLANK_AUDIO]
-
42:04
Might be might be having internet trouble here.
-
42:08
There we go.
-
42:09
Okay. You can see I'm
-
42:10
hitting 5470d93f.inroc.com.
-
42:14
It's really cool because as you're doing that
-
42:17
you can keep an eye on what's running here in the terminal and
-
42:19
it's gonna show you the traffic, the requests that are coming through.
-
42:22
And you can actually go to ngrot.com and
-
42:24
they provide you with an online tool set for, for using deeper analysis of
-
42:28
that traffic What I'm showing you right here is actually free.
-
42:33
But for a very minimal one time fee, you can get some extra services.
-
42:38
You can get custom subdomain names.
-
42:40
So you could point everybody to, you know, yourcustomname.ngrok.com.
-
42:47
For those of you that wanna get a little more sophisticated with it,
-
42:50
Ngrok is actually an open source tool.
-
42:52
So you can install this on your own server and
-
42:54
completely push their service out of the picture for you and host this yourself.
-
42:58
[BLANK_AUDIO]
-
43:11
So, what we're seeing there is pretty powerful.
-
43:14
I, I don't know everybody's background this year.
-
43:16
I can tell you a couple ways that I frequently find myself using this tool.
-
43:21
Let's say that I'm, I'm working on a,
-
43:22
a single page application that has a series of, of mocha tests behind it.
-
43:29
I don't know how many of you here are familiar with tools like Selenium or
-
43:33
Sauce Labs, that allow you to run an automated test suite against your product.
-
43:38
But having this tool allows me to use those third party services.
-
43:43
And then tunnel their traffic into my box and
-
43:46
not have to worry about well is my router setup?
-
43:48
Are they gonna be able to get through?
-
43:50
It just works.
-
43:51
It's a simply appliance.
-
43:55
We're running a little short on time, but
-
43:58
that's fine cuz I only have one more example.
-
44:00
[SOUND]
-
44:04
All right.
-
44:13
I've stored the server already, and then spin it back up.
-
44:18
One thing that I frequently find myself frustrated with in
-
44:21
terms of app development is email testing.
-
44:26
So most of the products that I work on, they, they tend to take a tack of,
-
44:30
all right, well, when somebody registers,
-
44:33
we're not gonna have them create their own username.
-
44:35
We're just gonna say, give us your email.
-
44:36
That's gonna serve as your user name and we're gon-,
-
44:39
we're gonna keep the barriers to entry really low.
-
44:41
We're gonna let them into our app right away.
-
44:43
But we do eventually want to validate that email address and
-
44:47
make sure they're not spamming us.
-
44:49
We actually got another, another person on the end of this line.
-
44:51
And so testing the, you know, that process.
-
44:54
Testing out all of the transactional emails that go out from an app,
-
44:58
that can be kind of a pain to deal with.
-
45:02
One of the nice things about working with Vagrant is that you can
-
45:06
put some solutions in place to deal with that.
-
45:08
So, in this particular instance, this server actually has its own
-
45:11
email server running on it, and it has users inside of it.
-
45:15
So, what that means is that I can send email to users at this box.
-
45:20
I can say you know, sending an email to user1@favorite.site.
-
45:25
And then I can just hit port 8000.
-
45:31
Maybe it's port 8080.
-
45:35
I actually have what's called Roundcube running on this box.
-
45:39
It's just a really simple PHP-based email client.
-
45:44
yeah.
-
45:45
So we're running a little bit short on time here.
-
45:47
Instead of just, you know, dragging you through it how all this works lets see if
-
45:50
anybody's got any more questions.
-
45:51
Regina is there anything else that anybody'd like to talk about,
-
45:54
any questions you have or, or
-
45:55
any insights into how you happen to be using Vagrant at the moment?
-
45:58
[BLANK_AUDIO]
-
46:09
Regarding the guest IP aspect of the config, how did you choose it?
-
46:12
Is that router specific?
-
46:13
Would it make more sense to use a 198.162.XX address?
-
46:18
I honestly don't remember where I got that number.
-
46:20
I, I've been using Vagrant for a while now and
-
46:21
I think that's just the number I've seen that, I happen to just have stumbled on.
-
46:25
I think that you can, again, you could just as easily have used in any,
-
46:28
any local IP or adding scene that you want.
-
46:31
Obviously you don't want to use something that could actually be a real remote IP
-
46:35
address, but anything that's know a local subnet would be just fine.
-
46:39
[SOUND] When I get it right, you always need one.
-
46:45
If I get it right, you always need one origin box.
-
46:48
Is that correct?
-
46:49
Could you expand on that a little bit?
-
46:51
I'm not sure that I know exactly what you mean by origin box.
-
46:58
If you bring up a box with a cloud provider does Vagrant destroy,
-
47:01
delete the VM there?
-
47:03
Yes it does.
-
47:04
At least I can,
-
47:05
I can tell you with 100% certainty that it does in the case of Visual Ocean.
-
47:09
I hadn't used all of them but
-
47:10
I'm gonna venture to guess that they all pack in the same way.
-
47:13
But in, in, with this particular provider for Digital Ocean, yes, it does.
-
47:19
One existent virtual box.
-
47:21
Yeah, I don't think you, yeah you always need to define at least one server to use.
-
47:26
If I'm understanding you correctly, I'm not sure if can understand a situation
-
47:30
which you would wanna use it without defining servers at all.
-
47:34
But yeah, you definitely need at least one server.
-
47:40
So real quick, let me just make one more comment.
-
47:42
In terms of how I find people objectively using this tool.
-
47:47
If you happen to find yourself in a project where you have multiple developers
-
47:50
working on a single code base typically what I
-
47:53
find people doing is having a single GitHub refill in which that project lives.
-
47:59
And then underneath that refill they've got a vagrant folder.
-
48:03
And within that folder live these files that we were looking at.
-
48:05
The ones that you're gonna have access to GitHub after the call.
-
48:10
And what.
-
48:11
Do as I say.
-
48:11
All right we have a new guy here, girl here going to start on this project.
-
48:16
Clone this [UNKNOWN].
-
48:16
See me in the emulator for worm.
-
48:18
Hit Vagrant up and then you're good to go.
-
48:20
And it's really as simple as that.
-
48:23
It provides you with this nice appliance that can track right along with it.
-
48:28
Without requiring people to, to go though all these tedious steps of
-
48:32
setting this stuff up on [INAUDIBLE] server.
-
48:35
How would you do this if you had parallels?
-
48:38
Like I mentioned earlier in the presentation,
-
48:40
yes Vagrant absolutely supports parallels.
-
48:42
It supports VMWare as well.
-
48:45
I haven't used parallels before or
-
48:47
I shouldn't say I've never, it's, it's been quite a while.
-
48:51
Pull up the documentation,
-
48:52
essentially what you're gonna do is take the same scripts that we were using here,
-
48:56
and instead of pointing it to Digital Ocean or pointing it to,
-
48:59
to Virtualbox you're gonna override that and say point it to parallels.
-
49:03
You may run into a,
-
49:04
a, a couple of instances where you have to tweak a couple of the settings, for
-
49:07
example, if, you know, parallel support's doing one thing in one way that
-
49:11
Virtual Docs just doesn't support, you might have to tweak it a little bit.
-
49:15
But you know, 98% of the stuff is going to fork right on over.
You need to sign up for Treehouse in order to download course files.
Sign up