Multi-Provider Vagrant: AWS, VMware & More - PuppetConf 2013
-
date post
18-Oct-2014 -
Category
Technology
-
view
7.064 -
download
1
description
Transcript of Multi-Provider Vagrant: AWS, VMware & More - PuppetConf 2013
Living in a Multi-Provider World
Friday, August 23, 13
I’m Mitchell HashimotoAlso known as @mitchellh
Friday, August 23, 13
I build toolshttp://hashicorp.com
Friday, August 23, 13
Vagranthttp://www.vagrantup.com
Friday, August 23, 13
Packerhttp://www.packer.io
Friday, August 23, 13
http://vagrantup.com
Friday, August 23, 13
I think you know what this nowadays...
Friday, August 23, 13
SUCCESS!
Friday, August 23, 13
You probably should really be using this nowadays to be working with and testing Puppet modules...
Friday, August 23, 13
State of the Vagrant
Friday, August 23, 13
Vagrants are still struggling to find work, shelter, and food.
Friday, August 23, 13
Friday, August 23, 13
Vagrants are still struggling to find work, shelter, and food.
Friday, August 23, 13
Vagrant!
Friday, August 23, 13
Mature, stable, proven.Development since Jan 2010.Used by thousands of companies.
Friday, August 23, 13
Friday, August 23, 13
Friday, August 23, 13
Vagrant
Friday, August 23, 13
Puppet
Friday, August 23, 13
Friday, August 23, 13
Create and Manage Virtualized Development Environments
Mitchell Hashimoto
VagrantUp and Running
http://hashi.co/vagrant-book
Friday, August 23, 13
Releases in 2013: 14
Friday, August 23, 13
Vagrant 1.1+ was finally released in March. A year in development.
Friday, August 23, 13
SUCCESS!
Friday, August 23, 13
Things are good.
Friday, August 23, 13
Things are getting
BETTER!
Friday, August 23, 13
Vagrant 1.1+
Friday, August 23, 13
I hear you like VirtualBox...
Friday, August 23, 13
Providers.
Friday, August 23, 13
a.k.a.No more VirtualBox.
Friday, August 23, 13
(Don’t worry, Vagrant still works with VirtualBox)
Friday, August 23, 13
BUT NOW IT WORKS WITH:
AWS, DigitalOcean, HP Cloud, Joyent, KVM, libvirt, lxc, OpenStack, Rackspace, VMware.
Friday, August 23, 13
Mother of God...
Friday, August 23, 13
Vagrant 1.1: March 2013
Friday, August 23, 13
We’re now on 1.2.7.(14 releases later)
Friday, August 23, 13
The same Vagrant you know and love, butso much better.
Friday, August 23, 13
Backwards Compatible*Just “vagrant up” your 1.0.x Vagrantfiles.
* Plugins from 1.0.x aren’t backwards compatible.
Friday, August 23, 13
VAGRANT_API_VERSION = “2”
Vagrant.configure(VAGRANT_API_VERSION) do |config| config.vm.box = “precise64”end
A Vagrantfile
Friday, August 23, 13
Installer only.“gem install” folks living in the past, take note.
http://downloads.vagrantup.com
Friday, August 23, 13
Path to 2.0Guaranteed Vagrantfile stability, widespread use.
Friday, August 23, 13
But 1.2.x is quite goodThe core is much stronger, many subtle issues fixed, latest support for various host/guest combos, NFS is way better, etc.
Friday, August 23, 13
Vagrant Future
Friday, August 23, 13
Going to get way better.This is the part where I tease you.
Friday, August 23, 13
Windows VM support“vagrant up” Windows VMs with ease.
Friday, August 23, 13
Box versioningNo more “am I using the latest box?”
Friday, August 23, 13
Docker ProvisionerYes, I’ll take a RabbitMQ with a side of Nginx.
Friday, August 23, 13
Superpowered “package”Powered by Packer, to be discussed.
Friday, August 23, 13
Automated box buildingPACKER!
Friday, August 23, 13
Other stuff...I think I’ve said enough. Get excited.
Friday, August 23, 13
Multi-ProviderWhat does it mean? Why?
Friday, August 23, 13
A provider manages compute resources* for Vagrant machines.
* But also sets up networking and some basic storage too.
Friday, August 23, 13
Vagrant 1.0: VirtualBox was the only “provider”
Friday, August 23, 13
Why?Because you didn’t love VirtualBox hard enough.
Friday, August 23, 13
VirtualBox isn’t great for every situation.
Friday, August 23, 13
Honestly: VirtualBox is bad.* Its okay, until you realize almost anything else is way better.
Friday, August 23, 13
Multiple providers enable Vagrant to do new and awesome things.
Friday, August 23, 13
People love Vagrant for the workflow. Not for VirtualBox.
Friday, August 23, 13
Other providers let you have that workflow in an environment that works best for you.
Friday, August 23, 13
New use cases...Vagrant where Vagrant has never gone before.
Friday, August 23, 13
Continuous IntegrationAWS, LXC, etc. Fantastic.
Friday, August 23, 13
Develop locally. Test remotely.Work in VirtualBox. Test in AWS (more prod-like).
Friday, August 23, 13
Vagrant in VagrantVMware outside. LXC inside. Etcetera.
Friday, August 23, 13
Corporate EnvironmentsMaximize that VMware investment.
Friday, August 23, 13
etc...That was just a taste.
Friday, August 23, 13
Multi-ProviderHow do I use it?
Friday, August 23, 13
vagrant up --provider=fooWhere foo is “vmware_fusion”, “aws”, etc.
Friday, August 23, 13
Same Vagrantfile,multiple providers.Pretty magical once you see it.
Friday, August 23, 13
Vagrant.configure(“2”) do |config| config.vm.box = “precise64”end
A Vagrantfile
Friday, August 23, 13
$ vagrant box add precise64 \ http://files.vagrantup.com/precise64.box...
$ vagrant box add precise64 \ http://files.vagrantup.com/precise64_vmware_fusion.box...
Some Boxes
Friday, August 23, 13
$ vagrant up --provider=virtualbox...
OR$ vagrant up --provider=vmware_fusion...
Up in VirtualBox or VMware
Friday, August 23, 13
It’s that easy.
Friday, August 23, 13
Best effort.Not every provider can satisfy every Vagrant abstraction, but it won’t fail if it can’t.
Example: AWS networking doesn’t map well to Vagrant networking.
Vagrant + AWS will just ignore networking configurations. Not error. It’ll make a “best effort” to work.
Friday, August 23, 13
BoxesThey’re now tied to providers.
Friday, August 23, 13
$ vagrant box listcentos (virtualbox)precise64 (aws)precise64 (virtualbox)precise64 (vmware_fusion)
Tied to a Provider
Friday, August 23, 13
You need a box for each provider.Packer to the rescue!
Friday, August 23, 13
VirtualBox: OVF exportVMware: VMX exportLXC: rootfs tarballAWS: Metadata (AMI info)
What’s in a box?
It varies by provider. Actually, anything can be in a box. The provider is responsible for reading and verifying structure.
Friday, August 23, 13
Provider-Specific ConfigThe full power of the provider, if you need it.
Abstractions are nice, but sometimes you want to take advantage of specific properties of a provider. For example, AWS can do things VMware can’t, and vice versa.
Provider-specific config lets you do that.
Friday, August 23, 13
Vagrant.configure(“2”) do |config| config.vm.box = “precise64”
config.vm.provider “virtualbox” do |v| v.customize [“modifyvm”, :id, “--memory”, “2048”] end
config.vm.provider “vmware_fusion” do |v| v.vmx[“memsize”] = “2048” endend
Example: Setting Memory
Friday, August 23, 13
Vagrant.configure(“2”) do |config| config.vm.box = “precise64”
config.vm.provider “virtualbox” do |v| v.customize [“modifyvm”, :id, “--memory”, “2048”] end
config.vm.provider “vmware_fusion” do |v| v.vmx[“memsize”] = “2048” endend
Example: Setting Memory
Friday, August 23, 13
Vagrant.configure(“2”) do |config| config.vm.box = “precise64”
config.vm.provider “virtualbox” do |v| v.customize [“modifyvm”, :id, “--memory”, “2048”] end
config.vm.provider “vmware_fusion” do |v| v.vmx[“memsize”] = “2048” endend
Example: Setting Memory
Friday, August 23, 13
PowerfulA place to expose full capabilities of underlying providers.
Friday, August 23, 13
PortableEven if the user doesn’t have that provider installed, the Vagrantfile will still work.
Friday, August 23, 13
Clear PurposeIt makes it clear that that configuration applies ONLY to specific providers.
Friday, August 23, 13
Totally OptionalJust use a normal Vagrantfile if you don’t care.This is for power users.
Friday, August 23, 13
That’s it for providers.Same powerful workflow, clean abstractions, uncompromised flexibility.
Friday, August 23, 13
Real world: People usually choose one provider and stick with it. The important part is you now have choice.
Friday, August 23, 13
PackerFriday, August 23, 13
Automatically create machine images for multiple platforms from a single source config
Friday, August 23, 13
Friday, August 23, 13
Friday, August 23, 13
Machine image: A single deployable unit that contains a pre-configured OS and software.
Friday, August 23, 13
AWS: AMIVMware: VMX + disksVirtualBox: OVF + disksDigitalOcean: Snapshots
Friday, August 23, 13
Useful on its own, without Vagrant. But also very useful with Vagrant.
Friday, August 23, 13
Production and dev are different providers.
Case One
Friday, August 23, 13
“vagrant up” takes too long.
Case Two
Friday, August 23, 13
Multi-provider Vagrant, but want identical images.
Case Three
Friday, August 23, 13
Packer images solve these three cases (and way more).
Friday, August 23, 13
Ew... Images.The anti-image stigma
Friday, August 23, 13
DevOps has historically been against machine images.
Friday, August 23, 13
Important to understand why DevOps has historically been against machine images.
Friday, August 23, 13
Golden images used to be the way.
Friday, August 23, 13
Quarterly, unchanged, blessed image.
Friday, August 23, 13
Getting any changes (ops or dev) in was slow and frustrating.
Friday, August 23, 13
Necessary evil while tooling wasn’t as good as it is today.
Friday, August 23, 13
With modern config management, easy to simply ignore images.
Friday, August 23, 13
Machine images also have a ton of benefits.
Friday, August 23, 13
Super fast infrastructure deployment.
Friday, August 23, 13
Multi-cloud portability
Friday, August 23, 13
Stability and Testability
Friday, August 23, 13
A Modern ToolEmbrace best practices.
Friday, August 23, 13
Packer brings all the benefits of machine images without the downsides.
Friday, August 23, 13
AutomationNo human interaction. Great for CI.
Friday, August 23, 13
Config managementUse Puppet to configure the image, run Puppet after it boots still. Lose nothing.
Friday, August 23, 13
RepeatabilityTemplate goes into version control. Image creation knowledge is now in code.
Friday, August 23, 13
ExampleDocker-ready AMI
Friday, August 23, 13
Template{ "variables": { "aws_access_key": "", "aws_secret_key": "" },
Friday, August 23, 13
Template "builders": [{ "type": "amazon-ebs", "access_key": "{{user `aws_access_key`}}", "secret_key": "{{user `aws_secret_key` }}", "region": "us-east-1", "source_ami": "ami-23d9a94a", "instance_type": "m1.small", "ssh_username": "ubuntu", "ami_name": "packer-docker {{timestamp}}" }],
Friday, August 23, 13
Template "provisioners": [{ "type": "shell", "scripts": [ "scripts/kernel.sh", "scripts/docker.sh" ] }]}
Friday, August 23, 13
BUILD!$ packer build \ -var ‘aws_access_key=YOUR KEY’ \ -var ‘aws_secret_key=YOUR SECRET’ \ template.json...
Friday, August 23, 13
A few minutes later...
Friday, August 23, 13
Easiest AMI creation ever? Just the beginning.
Friday, August 23, 13
Thank you.
vagrantup.com packer.io
Friday, August 23, 13