Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
It Works on My Machine:It Works on My Machine:
Vagrant for Software DevelopmentVagrant for Software Development
Colorado S...
January 20, 2016 Overview of Vagrant 2
Traditional Dev. EnvironmentTraditional Dev. Environment
SCM / CI
Dev. 1 w/ app sta...
January 20, 2016 Overview of Vagrant 3
Source: TIOBE Index for January 2016
http://www.tiobe.com/index.php/content/paperin...
January 20, 2016 Overview of Vagrant 4
Why Use Vagrant?Why Use Vagrant?
●
SOLUTION: Have everyone work on the 'sameSOLUTIO...
January 20, 2016 Overview of Vagrant 5
Vagrant ArchitectureVagrant Architecture
VM
Host OS
Guest OS: CentOS
/home/user1/pr...
January 20, 2016 Overview of Vagrant 6
Basic DemoBasic Demo
January 20, 2016 Overview of Vagrant 7
VagrantVagrant
●
Open source, started in 2010 by MitchellOpen source, started in 20...
January 20, 2016 Overview of Vagrant 8
TerminologyTerminology
●
BoxBox: VM base image for: VM base image for guestguest (a...
January 20, 2016 Overview of Vagrant 9
Basic CommandsBasic Commands
● vagrant –helpvagrant –help
● vagrant global-statusva...
January 20, 2016 Overview of Vagrant 10
Vagrant Up FlowVagrant Up Flow
A
Box repository
download
B
Local box
directory
C
V...
January 20, 2016 Overview of Vagrant 11
Where to Find Boxes?Where to Find Boxes?
●
Hashicorp Atlas (Hashicorp Atlas (https...
January 20, 2016 Overview of Vagrant 12
Vagrant Lifecycle CommandsVagrant Lifecycle Commands
● vagrant upvagrant up
instan...
January 20, 2016 Overview of Vagrant 13
Vagrant SnapshotVagrant Snapshot
●
Vagrant supports VMVagrant supports VM
snapshot...
January 20, 2016 Overview of Vagrant 14
The VagrantfileThe Vagrantfile
●
Vagrantfile in project controls 'up' processVagra...
January 20, 2016 Overview of Vagrant 15
Initializing a ProjectInitializing a Project
$ cd ~/project1
$ vagrant init ubuntu...
January 20, 2016 Overview of Vagrant 16
ProvisioningProvisioning
●
ProvisioningProvisioning occursoccurs
after aafter a bo...
January 20, 2016 Overview of Vagrant 17
Types of ProvisionersTypes of Provisioners
Name Description
file The file provisio...
January 20, 2016 Overview of Vagrant 18
Using Vagrant for Web DevelopmentUsing Vagrant for Web Development
●
Scenario:Scen...
January 20, 2016 Overview of Vagrant 19
BackgroundBackground●
Zurb FoundationZurb Foundation
●
'A front-end Framework is a...
January 20, 2016 Overview of Vagrant 20
Provisioning ApproachProvisioning Approach
● Step 1:Step 1: vagrant upvagrant up
●...
January 20, 2016 Overview of Vagrant 21
Eliminating Step 2Eliminating Step 2
●
The 'setup.sh' script can be replaced with ...
January 20, 2016 Overview of Vagrant 22
Provisioning DemoProvisioning Demo
January 20, 2016 Overview of Vagrant 23
Vagrant ShareVagrant Share
●
Tunnel HTTP and SSH ports through a proxyTunnel HTTP ...
January 20, 2016 Overview of Vagrant 24
Creating BoxenCreating Boxen
January 20, 2016 Overview of Vagrant 25
Box Creation LifecycleBox Creation Lifecycle
$ packer
build
OS ISO image
1st box
$...
January 20, 2016 Overview of Vagrant 26
vagrant packagevagrant package
● vagrant packagevagrant package takes an existing ...
January 20, 2016 Overview of Vagrant 27
PackerPacker
● packerpacker is a tool to create Vagrant boxes fromis a tool to cre...
January 20, 2016 Overview of Vagrant 28
Hashicorp AtlasHashicorp Atlas
Boxes can be built in the cloud using templates pus...
January 20, 2016 Overview of Vagrant 29
Box VersioningBox Versioning
●
Boxes may be versioned usingBoxes may be versioned ...
January 20, 2016 Overview of Vagrant 30
Self-hosted VersioningSelf-hosted Versioning
●
Generate and hostGenerate and host
...
January 20, 2016 Overview of Vagrant 31
Provisioning vs. PackagingProvisioning vs. Packaging
●
Best to take a base box, pr...
January 20, 2016 Overview of Vagrant 32
Multiple MachinesMultiple Machines
●
Mulit-machine can beMulit-machine can be
spec...
January 20, 2016 Overview of Vagrant 33
Vagrant SecurityVagrant Security
●
By default, Vagrant boxes areBy default, Vagran...
January 20, 2016 Overview of Vagrant 34
Other TipsOther Tips
●
Unix vs. DOS line feeds, confuses shell and file provisione...
January 20, 2016 Overview of Vagrant 35
Thank You!Thank You!
●
Sample Vagrant project with Django andSample Vagrant projec...
Upcoming SlideShare
Loading in …5
×

of

It Works On My Machine: Vagrant for Software Development Slide 1 It Works On My Machine: Vagrant for Software Development Slide 2 It Works On My Machine: Vagrant for Software Development Slide 3 It Works On My Machine: Vagrant for Software Development Slide 4 It Works On My Machine: Vagrant for Software Development Slide 5 It Works On My Machine: Vagrant for Software Development Slide 6 It Works On My Machine: Vagrant for Software Development Slide 7 It Works On My Machine: Vagrant for Software Development Slide 8 It Works On My Machine: Vagrant for Software Development Slide 9 It Works On My Machine: Vagrant for Software Development Slide 10 It Works On My Machine: Vagrant for Software Development Slide 11 It Works On My Machine: Vagrant for Software Development Slide 12 It Works On My Machine: Vagrant for Software Development Slide 13 It Works On My Machine: Vagrant for Software Development Slide 14 It Works On My Machine: Vagrant for Software Development Slide 15 It Works On My Machine: Vagrant for Software Development Slide 16 It Works On My Machine: Vagrant for Software Development Slide 17 It Works On My Machine: Vagrant for Software Development Slide 18 It Works On My Machine: Vagrant for Software Development Slide 19 It Works On My Machine: Vagrant for Software Development Slide 20 It Works On My Machine: Vagrant for Software Development Slide 21 It Works On My Machine: Vagrant for Software Development Slide 22 It Works On My Machine: Vagrant for Software Development Slide 23 It Works On My Machine: Vagrant for Software Development Slide 24 It Works On My Machine: Vagrant for Software Development Slide 25 It Works On My Machine: Vagrant for Software Development Slide 26 It Works On My Machine: Vagrant for Software Development Slide 27 It Works On My Machine: Vagrant for Software Development Slide 28 It Works On My Machine: Vagrant for Software Development Slide 29 It Works On My Machine: Vagrant for Software Development Slide 30 It Works On My Machine: Vagrant for Software Development Slide 31 It Works On My Machine: Vagrant for Software Development Slide 32 It Works On My Machine: Vagrant for Software Development Slide 33 It Works On My Machine: Vagrant for Software Development Slide 34 It Works On My Machine: Vagrant for Software Development Slide 35
Upcoming SlideShare
Vagrant For DevOps
Next
Download to read offline and view in fullscreen.

5 Likes

Share

Download to read offline

It Works On My Machine: Vagrant for Software Development

Download to read offline

Vagrant is a command-line interface for simplifying the use of virtual machines (VM's). Vagrant allows teams to standardize their software development workflows by offering a uniform and portable interface to provision and run VM's on different operating platforms such as Mac OS X, Windows, and Linux and achieve identical results. It supports all the major virtualization solutions such as VirtualBox, VMWare, and Hyper-V and supports configuration tools that range from simple shell scripts to powerful Chef and Puppet recipes. Developers simply invoke “vagrant up” and immediately enjoy a standard, consistent, and reproducible VM for software development and testing.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

It Works On My Machine: Vagrant for Software Development

  1. 1. It Works on My Machine:It Works on My Machine: Vagrant for Software DevelopmentVagrant for Software Development Colorado Springs Open Source Software MeetupColorado Springs Open Source Software Meetup 1/20/20161/20/2016 Carlos PerezCarlos Perez perez@doorstep.comperez@doorstep.com
  2. 2. January 20, 2016 Overview of Vagrant 2 Traditional Dev. EnvironmentTraditional Dev. Environment SCM / CI Dev. 1 w/ app stack Mac OS X Test / Stage /Prod Dev. 2 w/ app stack Linux Ubuntu Dev. 3 w/ app stack MS Windows Dev. 4 w/ app stack Everyone has their own application stack and machine dependencies. This is known as the 'works on my machine' problem.
  3. 3. January 20, 2016 Overview of Vagrant 3 Source: TIOBE Index for January 2016 http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html TIOBE Index of Popular Programming Languages
  4. 4. January 20, 2016 Overview of Vagrant 4 Why Use Vagrant?Why Use Vagrant? ● SOLUTION: Have everyone work on the 'sameSOLUTION: Have everyone work on the 'same machine' bymachine' by declaratively specifying thedeclaratively specifying the configuration for a VM instanceconfiguration for a VM instance ● Based on virtual machines you already knowBased on virtual machines you already know (VirtualBox, VMWare, Hyper-V, etc.)(VirtualBox, VMWare, Hyper-V, etc.) ● Easy to configure, reproducible, portableEasy to configure, reproducible, portable ● SCM friendly files (git, tfvc)SCM friendly files (git, tfvc) ● DevOps friendly: write and test provisioningDevOps friendly: write and test provisioning 'scripts' (Chef, Puppet, Ansible, etc.)'scripts' (Chef, Puppet, Ansible, etc.)
  5. 5. January 20, 2016 Overview of Vagrant 5 Vagrant ArchitectureVagrant Architecture VM Host OS Guest OS: CentOS /home/user1/projects/web1 => /vagrant Web Browser IDE / Editor git Apache PHP MySQL port 2222 => 22; port 8000 => 80 Virtualbox port forwards synced folders
  6. 6. January 20, 2016 Overview of Vagrant 6 Basic DemoBasic Demo
  7. 7. January 20, 2016 Overview of Vagrant 7 VagrantVagrant ● Open source, started in 2010 by MitchellOpen source, started in 2010 by Mitchell HashimotoHashimoto ● MIT LicenseMIT License ● Website:Website: https://www.vagrantup.comhttps://www.vagrantup.com ● Docs:Docs: https://docs.vagrantup.com/v2/https://docs.vagrantup.com/v2/ ● Installation:Installation: ● Vagrant (apt-get, .deb, .dmg, .msi)Vagrant (apt-get, .deb, .dmg, .msi) ● VM (VM (https://www.virtualbox.orghttps://www.virtualbox.org)) ● Windows: PuTTY, PuTTYgenWindows: PuTTY, PuTTYgen
  8. 8. January 20, 2016 Overview of Vagrant 8 TerminologyTerminology ● BoxBox: VM base image for: VM base image for guestguest (a.k.a.(a.k.a. templatetemplate)) ● ProviderProvider: virtualization layer on: virtualization layer on hosthost (VirtualBox, VMWare, etc.)(VirtualBox, VMWare, etc.) ● ProvisionerProvisioner: system for automating software: system for automating software installations (shell, chef, etc.)installations (shell, chef, etc.) ● ProjectProject: directory containing Vagrantfile and: directory containing Vagrantfile and typically the root of the 'synced folder'typically the root of the 'synced folder'
  9. 9. January 20, 2016 Overview of Vagrant 9 Basic CommandsBasic Commands ● vagrant –helpvagrant –help ● vagrant global-statusvagrant global-status: show: show environmentsenvironments ● vagrant statusvagrant status: show project status: show project status ● vagrant box listvagrant box list: show installed boxes: show installed boxes
  10. 10. January 20, 2016 Overview of Vagrant 10 Vagrant Up FlowVagrant Up Flow A Box repository download B Local box directory C VM instance directory import 1) vagrant up 2) If box does not exist, download from 'A' and add to 'B' 3) If VM does not exist, import from local box directory 'B' and copy to 'C' 4) Start VM, networking, port forwards, import SSH keys 5) Mount shared folders 6) Provision VM 7) vagrant ssh https://atlas.hashicorp.com/ubuntu/boxes/trusty32/versions/20151218.0.1/ provider/virtualbox.box ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-trusty32 ~/VirtualBox VMs/trusty32_default_1452718546328_49107
  11. 11. January 20, 2016 Overview of Vagrant 11 Where to Find Boxes?Where to Find Boxes? ● Hashicorp Atlas (Hashicorp Atlas (https://atlas.hashicorp.com/https://atlas.hashicorp.com/)) ● Cataloged using theCataloged using the vendor/boxnamevendor/boxname notationnotation ● Public catalogs (Public catalogs (http://www.vagrantbox.es/http://www.vagrantbox.es/)) ● Think craigslist-- boxes may not be secureThink craigslist-- boxes may not be secure ● Build your own usingBuild your own using packerpacker oror vagrantvagrant packagepackage ● Installation ISO + packer + JSON config = your boxInstallation ISO + packer + JSON config = your box ● Host on your own web serverHost on your own web server
  12. 12. January 20, 2016 Overview of Vagrant 12 Vagrant Lifecycle CommandsVagrant Lifecycle Commands ● vagrant upvagrant up instantiate, provision,instantiate, provision, start VMstart VM ● vagrant haltvagrant halt: stop: stop / poweroff VM/ poweroff VM ● vagrant destoryvagrant destory:: stop / delete VMstop / delete VM ● vagrant suspendvagrant suspend // vagrant resumevagrant resume running powered off suspended non- existent resumesuspend up halt destroy up
  13. 13. January 20, 2016 Overview of Vagrant 13 Vagrant SnapshotVagrant Snapshot ● Vagrant supports VMVagrant supports VM snapshotssnapshots ● vagrant snapshot pushvagrant snapshot push // poppop ● vagrant snapshot savevagrant snapshot save // restorerestore ● vagrant snapshot listvagrant snapshot list ● vagrant snapshotvagrant snapshot deletedelete ● Note: do not mixNote: do not mix push/pop andpush/pop and save/restoresave/restore snapshots VM instance push pop
  14. 14. January 20, 2016 Overview of Vagrant 14 The VagrantfileThe Vagrantfile ● Vagrantfile in project controls 'up' processVagrantfile in project controls 'up' process ● Ruby languageRuby language ● Located in project directory and checked into SCMLocated in project directory and checked into SCM ● vagrant upvagrant up creates .vagrant directory (add tocreates .vagrant directory (add to .gitignore).gitignore) ● Other Vagrantfiles are consulted duringOther Vagrantfiles are consulted during vagrant upvagrant up (process called 'merging')(process called 'merging') ● ~/.vagrant.d/boxes/.../Vagrantfile, include/_Vagrantfile~/.vagrant.d/boxes/.../Vagrantfile, include/_Vagrantfile ● ~/.vagrant.d~/.vagrant.d ● Vagrantfile in the project hierarchyVagrantfile in the project hierarchy
  15. 15. January 20, 2016 Overview of Vagrant 15 Initializing a ProjectInitializing a Project $ cd ~/project1 $ vagrant init ubuntu/trusty32 $ vagrant up
  16. 16. January 20, 2016 Overview of Vagrant 16 ProvisioningProvisioning ● ProvisioningProvisioning occursoccurs after aafter a boxbox isis importedimported into a VMinto a VM ● Provisioning usuallyProvisioning usually occurs once, but canoccurs once, but can be run againbe run again ● vagrant provisionvagrant provision ● Vagrantfile config.vm.provisionVagrantfile config.vm.provision run: 'always', etc.run: 'always', etc. ... config.vm.provision "shell", inline: <<-SHELL sudo apt-get update sudo apt-get install -y apache2 SHELL ...
  17. 17. January 20, 2016 Overview of Vagrant 17 Types of ProvisionersTypes of Provisioners Name Description file The file provisioner allows you to upload a file or directory from the host machine to the guest machine. shell The shell provisioner allows you to upload and execute a script within the guest machine. ansible, ansible_local The Ansible provisioner allows you to provision the guest using Ansible playbooks by executing ansible-playbook from the Vagrant host; ansible_local is executed on the guest machine. cfengine The CFEngine provisioner allows you to provision the guest using CFEngine. chef_solo, chef_zero, chef_client, chef_apply Provision with Chef 'cookbooks' and 'recipes' using a Chef Server. chef_solo doesn't need a server and is easy to setup. docker The docker provisioner can automatically install Docker, pull Docker containers, and configure certain containers to run on boot. puppet, puppet_server The Puppet provisioner, 'puppet' does not require a Puppet Master. salt The salt Provisioner allows you to provision the guest using Salt states. https://docs.vagrantup.com/v2/provisioning/index.html
  18. 18. January 20, 2016 Overview of Vagrant 18 Using Vagrant for Web DevelopmentUsing Vagrant for Web Development ● Scenario:Scenario: ● Zurb Foundation for front-end (v. 6.1.0, downloaded)Zurb Foundation for front-end (v. 6.1.0, downloaded) ● Python Django for back-end (v. 1.9.1, not stock Ubuntu)Python Django for back-end (v. 1.9.1, not stock Ubuntu) ● IDE on host: Sublime TextIDE on host: Sublime Text ● Challenges:Challenges: ● Zurb Foundation installed using npm and bootstrapped usingZurb Foundation installed using npm and bootstrapped using CLI and Sass/CSS toolchainCLI and Sass/CSS toolchain ● Django downloaded using pip and bootstrapped using CLIDjango downloaded using pip and bootstrapped using CLI ● Django runs in its own Python3 virtualenvDjango runs in its own Python3 virtualenv ● Don't forget the database!Don't forget the database!
  19. 19. January 20, 2016 Overview of Vagrant 19 BackgroundBackground● Zurb FoundationZurb Foundation ● 'A front-end Framework is a collection of HTML, CSS, and JavaScript containing design patterns that'A front-end Framework is a collection of HTML, CSS, and JavaScript containing design patterns that you can build upon. They keep you from wasting time rewriting boring, boilerplate code over and overyou can build upon. They keep you from wasting time rewriting boring, boilerplate code over and over again.' –again.' – http://foundation.zurb.com/learn/about.htmlhttp://foundation.zurb.com/learn/about.html ● DjangoDjango ● 'With Django, you can take Web applications from concept to launch in a matter of hours. Django takes'With Django, you can take Web applications from concept to launch in a matter of hours. Django takes care of much of the hassle of Web development, so you can focus on writing your app without needingcare of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.' –to reinvent the wheel. It’s free and open source.' – https://www.djangoproject.com/start/overview/https://www.djangoproject.com/start/overview/ ● BowerBower ● 'Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files. Bower'Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files. Bower doesn’t concatenate or minify code or do anything else - it just installs the right versions of thedoesn’t concatenate or minify code or do anything else - it just installs the right versions of the packages you need and their dependencies.' –packages you need and their dependencies.' – http://bower.io/http://bower.io/ ● npmnpm ● 'npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update'npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you're sharing.' –the code that you're sharing.' – https://docs.npmjs.com/getting-started/what-is-npmhttps://docs.npmjs.com/getting-started/what-is-npm ● pippip ● 'pip is a package management system used to install and manage software packages written in'pip is a package management system used to install and manage software packages written in Python.' –Python.' – https://en.wikipedia.org/wiki/Pip_(package_managerhttps://en.wikipedia.org/wiki/Pip_(package_manager))
  20. 20. January 20, 2016 Overview of Vagrant 20 Provisioning ApproachProvisioning Approach ● Step 1:Step 1: vagrant upvagrant up ● Import VMImport VM ● Provision usingProvision using AnsibleAnsible – Install latest NodeJSInstall latest NodeJS – Install 'step 2'Install 'step 2' dependenciesdependencies – Install PostgreSQLInstall PostgreSQL – Create vagrant user inCreate vagrant user in databasedatabase ● Step 2:Step 2: vagrantvagrant sshssh ● Run setup.sh scriptRun setup.sh script – Excute 'npm install'Excute 'npm install' and 'bower install'and 'bower install' – 'foundation build' to'foundation build' to build CSS from Sassbuild CSS from Sass – Install PythonInstall Python virtualenvvirtualenv – Django 'migrate' DBDjango 'migrate' DB and 'createsuperuser'and 'createsuperuser' ● Run only one time!Run only one time!
  21. 21. January 20, 2016 Overview of Vagrant 21 Eliminating Step 2Eliminating Step 2 ● The 'setup.sh' script can be replaced with theThe 'setup.sh' script can be replaced with the Ansible provisioner insteadAnsible provisioner instead ● Advantages: can go into 'airplane mode' afterAdvantages: can go into 'airplane mode' after provisioningprovisioning ● Ansible package modules: pip, bower, npmAnsible package modules: pip, bower, npm ● Bower and npm directories in a VM instanceBower and npm directories in a VM instance directory (/home/vagrant) not project directorydirectory (/home/vagrant) not project directory ● Modifications will be left as an exercise for theModifications will be left as an exercise for the readerreader
  22. 22. January 20, 2016 Overview of Vagrant 22 Provisioning DemoProvisioning Demo
  23. 23. January 20, 2016 Overview of Vagrant 23 Vagrant ShareVagrant Share ● Tunnel HTTP and SSH ports through a proxyTunnel HTTP and SSH ports through a proxy ● Example: http://ghastly-wombat-4051.vagrantshare.comExample: http://ghastly-wombat-4051.vagrantshare.com ● Requires account on atlas.hasicorp.comRequires account on atlas.hasicorp.com ● vagrant loginvagrant login ● vagrant sharevagrant share ● URL can be on your domain (--domain)URL can be on your domain (--domain) ● Share SSH sessionsShare SSH sessions ● vagrant share --sshvagrant share --ssh ● vagrant connect --sshvagrant connect --ssh
  24. 24. January 20, 2016 Overview of Vagrant 24 Creating BoxenCreating Boxen
  25. 25. January 20, 2016 Overview of Vagrant 25 Box Creation LifecycleBox Creation Lifecycle $ packer build OS ISO image 1st box $ vagrant package 2nd box etc... ● packerpacker ● install from installation ISO's to temp VMinstall from installation ISO's to temp VM ● vagrant packagevagrant package ● import from existing VM with Vagrant customizaionsimport from existing VM with Vagrant customizaions VM instance $ vagrant box add $ vagrant up
  26. 26. January 20, 2016 Overview of Vagrant 26 vagrant packagevagrant package ● vagrant packagevagrant package takes an existing VM andtakes an existing VM and outputs a re-usable .box fileoutputs a re-usable .box file ● The .box file can be added to the repositoryThe .box file can be added to the repository usingusing vagrant box addvagrant box add ● It can be copied up to a web server for URLIt can be copied up to a web server for URL distributiondistribution ● Using existing Vagrant instance is easiest as it hasUsing existing Vagrant instance is easiest as it has 'vagrant' user, networking, VB guest additions, etc.'vagrant' user, networking, VB guest additions, etc. $ vagrant package VM instance my_precious.box $ vagrant box add
  27. 27. January 20, 2016 Overview of Vagrant 27 PackerPacker ● packerpacker is a tool to create Vagrant boxes fromis a tool to create Vagrant boxes from bare metal virtual machinesbare metal virtual machines ● https://www.packer.io/https://www.packer.io/ ● Packer templates are JSON files:Packer templates are JSON files: ● Chef / bento:Chef / bento: https://github.com/chef/bentohttps://github.com/chef/bento – used internally by Chef to build base boxesused internally by Chef to build base boxes ● Boxcutter:Boxcutter: https://github.com/boxcutterhttps://github.com/boxcutter – community-driven templates that are CM tool-agnosticcommunity-driven templates that are CM tool-agnostic $ packer build OS ISO image my_precious.box
  28. 28. January 20, 2016 Overview of Vagrant 28 Hashicorp AtlasHashicorp Atlas Boxes can be built in the cloud using templates pushed up by packer. For example, need to build a box for VMWare desktop but you don't have VMWare? Not a problem. See http://atlas.hashicorp.com for more information.
  29. 29. January 20, 2016 Overview of Vagrant 29 Box VersioningBox Versioning ● Boxes may be versioned usingBoxes may be versioned using semanticsemantic versioningversioning (e.g. 1.0.9)(e.g. 1.0.9) ● Versioning is default for Atlas hosted boxesVersioning is default for Atlas hosted boxes ● NoteNote vendor/boxnamevendor/boxname conventionconvention ● For self-hosted boxes, couple of choices...For self-hosted boxes, couple of choices... ● No versioning, use naming convention instead inNo versioning, use naming convention instead in vagrant box addvagrant box add (e.g. 'django-v1.0.0')(e.g. 'django-v1.0.0') ● Yes versioning, use 'metadata.json' versioningYes versioning, use 'metadata.json' versioning control in Vagrantcontrol in Vagrant
  30. 30. January 20, 2016 Overview of Vagrant 30 Self-hosted VersioningSelf-hosted Versioning ● Generate and hostGenerate and host metadata.json yourselfmetadata.json yourself ● Nice tool to gen jsonNice tool to gen json ● pip install vagrant-metadatapip install vagrant-metadata ● Upload to web orUpload to web or network sharenetwork share ● Using box:Using box: ● vagrant initvagrant init cperez/djsitecperez/djsite http://localhost/boxes/djsite/metadata.jsonhttp://localhost/boxes/djsite/metadata.json ● Upgrading:Upgrading: vagrantvagrant box updatebox update { "name": "cperez/djsite", "description": "Django box", "baseurl": "http://localhost/boxes/djsite", "versions": [ { "version": "1.0.0", "providers": [ { "name": "virtualbox", "checksum_type": "sha1", "checksum": "5bb7c7580712a547a7f30da920c2fb1e2430f904" , "url": "http://localhost/boxes/djsite/1.0.0/virtu albox/djsite-1.0.0.box" } ] } ] }
  31. 31. January 20, 2016 Overview of Vagrant 31 Provisioning vs. PackagingProvisioning vs. Packaging ● Best to take a base box, provision it, and thenBest to take a base box, provision it, and then 'freeze' it using'freeze' it using vagrant packagevagrant package ● speeds upspeeds up vagrant destroyvagrant destroy // vagrant upvagrant up cyclecycle ● can include a Vagrantfile with the box with preferredcan include a Vagrantfile with the box with preferred settings (such as networking and port forwards)settings (such as networking and port forwards) ● Nice recipes:Nice recipes: – https://github.com/pro-vagranthttps://github.com/pro-vagrant ● Best to keep box packaging scripts in separateBest to keep box packaging scripts in separate directorydirectory
  32. 32. January 20, 2016 Overview of Vagrant 32 Multiple MachinesMultiple Machines ● Mulit-machine can beMulit-machine can be specified inspecified in VagrantfileVagrantfile ● Name each machineName each machine ● vagrant ssh webvagrant ssh web ● Networking optionsNetworking options allow for machine toallow for machine to machinemachine communicationscommunications Vagrant.configure("2") do |config| config.vm.provision "shell", inline: "echo Hello" config.vm.define "web" do |web| web.vm.box = "apache" end config.vm.define "db" do |db| db.vm.box = "mysql" end end
  33. 33. January 20, 2016 Overview of Vagrant 33 Vagrant SecurityVagrant Security ● By default, Vagrant boxes areBy default, Vagrant boxes are insecureinsecure ● For local development, not productionFor local development, not production ● Keep your box behind a firewall, not on Internet!Keep your box behind a firewall, not on Internet! ● Public boxes contain the 'insecure private key'Public boxes contain the 'insecure private key' ● https://github.com/mitchellh/vagrant/tree/master/keyshttps://github.com/mitchellh/vagrant/tree/master/keys ● Default password is 'vagrant'Default password is 'vagrant' ● OnOn vagrant upvagrant up, the insecure key is replaced with a, the insecure key is replaced with a local 'insecure key'local 'insecure key' ● vagrant packagevagrant package may create box with newmay create box with new vagrant_private_keyvagrant_private_key
  34. 34. January 20, 2016 Overview of Vagrant 34 Other TipsOther Tips ● Unix vs. DOS line feeds, confuses shell and file provisioners. Standardize onUnix vs. DOS line feeds, confuses shell and file provisioners. Standardize on Unix line endings (LF) in your IDE's.Unix line endings (LF) in your IDE's. ● C++ developers: cannot execute built binaries from /vagrant mount? Copy toC++ developers: cannot execute built binaries from /vagrant mount? Copy to /home/vagrant./home/vagrant. ● Running FreeBSD and the nfs folder sync doesn't work because your homeRunning FreeBSD and the nfs folder sync doesn't work because your home directory is encrypted? Try 'rsync' option for folder syncing.directory is encrypted? Try 'rsync' option for folder syncing. ● Box versioning: best to specify a version in Vagrantfile rather thanBox versioning: best to specify a version in Vagrantfile rather than downloading latest base box.downloading latest base box. ● Ubuntu guest: remove 'mesg n' in /root/.profile to eliminate annoying 'default:Ubuntu guest: remove 'mesg n' in /root/.profile to eliminate annoying 'default: stdin: is not a tty' message when using shell provisioner.stdin: is not a tty' message when using shell provisioner.
  35. 35. January 20, 2016 Overview of Vagrant 35 Thank You!Thank You! ● Sample Vagrant project with Django andSample Vagrant project with Django and Foundation:Foundation: https://github.com/coloradocarlos/djfoundation1https://github.com/coloradocarlos/djfoundation1 ● Contact: perez@doorstep.comContact: perez@doorstep.com
  • VybhavaRobotics

    May. 21, 2018
  • GerardMcCann4

    Mar. 21, 2018
  • kv82579

    Feb. 24, 2018
  • sadhiesh

    May. 30, 2017
  • AinyRusly1

    Aug. 8, 2016

Vagrant is a command-line interface for simplifying the use of virtual machines (VM's). Vagrant allows teams to standardize their software development workflows by offering a uniform and portable interface to provision and run VM's on different operating platforms such as Mac OS X, Windows, and Linux and achieve identical results. It supports all the major virtualization solutions such as VirtualBox, VMWare, and Hyper-V and supports configuration tools that range from simple shell scripts to powerful Chef and Puppet recipes. Developers simply invoke “vagrant up” and immediately enjoy a standard, consistent, and reproducible VM for software development and testing.

Views

Total views

8,984

On Slideshare

0

From embeds

0

Number of embeds

7,310

Actions

Downloads

44

Shares

0

Comments

0

Likes

5

×