SlideShare a Scribd company logo
Vagrant hackaton
Session Activities can be found here:
https://github.com/akranga/devops-hackathon-1
Vagrant
- Vagrant will mange VM for you
- Describe VM in configuration file
- Can put configuration in Source Control
- You can allow other to contribute
- You have full control on VM
Vagrant
- Ruby powered command line interface to
VM hosted in your Computer
- Supports multiple VM providers
(VirtualBox by default)
- Allows to create reproducible and
portable environments
Vagrant
- Supports run of Multi-VM environments
- Allows to create/restore snapshots of VM
- Allows package environment
- Environment configuration stored in file
(you can put it in git)
Installing Vagrant
- Download and install latest VirtualBox for your OS:
https://www.virtualbox.org/wiki/Downloads
- Download and install latest vagrant for your OS:
http://www.vagrantup.com/downloads.html
- Update PATH Environment System Variable. Add entries:
- VirtualBox location
- C:Program FilesOracleVirtualBox
- Vagrant location
- C:DevOpsvagrantbin
- Might require extra directories
- C:DevOpsvagrantembeddedbin
- C:DevOpsvagrantembeddedmingwbin
- C:DevOpsvagrantembeddedgemsbin
Vagrant Components
- Command Line Interface
- Vagrantfile
- Boxes
- Synced Folder
- Provisioning
- Multi Machine
- Providers
Command Line Interface
Vagrant basic operating model through CLI vagrant command
Running any vagrant subcommand with --help or –h prints context help
$ vagrant init
$ vagrant up
$ vagrant halt
$ vagrant reload
$ vagrant provision
$ vagrant destroy
$ vagrant ssh
$ vagrant ssh-config
Create initial Vagrant configuratoin
Start or create VM if not exists
Power down VM
Restart VM (useful when you change config)
Run Chef or Puppet scripts
Destroy VM as it never existed
Connect to VM if it is running
Prints SSH configuration
Command Line Interface
shell
$ vagrant box list
$ vagrant box add
$ vagrant box remove
$ vagrant box repackage
$ vagrant box outdated
$ vagrant box update
List all vagrant environments on your PC
Add basebox record to vagrant registry
Remove basebox (doesn’t terminate VM)
Make a snapshot of your VM
Deprecates the VM
Checks and updates a VM if it is out-dated
Additional commands to manage your vagrant environments
Vagrantfile
All VM configuration stored in Ruby DSL file. This file can be placed in git.
When you run vagrant up. Vagrant will check following directories.
./Vagrantfile
/home/mitchellh/projects/foo/Vagrantfile
/home/mitchellh/projects/Vagrantfile
/home/mitchellh/Vagrantfile
/home/Vagrantfile
/Vagrantfile
VAGRANT_CWD to change directory where Vagrant is looking for configuration
Boxes
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url"
end
Minimal Vagrantfile looks like this
Vagrant file contains API versioning.
Vagrantfile (cont)
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url“
(1..3).each do |i|
config.vm.define "slave-#{i}" do |slave|
slave.vm.provision "shell",
inline: "echo hello from slave #{i}"
end
end
end
How many machines will
run this file?
Modifying scripts
config.vm – to mange VM parameters
Vagrantfile
config.vm.box
config.vm.check_update
config.vm.box_url
config.vm.box_version
config.vm.box.hostname
config.vm.provider
cofnig.vm.synced_folder
Name to be associated with box
By default true. Can disable update checks
URL of the VM to download
Version of the basebox file
Hostname of the VM
By default VirtualBox. Can be other
By default current host dir mounted as
/Vagrant. Can map additional directory
inside VM
Modifying scripts
config.ssh – to customize SSH behavior
Vagrantfile
config.ssh.username
config.ssh.password
config.ssh.private_key_path
config.ssh.insert_key
config.ssh.shell
By default vagrant
No pass by default
Path to your SSH key. By default
/home/.vagrant.d/insecure_private_key
By default true. Can disable to use pass
Shell to open when ssh. By default bash -l
Boxes
To create a VM Vagrant needs a basebox file which is typically
Just Enough Operating System.
Baseboxes can be downloaded from Community websites
www.vagrantbox.es Offsite for Vagrant boxes
http://opscode.github.io/bento/ Vagrant boxes optimized for Chef
You can create your own box using
- Packer (http://packer.io)
- Packer templates for Chef optimized boxes can be found:
https://github.com/opscode/bento
Synced Folder
To enable Vagrant to sync files at your Host and Guest machine
By default mapped directory: /vagrant
Permissions: all files in synced folder are 0777
Vagrant Plugins
Vagrant is extremely pluggable.
You can add/costomize almost everything in Vagrant (such as add
VMWare, AWS or Docker providers), Chef or Puppet provisioning etc.
Vagrant has tons of plugins. Official hosted here:
https://github.com/mitchellh/vagrant/tree/master/plugins
Dog Food: API for Vagrant plugins:
http://en.wikipedia.org/wiki/Eating_your_own_dog_food
Most useful Plugins:
- vagrant-omnibus: Chef for Vagrant VMs
- vagrant-cachier: Cache for packages (can be reused across VMs)
- vagrant-berkshelf: Enable Chef cookbook dependency mechanism
Vagrant plugins command
CLI to manage vagrant plugins.
Will be installed in /home/.vagrant.d/gems
Shell
$ vagrant plugin install
$ vagrant plugin list
$ vagrant plugin uninstall
$ vagrant plugin update
Install vagrant plugin
List of installed plugins
Erase plugin
Check plugin and update with newer version
Activity 1
Run a vagrant box.
Activity 1
Go to /activity1 directory
1. Create a vagrant box file:
$ vagrant init vagrant-hackaton http://opscode-vm-
bento.s3.amazonaws.com/vagrant/vmware/opscode_ubuntu-14.04_chef-
provisionerless.box
2. Run command:
This will create a Vagrant configuration which is pointed to URL.
This is a good manner to specify Valid URL so vagrant config can be
repeatable out of box
$ vagrant up
This will start download image from Internet. Please spare our bandwidth
and terminate this process (CTRL+C). We will add image from our local disk
Activity 1
3. Check if nothing installed
$ vagrant box list
5. Spin up VM:
Vagrant should return no images. Otherwise we might overwrite one with
this activity. Or you might want to change name of VM by modifying
Vagrantfile
4. Add box manually with link to local file
$ vagrant box add vagrant-hackaton PATH-TO-BOX/opscode_ubuntu-
14.04_chef-provisionerless.box
$ vagrant up
6. Connect via SSH
$ vagrant ssh
Activity 1
7. Type command
$ vagrant destroy
8. Destroy VM
in VM
$ uptime
$ exit
Activity 2
Customize VM attributes
Activity 2
Go to /activity2 directory
1. Run command
$ vagrant up
This will bring VM to life. Vagrant will reuse basebox from local file because
activity2 VM has same name as VM from activty1
2. In the VM run command
You should get some HTML text on console. Before exiting SSH sesion
in VM
$ sudo apt-get install –y apache2 curl
$ http://localhost
$ exit
Activity 2
3. Modify Vagrantfile
This will instruct Vagrant to use cache on your Host machine all software
installed inside VM (vagrant requires plugin vagrant-cachier)
4. Modify Vagrantfile as per instructions
Vagrantfile: TODO2
config.vm.network :forwarded_port, guest: XXXXX, host: YYYYY
Vagrantfile: TODO1
config.cache.auto_detect = true
Vagrantfile: TODO3
config.vm.synced_folder "webapp/", "/var/www"
5. Modify Vagrantfile as per instructions
Activity 2
5. after Vagrantfile changes we need to raload VM
$ vagrant reload
6. With your browser open: http://localhost:80801
You will get something like this (on the right)
This is allright. We need to create a HTML
7. Create file webapp/index.html
webapp/index.html
<html>
<head><title>Hello World!</title><head>
<body><h1>Hello Vagrant!</h1></body
</html>
Activity 2
No needs to reload VM (directory will be synced automagically )
8. Refresh your browser at: http://localhost:80801
You will get something like this (on the right)
7. Destroy VM
$ vagrant destroy
Activity 3
Provision DB Server
Activity 3
Go to /activity3 directory
1. Run command
$ vagrant up
Vagrant will fail with
Vagrant:
* Unknown configuration section 'berkshelf'.
* Unknown configuration section 'omnibus'.
2. You need to install additional plugins
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ vagrant up
Activity 3
Go to /activity3 directory
1. Run command
$ vagrant up
Vagrantfile has extra configuration that says it will use Chef (Omnibus
packaged) and Berkshelf to download cookbooks. But it doesn’t have plugins
and it will fail:
Vagrant:
* Unknown configuration section 'berkshelf'.
* Unknown configuration section 'omnibus'.
2. Check if plugins installed and install plugins
$ vagrant plugin list
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ vagrant up
Activity 3
Go to /activity3 directory
1. Run command
$ vagrant up
Vagrantfile has extra configuration that says it will use Chef (Omnibus
packaged) and Berkshelf to download cookbooks. But it doesn’t have plugins
and it will fail:
Vagrant:
* Unknown configuration section 'berkshelf'.
* Unknown configuration section 'omnibus'.
2. Check if plugins installed and install plugins
$ vagrant plugin list
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ vagrant up
Retrospective
How many VMs will this file run?
Vagrantfile
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url“
(1..3).each do |i|
config.vm.define "slave-#{i}" do |slave|
slave.vm.provision "shell",
inline: "echo hello from slave #{i}"
end
end
end
Synced folder tricks
Vagrantfile
require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url“
config.vm.synced_folder
"webapp/",
"/var/www/html",
nfs: is_windows
end
Synced folder in windows synchronizes in one direction. To enable it to
synchronize in both directions we need to say that host system is
Windows by setting parameter nfs to true
Synced folder tricks
Vagrantfile
require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
Vagrant.configure "2" do |config|
config.vm.box = “my-vm"
config.vm.box_url = “box-url“
config.vm.synced_folder
"webapp/",
"/var/www/html",
nfs: is_windows
end
Synced folder in windows synchronizes in one direction. To enable it to
synchronize in both directions we need to say that host system is
Windows by setting parameter nfs to true
Synced folder tricks
If Windows host machine you cannot create symlinks in synced directory
However there is a workaround.
1. Add vm customization parameter to Vagrantfile
Vagrantfile
config.vm.customize ["setextradata", :id,
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] if
is_windows
2. Run vagrant up as user Administrator
Shell
$ git clone https://github.com/opscode/bento.git
$ cd bento/packer
bento/packer $ packer build ubuntu-13.10-amd64.json
Creating VM from scratch
Shell
bento/packer $ packer build 
-only=virtualbox 
-var-file=variables.json
ubuntu-13.10-amd64.json
Packer with extra params
variables.json
{
"chef_version": "latest",
"mirror": "../builds/iso/"
}

More Related Content

What's hot (20)

Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and more
Chef Software, Inc.
 
Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with Chef
Michael Lihs
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker Chef
Sean OMeara
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
kognate
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
Anuchit Chalothorn
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
Yury Pliashkou
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
Manuel de la Peña Peña
 
Vagrant crash course
Vagrant crash courseVagrant crash course
Vagrant crash course
Marcus Deglos
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
jtyr
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
Orestes Carracedo
 
Vagrant
VagrantVagrant
Vagrant
Michael Peacock
 
It Works On My Machine: Vagrant for Software Development
It Works On My Machine: Vagrant for Software DevelopmentIt Works On My Machine: Vagrant for Software Development
It Works On My Machine: Vagrant for Software Development
Carlos Perez
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and Docker
Daniel Ku
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with Puppet
Michael Lessard
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
Michele Orselli
 
Linecook - A Chef Alternative
Linecook - A Chef AlternativeLinecook - A Chef Alternative
Linecook - A Chef Alternative
thinkerbot
 
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Julian Dunn
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
Larry Cai
 
Ansible intro
Ansible introAnsible intro
Ansible intro
Hsi-Kai Wang
 
Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and more
Chef Software, Inc.
 
Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with Chef
Michael Lihs
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker Chef
Sean OMeara
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
kognate
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
Yury Pliashkou
 
Vagrant crash course
Vagrant crash courseVagrant crash course
Vagrant crash course
Marcus Deglos
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
jtyr
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
Orestes Carracedo
 
It Works On My Machine: Vagrant for Software Development
It Works On My Machine: Vagrant for Software DevelopmentIt Works On My Machine: Vagrant for Software Development
It Works On My Machine: Vagrant for Software Development
Carlos Perez
 
Deploying an application with Chef and Docker
Deploying an application with Chef and DockerDeploying an application with Chef and Docker
Deploying an application with Chef and Docker
Daniel Ku
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with Puppet
Michael Lessard
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
Michele Orselli
 
Linecook - A Chef Alternative
Linecook - A Chef AlternativeLinecook - A Chef Alternative
Linecook - A Chef Alternative
thinkerbot
 
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Julian Dunn
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
Larry Cai
 

Viewers also liked (11)

DevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureDevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless Architecture
Antons Kranga
 
Robert kiyosaki pdf
Robert kiyosaki pdfRobert kiyosaki pdf
Robert kiyosaki pdf
Restu Pratomo
 
DevTernity - DevOps with smell
DevTernity - DevOps with smellDevTernity - DevOps with smell
DevTernity - DevOps with smell
Antons Kranga
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
Antons Kranga
 
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and KubernetesJava Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Antons Kranga
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless Archtiectures
Antons Kranga
 
Riga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSRiga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWS
Antons Kranga
 
OpenSlava Infrastructure Automation Patterns
OpenSlava   Infrastructure Automation PatternsOpenSlava   Infrastructure Automation Patterns
OpenSlava Infrastructure Automation Patterns
Antons Kranga
 
DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven Infrastructure
Antons Kranga
 
OpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-outOpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-out
Antons Kranga
 
Dev ops with smell v1.2
Dev ops with smell v1.2Dev ops with smell v1.2
Dev ops with smell v1.2
Antons Kranga
 
DevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureDevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless Architecture
Antons Kranga
 
DevTernity - DevOps with smell
DevTernity - DevOps with smellDevTernity - DevOps with smell
DevTernity - DevOps with smell
Antons Kranga
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
Antons Kranga
 
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and KubernetesJava Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Java Day Kharkiv - Next-gen engineering with Docker and Kubernetes
Antons Kranga
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless Archtiectures
Antons Kranga
 
Riga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSRiga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWS
Antons Kranga
 
OpenSlava Infrastructure Automation Patterns
OpenSlava   Infrastructure Automation PatternsOpenSlava   Infrastructure Automation Patterns
OpenSlava Infrastructure Automation Patterns
Antons Kranga
 
DevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven InfrastructureDevOps Hackathon: Session 3 - Test Driven Infrastructure
DevOps Hackathon: Session 3 - Test Driven Infrastructure
Antons Kranga
 
OpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-outOpenSlava 2014 - CloudFoundry inside-out
OpenSlava 2014 - CloudFoundry inside-out
Antons Kranga
 
Dev ops with smell v1.2
Dev ops with smell v1.2Dev ops with smell v1.2
Dev ops with smell v1.2
Antons Kranga
 

Similar to DevOps Hackathon - Session 1: Vagrant (20)

Vagrant
VagrantVagrant
Vagrant
ProfessionalVMware
 
Vagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy StepsVagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy Steps
Trevor Roberts Jr.
 
Cooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialCooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World Tutorial
David Golden
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
Brian Hogan
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
Adam Culp
 
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and BerkshelfChef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Jun Sakata
 
Node.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ BenetechNode.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ Benetech
Christopher Bumgardner
 
Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet
Coveros, Inc.
 
Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and PuppetCreate Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet
Gene Gotimer
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
Soshi Nemoto
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
Intro to vagrant
Intro to vagrantIntro to vagrant
Intro to vagrant
Mantas Klasavicius
 
Quick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with VagrantQuick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with Vagrant
Joe Ferguson
 
Vagrant - Version control your dev environment
Vagrant - Version control your dev environmentVagrant - Version control your dev environment
Vagrant - Version control your dev environment
bocribbz
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development System
Paul Bearne
 
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 -  Working with Wercker WorksheetsOracle Developers APAC Meetup #1 -  Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Darrel Chia
 
Vagrant-Overview
Vagrant-OverviewVagrant-Overview
Vagrant-Overview
Crifkin
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10
Stefan Scherer
 
Professional deployment
Professional deploymentProfessional deployment
Professional deployment
Ivelina Dimova
 
Cooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialCooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World Tutorial
David Golden
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
Brian Hogan
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
Adam Culp
 
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and BerkshelfChef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Chef Workshop: Setup Environment with Chef,Vagrant, and Berkshelf
Jun Sakata
 
Node.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ BenetechNode.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ Benetech
Christopher Bumgardner
 
Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet
Coveros, Inc.
 
Create Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and PuppetCreate Disposable Test Environments with Vagrant and Puppet
Create Disposable Test Environments with Vagrant and Puppet
Gene Gotimer
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
Soshi Nemoto
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
Quick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with VagrantQuick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with Vagrant
Joe Ferguson
 
Vagrant - Version control your dev environment
Vagrant - Version control your dev environmentVagrant - Version control your dev environment
Vagrant - Version control your dev environment
bocribbz
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development System
Paul Bearne
 
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 -  Working with Wercker WorksheetsOracle Developers APAC Meetup #1 -  Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Darrel Chia
 
Vagrant-Overview
Vagrant-OverviewVagrant-Overview
Vagrant-Overview
Crifkin
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10
Stefan Scherer
 
Professional deployment
Professional deploymentProfessional deployment
Professional deployment
Ivelina Dimova
 

Recently uploaded (20)

RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 

DevOps Hackathon - Session 1: Vagrant

  • 1. Vagrant hackaton Session Activities can be found here: https://github.com/akranga/devops-hackathon-1
  • 2. Vagrant - Vagrant will mange VM for you - Describe VM in configuration file - Can put configuration in Source Control - You can allow other to contribute - You have full control on VM
  • 3. Vagrant - Ruby powered command line interface to VM hosted in your Computer - Supports multiple VM providers (VirtualBox by default) - Allows to create reproducible and portable environments
  • 4. Vagrant - Supports run of Multi-VM environments - Allows to create/restore snapshots of VM - Allows package environment - Environment configuration stored in file (you can put it in git)
  • 5. Installing Vagrant - Download and install latest VirtualBox for your OS: https://www.virtualbox.org/wiki/Downloads - Download and install latest vagrant for your OS: http://www.vagrantup.com/downloads.html - Update PATH Environment System Variable. Add entries: - VirtualBox location - C:Program FilesOracleVirtualBox - Vagrant location - C:DevOpsvagrantbin - Might require extra directories - C:DevOpsvagrantembeddedbin - C:DevOpsvagrantembeddedmingwbin - C:DevOpsvagrantembeddedgemsbin
  • 6. Vagrant Components - Command Line Interface - Vagrantfile - Boxes - Synced Folder - Provisioning - Multi Machine - Providers
  • 7. Command Line Interface Vagrant basic operating model through CLI vagrant command Running any vagrant subcommand with --help or –h prints context help $ vagrant init $ vagrant up $ vagrant halt $ vagrant reload $ vagrant provision $ vagrant destroy $ vagrant ssh $ vagrant ssh-config Create initial Vagrant configuratoin Start or create VM if not exists Power down VM Restart VM (useful when you change config) Run Chef or Puppet scripts Destroy VM as it never existed Connect to VM if it is running Prints SSH configuration
  • 8. Command Line Interface shell $ vagrant box list $ vagrant box add $ vagrant box remove $ vagrant box repackage $ vagrant box outdated $ vagrant box update List all vagrant environments on your PC Add basebox record to vagrant registry Remove basebox (doesn’t terminate VM) Make a snapshot of your VM Deprecates the VM Checks and updates a VM if it is out-dated Additional commands to manage your vagrant environments
  • 9. Vagrantfile All VM configuration stored in Ruby DSL file. This file can be placed in git. When you run vagrant up. Vagrant will check following directories. ./Vagrantfile /home/mitchellh/projects/foo/Vagrantfile /home/mitchellh/projects/Vagrantfile /home/mitchellh/Vagrantfile /home/Vagrantfile /Vagrantfile VAGRANT_CWD to change directory where Vagrant is looking for configuration
  • 10. Boxes Vagrantfile Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url" end Minimal Vagrantfile looks like this Vagrant file contains API versioning.
  • 11. Vagrantfile (cont) Vagrantfile Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url“ (1..3).each do |i| config.vm.define "slave-#{i}" do |slave| slave.vm.provision "shell", inline: "echo hello from slave #{i}" end end end How many machines will run this file?
  • 12. Modifying scripts config.vm – to mange VM parameters Vagrantfile config.vm.box config.vm.check_update config.vm.box_url config.vm.box_version config.vm.box.hostname config.vm.provider cofnig.vm.synced_folder Name to be associated with box By default true. Can disable update checks URL of the VM to download Version of the basebox file Hostname of the VM By default VirtualBox. Can be other By default current host dir mounted as /Vagrant. Can map additional directory inside VM
  • 13. Modifying scripts config.ssh – to customize SSH behavior Vagrantfile config.ssh.username config.ssh.password config.ssh.private_key_path config.ssh.insert_key config.ssh.shell By default vagrant No pass by default Path to your SSH key. By default /home/.vagrant.d/insecure_private_key By default true. Can disable to use pass Shell to open when ssh. By default bash -l
  • 14. Boxes To create a VM Vagrant needs a basebox file which is typically Just Enough Operating System. Baseboxes can be downloaded from Community websites www.vagrantbox.es Offsite for Vagrant boxes http://opscode.github.io/bento/ Vagrant boxes optimized for Chef You can create your own box using - Packer (http://packer.io) - Packer templates for Chef optimized boxes can be found: https://github.com/opscode/bento
  • 15. Synced Folder To enable Vagrant to sync files at your Host and Guest machine By default mapped directory: /vagrant Permissions: all files in synced folder are 0777
  • 16. Vagrant Plugins Vagrant is extremely pluggable. You can add/costomize almost everything in Vagrant (such as add VMWare, AWS or Docker providers), Chef or Puppet provisioning etc. Vagrant has tons of plugins. Official hosted here: https://github.com/mitchellh/vagrant/tree/master/plugins Dog Food: API for Vagrant plugins: http://en.wikipedia.org/wiki/Eating_your_own_dog_food Most useful Plugins: - vagrant-omnibus: Chef for Vagrant VMs - vagrant-cachier: Cache for packages (can be reused across VMs) - vagrant-berkshelf: Enable Chef cookbook dependency mechanism
  • 17. Vagrant plugins command CLI to manage vagrant plugins. Will be installed in /home/.vagrant.d/gems Shell $ vagrant plugin install $ vagrant plugin list $ vagrant plugin uninstall $ vagrant plugin update Install vagrant plugin List of installed plugins Erase plugin Check plugin and update with newer version
  • 18. Activity 1 Run a vagrant box.
  • 19. Activity 1 Go to /activity1 directory 1. Create a vagrant box file: $ vagrant init vagrant-hackaton http://opscode-vm- bento.s3.amazonaws.com/vagrant/vmware/opscode_ubuntu-14.04_chef- provisionerless.box 2. Run command: This will create a Vagrant configuration which is pointed to URL. This is a good manner to specify Valid URL so vagrant config can be repeatable out of box $ vagrant up This will start download image from Internet. Please spare our bandwidth and terminate this process (CTRL+C). We will add image from our local disk
  • 20. Activity 1 3. Check if nothing installed $ vagrant box list 5. Spin up VM: Vagrant should return no images. Otherwise we might overwrite one with this activity. Or you might want to change name of VM by modifying Vagrantfile 4. Add box manually with link to local file $ vagrant box add vagrant-hackaton PATH-TO-BOX/opscode_ubuntu- 14.04_chef-provisionerless.box $ vagrant up 6. Connect via SSH $ vagrant ssh
  • 21. Activity 1 7. Type command $ vagrant destroy 8. Destroy VM in VM $ uptime $ exit
  • 23. Activity 2 Go to /activity2 directory 1. Run command $ vagrant up This will bring VM to life. Vagrant will reuse basebox from local file because activity2 VM has same name as VM from activty1 2. In the VM run command You should get some HTML text on console. Before exiting SSH sesion in VM $ sudo apt-get install –y apache2 curl $ http://localhost $ exit
  • 24. Activity 2 3. Modify Vagrantfile This will instruct Vagrant to use cache on your Host machine all software installed inside VM (vagrant requires plugin vagrant-cachier) 4. Modify Vagrantfile as per instructions Vagrantfile: TODO2 config.vm.network :forwarded_port, guest: XXXXX, host: YYYYY Vagrantfile: TODO1 config.cache.auto_detect = true Vagrantfile: TODO3 config.vm.synced_folder "webapp/", "/var/www" 5. Modify Vagrantfile as per instructions
  • 25. Activity 2 5. after Vagrantfile changes we need to raload VM $ vagrant reload 6. With your browser open: http://localhost:80801 You will get something like this (on the right) This is allright. We need to create a HTML 7. Create file webapp/index.html webapp/index.html <html> <head><title>Hello World!</title><head> <body><h1>Hello Vagrant!</h1></body </html>
  • 26. Activity 2 No needs to reload VM (directory will be synced automagically ) 8. Refresh your browser at: http://localhost:80801 You will get something like this (on the right) 7. Destroy VM $ vagrant destroy
  • 28. Activity 3 Go to /activity3 directory 1. Run command $ vagrant up Vagrant will fail with Vagrant: * Unknown configuration section 'berkshelf'. * Unknown configuration section 'omnibus'. 2. You need to install additional plugins $ vagrant plugin install vagrant-berkshelf $ vagrant plugin install vagrant-omnibus $ vagrant up
  • 29. Activity 3 Go to /activity3 directory 1. Run command $ vagrant up Vagrantfile has extra configuration that says it will use Chef (Omnibus packaged) and Berkshelf to download cookbooks. But it doesn’t have plugins and it will fail: Vagrant: * Unknown configuration section 'berkshelf'. * Unknown configuration section 'omnibus'. 2. Check if plugins installed and install plugins $ vagrant plugin list $ vagrant plugin install vagrant-berkshelf $ vagrant plugin install vagrant-omnibus $ vagrant up
  • 30. Activity 3 Go to /activity3 directory 1. Run command $ vagrant up Vagrantfile has extra configuration that says it will use Chef (Omnibus packaged) and Berkshelf to download cookbooks. But it doesn’t have plugins and it will fail: Vagrant: * Unknown configuration section 'berkshelf'. * Unknown configuration section 'omnibus'. 2. Check if plugins installed and install plugins $ vagrant plugin list $ vagrant plugin install vagrant-berkshelf $ vagrant plugin install vagrant-omnibus $ vagrant up
  • 32. How many VMs will this file run? Vagrantfile Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url“ (1..3).each do |i| config.vm.define "slave-#{i}" do |slave| slave.vm.provision "shell", inline: "echo hello from slave #{i}" end end end
  • 33. Synced folder tricks Vagrantfile require 'rbconfig' is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url“ config.vm.synced_folder "webapp/", "/var/www/html", nfs: is_windows end Synced folder in windows synchronizes in one direction. To enable it to synchronize in both directions we need to say that host system is Windows by setting parameter nfs to true
  • 34. Synced folder tricks Vagrantfile require 'rbconfig' is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) Vagrant.configure "2" do |config| config.vm.box = “my-vm" config.vm.box_url = “box-url“ config.vm.synced_folder "webapp/", "/var/www/html", nfs: is_windows end Synced folder in windows synchronizes in one direction. To enable it to synchronize in both directions we need to say that host system is Windows by setting parameter nfs to true
  • 35. Synced folder tricks If Windows host machine you cannot create symlinks in synced directory However there is a workaround. 1. Add vm customization parameter to Vagrantfile Vagrantfile config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] if is_windows 2. Run vagrant up as user Administrator
  • 36. Shell $ git clone https://github.com/opscode/bento.git $ cd bento/packer bento/packer $ packer build ubuntu-13.10-amd64.json Creating VM from scratch
  • 37. Shell bento/packer $ packer build -only=virtualbox -var-file=variables.json ubuntu-13.10-amd64.json Packer with extra params variables.json { "chef_version": "latest", "mirror": "../builds/iso/" }