SlideShare a Scribd company logo
Introduction to Vagrant
      Marcelo Correia Pinheiro
Friday, March 29, 13
Friday, March 29, 13
Friday, March 29, 13
What is Vagrant?
                A tool to build development environments based on
                virtual machines
                Focused to create environments that are similar as
                possible or identical with production servers
                Created by Mitchell Hashimoto
                Written in Ruby
                Initially builted on top of VirtualBox API, today offers
                VMWare Fusion support (as $79 per licence)


Friday, March 29, 13
How I install Vagrant?


                Get VirtualBox first
                Download installer on Vagrant site (Debian, CentOS,
                Windows, OSX, other OS’s)
                Get a Vagrant box




Friday, March 29, 13
What is a Vagrant Box?


                Is a previously builted Vagrant virtual machine image,
                ready-to-run
                Available in a lot of platforms (Linux, Windows, BSD)
                You can create one! :)




Friday, March 29, 13
How I add a box?

                Great box repository: www.vagrantbox.es
                Run this command:



           $ vagrant box add <name> <url> <provider> # virtualbox




Friday, March 29, 13
How I create a environment?

                Inside your project, create a Vagrantfile:



           $ vagrant init <your box name>




Friday, March 29, 13
How I create a environment?

           # -*- mode: ruby -*-
           # vi: set ft=ruby :

           Vagrant.configure("2") do |config|
             # All Vagrant configuration is done here. The most common configuration
             # options are documented and commented below. For a complete reference,
             # please see the online documentation at vagrantup.com.

               # Every Vagrant virtual environment requires a box to build off of.
               config.vm.box = "my_precious_box"

             # ...
             # A list of options here
             # ...
           end




Friday, March 29, 13
How I start to use it?

                Simply run this command:



           $ vagrant up




Friday, March 29, 13
How I connect to it?

                Easy:



           $ vagrant ssh




Friday, March 29, 13
How I stop it?

                Easy:



           $ vagrant halt




Friday, March 29, 13
How I restart it?

                Easy:



           $ vagrant reload




Friday, March 29, 13
How I access it?
                You need to set forwarding ports between guest and
                host to work (bind on 0.0.0.0!)
                Just add the following code in your Vagrantfile, restart
                server and access in browser:

           # -*- mode: ruby -*-
           # vi: set ft=ruby :

           Vagrant.configure("2") do |config|
             # ...

               config.vm.network :forwarded_port, guest: 3000, host: 3000

             # ...
           end



Friday, March 29, 13
How I customize it?
                You can change memory, CPU cores and other things in Vagrantfile
                Just see VBoxManage options
                Example:


           # -*- mode: ruby -*-
           # vi: set ft=ruby :

           Vagrant.configure("2") do |config|
             # ...

               config.vm.provider :virtualbox do |vb|
                 vb.customize [ 'modifyvm', :id, '--memory', '1024' ]
                 vb.customize [ 'modifyvm', :id, '--cpus',   '4'    ]
               end

             # ...
           end




Friday, March 29, 13
That’s it?
                Of course, no! :)
                It’s time to configure environment using available provisioners to install
                required software:
                       Chef Solo
                       Chef Server
                       Puppet Apply
                       Puppet Server
                       Shell
                       CFEngine (experimental)



Friday, March 29, 13
Using Chef Solo

                First, run chef-solo installation based on Opscode
                website in your guest:




           $ sudo true && curl -L https://www.opscode.com/chef/install.sh | sudo bash




Friday, March 29, 13
Using Chef Solo
                Get all necessary recipes from Opscode site
                       Great repo with a lot of recipes
                       Manual recipe dependency resolution sometimes

           # -*- mode: ruby -*-
           # vi: set ft=ruby :

           Vagrant.configure("2") do |config|
             # ...

               config.vm.provision :chef_solo do |chef|
                 chef.add_recipe 'apt'
                 chef.add_recipe 'build-essential'
                 chef.add_recipe 'ruby1.9'
                 chef.add_recipe 'mondodb'
                 chef.add_recipe 'redis'
               end

             # ...
           end

Friday, March 29, 13
Using Chef Solo
                Or Install berkshelf
                       Vagrant plugin very similar to Bundler
                       generate a Berksfile in app root and run:

           source :opscode

           cookbook 'mysql'
           cookbook 'nginx', '~> 0.101.5'




           $ berks install --path vendor/cookbooks




Friday, March 29, 13
Using Chef Server
                Configure Vagrantfile to use a Chef Server as a
                repository
                Requires a URL and a PEM key to connect

           # -*- mode: ruby -*-
           # vi: set ft=ruby :

           Vagrant.configure("2") do |config|
             # ...

               config.vm.provision :chef_client do |chef|
                 chef.chef_server_url     = 'https://your-chef-server.devops.com'
                 chef.validation_key_path = 'your-private-key.pem'
               end

             # ...
           end


Friday, March 29, 13
Using Puppet Apply

                Install Puppet from official repository in your guest VM:




           # wget http://apt.puppetlabs.com/puppetlabs-release-squeeze.deb
           # dpkg -i puppetlabs-release-squeeze.deb




Friday, March 29, 13
Using Puppet Apply

                Change Vagrantfile to use Puppet manifest files:


           # -*- mode: ruby -*-
           # vi: set ft=ruby :

           Vagrant.configure("2") do |config|
             # ...

               config.vm.provision :puppet do |puppet|
                 puppet.manifests_path = 'manifests'
                 puppet.manifest_file = 'my-devops-puppet-manifest.pp'
               end

             # ...
           end



Friday, March 29, 13
Using Puppet Apply


                Write Puppet manifest with all software that your app
                needs
                Depending of what you need, some additional
                configuration is required




Friday, March 29, 13
Using Puppet Server
                Change Vagrantfile to connect on a Puppet Server
                Set node hostname if you need
                Add some options too

           # -*- mode: ruby -*-
           # vi: set ft=ruby :

           Vagrant.configure("2") do |config|
             # ...

               config.vm.provision :puppet_server do |puppet|
                 puppet.puppet_server = 'http://your-master-of-puppets.devops.com'
                 puppet.puppet_node   = 'my-precious-puppet.devops.com'
                 puppet.options       = '--verbose --debug'
               end

             # ...
           end


Friday, March 29, 13
Using Shell
                Create a single bash script that installs all you need:


           #!/bin/bash

           apt-get update

           # base
           apt-get install --yes python nginx mongodb-server redis-server

           # others
           apt-get install --yes curl tmux htop

           (...)

           # some additional configuration here

           (...)



Friday, March 29, 13
Installing software

                Easy:



           $ vagrant provision




Friday, March 29, 13
Creating a custom box
                You can create custom boxes to distribute between
                development teams
                Requires a fresh installation of a virtual machine based
                on Vagrant conventions and some manual configuration
                Awesome advantage: you can repackage a existent
                Vagrant package after updating a existent VM
                Next steps are based on Debian distro as VM with
                VirtualBox as provider


Friday, March 29, 13
Creating a custom box

                       Installation steps:
                         set root password: vagrant
                         create a user with login vagrant and pwd vagrant
                         machine name: vagrant-debian-squeeze
                         machine host: vagrantup.com




Friday, March 29, 13
Creating a custom box
                Post-installation steps:
                       Install sudo on virtual machine
                       Add a group permission with visudo:
                         %admin ALL=NOPASSWD: ALL
                       Download SSH insecure pair files:
                         https://github.com/mitchellh/vagrant/tree/master/keys/
                         Save public key on GUEST in ~/.ssh/authorized_keys and all
                         keys in HOST
                       Or generate a custom pair of SSH keys and distribute it



Friday, March 29, 13
Creating a custom box

                Post-installation steps:
                       Install VirtualBox Guest Additions with /Cmd|Ctrl/-D
                       Remove pre-installed packages:


           # apt-get remove --purge virtualbox-ose-*




Friday, March 29, 13
Creating a custom box
                Post-installation steps:
                       VirtualBox needs xorg drivers, kernel headers and
                       gcc to correctly build Guest Additions kernel module.
                       Run:


           # apt-get install linux-headers-$(uname -r) build-essential xorg




Friday, March 29, 13
Creating a custom box

                Post-installation steps:
                       Run VirtualBox Guest Additions installer:



           # mount /media/cdrom
           # sh /media/cdrom/VBoxLinuxAdditions.run




Friday, March 29, 13
Creating a custom box

                After all steps, shutdown your VM
                Execute in host:


           $ vagrant package <vm-name> --base <package-name> --output
           <box-file>

           $ vagrant box add <package-name> <box-file> virtualbox




Friday, March 29, 13
Creating a custom box

                If you don’t want to build step-by-step, try veewee
                       https://github.com/jedi4ever/veewee
                       Supports VMWare Fusion, VirtualBox and KVM
                       Enable boxing based on a ISO file
                       Run as a Vagrant Plugin




Friday, March 29, 13
Performance Tips
                Slow I/O on Guest
                       Enable Host I/O cache on SATA Controller
                Slow with CPU-bound tasks
                       Set Motherboard Chipset to ICH9
                Still searching for a solution to slow webserver
                bootstrap (Ruby / Python)
                       Anomalous kernel CPU execution time while loading


Friday, March 29, 13
FAQ Time



                It’s time to make a question! :)




Friday, March 29, 13
Thank you! :)




Friday, March 29, 13

More Related Content

What's hot

Jenkins
JenkinsJenkins
Build automated Machine Images using Packer
Build automated Machine Images using PackerBuild automated Machine Images using Packer
Build automated Machine Images using Packer
Marek Piątek
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Frederik Mogensen
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
dotCloud
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
DuckDuckGo
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
Ajeet Singh Raina
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
John Lynch
 
Jenkins
JenkinsJenkins
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Ansible Automation - Enterprise Use Cases | Juncheng Anthony LinAnsible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Vietnam Open Infrastructure User Group
 
Packer by HashiCorp
Packer by HashiCorpPacker by HashiCorp
Packer by HashiCorp
Łukasz Cieśluk
 
Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
Docker, Inc.
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
ejlp12
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Jenkins Overview
Jenkins OverviewJenkins Overview
Jenkins Overview
Ahmed M. Gomaa
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
Omid Vahdaty
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with Ansible
Martin Etmajer
 
Ansible
AnsibleAnsible
Ansible
Rahul Bajaj
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
fazalraja
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
Stephane Manciot
 
From Zero to Docker
From Zero to DockerFrom Zero to Docker
From Zero to Docker
Abhishek Verma
 

What's hot (20)

Jenkins
JenkinsJenkins
Jenkins
 
Build automated Machine Images using Packer
Build automated Machine Images using PackerBuild automated Machine Images using Packer
Build automated Machine Images using Packer
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Jenkins
JenkinsJenkins
Jenkins
 
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Ansible Automation - Enterprise Use Cases | Juncheng Anthony LinAnsible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
 
Packer by HashiCorp
Packer by HashiCorpPacker by HashiCorp
Packer by HashiCorp
 
Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Jenkins Overview
Jenkins OverviewJenkins Overview
Jenkins Overview
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with Ansible
 
Ansible
AnsibleAnsible
Ansible
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
From Zero to Docker
From Zero to DockerFrom Zero to Docker
From Zero to Docker
 

Similar to Introduction to Vagrant

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
 
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
 
Vagrant - Version control your dev environment
Vagrant - Version control your dev environmentVagrant - Version control your dev environment
Vagrant - Version control your dev environment
bocribbz
 
Tech Talk - Vagrant
Tech Talk - VagrantTech Talk - Vagrant
Tech Talk - Vagrant
Thomas Krille
 
vagrant-php
vagrant-phpvagrant-php
vagrant-php
dominikzogg
 
Create your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and PackerCreate your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and Packer
frastel
 
Minicurso de Vagrant
Minicurso de VagrantMinicurso de Vagrant
Minicurso de Vagrant
Leandro Nunes
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
Yury Pliashkou
 
DevOpsDays Amsterdam Cosmic workshop
DevOpsDays Amsterdam Cosmic workshopDevOpsDays Amsterdam Cosmic workshop
DevOpsDays Amsterdam Cosmic workshop
Remi Bergsma
 
Vagrant step-by-step guide for Beginners
Vagrant step-by-step guide for BeginnersVagrant step-by-step guide for Beginners
Vagrant step-by-step guide for Beginners
Sagar Acharya
 
Docker
DockerDocker
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
 
Intro to vagrant
Intro to vagrantIntro to vagrant
Intro to vagrant
Mantas Klasavicius
 
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu ServerForget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
aaroncouch
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
macos installation automation
macos installation automationmacos installation automation
macos installation automation
Jon Fuller
 
Vagrant and chef
Vagrant and chefVagrant and chef
Vagrant and chef
Nick Ramirez
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Your own minecraft server on a linode vps
Your own minecraft server on a linode vpsYour own minecraft server on a linode vps
Your own minecraft server on a linode vps
Cleo Morisson
 
Software Defined Datacenter
Software Defined DatacenterSoftware Defined Datacenter
Software Defined Datacenter
NETWAYS
 

Similar to Introduction to Vagrant (20)

Quick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with VagrantQuick & Easy Dev Environments with Vagrant
Quick & Easy Dev Environments with Vagrant
 
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
 
Vagrant - Version control your dev environment
Vagrant - Version control your dev environmentVagrant - Version control your dev environment
Vagrant - Version control your dev environment
 
Tech Talk - Vagrant
Tech Talk - VagrantTech Talk - Vagrant
Tech Talk - Vagrant
 
vagrant-php
vagrant-phpvagrant-php
vagrant-php
 
Create your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and PackerCreate your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and Packer
 
Minicurso de Vagrant
Minicurso de VagrantMinicurso de Vagrant
Minicurso de Vagrant
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
 
DevOpsDays Amsterdam Cosmic workshop
DevOpsDays Amsterdam Cosmic workshopDevOpsDays Amsterdam Cosmic workshop
DevOpsDays Amsterdam Cosmic workshop
 
Vagrant step-by-step guide for Beginners
Vagrant step-by-step guide for BeginnersVagrant step-by-step guide for Beginners
Vagrant step-by-step guide for Beginners
 
Docker
DockerDocker
Docker
 
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
 
Intro to vagrant
Intro to vagrantIntro to vagrant
Intro to vagrant
 
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu ServerForget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
Forget MAMP and WAMP, Use Virtual Box to Have a Real Ubuntu Server
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
macos installation automation
macos installation automationmacos installation automation
macos installation automation
 
Vagrant and chef
Vagrant and chefVagrant and chef
Vagrant and chef
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Your own minecraft server on a linode vps
Your own minecraft server on a linode vpsYour own minecraft server on a linode vps
Your own minecraft server on a linode vps
 
Software Defined Datacenter
Software Defined DatacenterSoftware Defined Datacenter
Software Defined Datacenter
 

Recently uploaded

Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 

Introduction to Vagrant

  • 1. Introduction to Vagrant Marcelo Correia Pinheiro Friday, March 29, 13
  • 4. What is Vagrant? A tool to build development environments based on virtual machines Focused to create environments that are similar as possible or identical with production servers Created by Mitchell Hashimoto Written in Ruby Initially builted on top of VirtualBox API, today offers VMWare Fusion support (as $79 per licence) Friday, March 29, 13
  • 5. How I install Vagrant? Get VirtualBox first Download installer on Vagrant site (Debian, CentOS, Windows, OSX, other OS’s) Get a Vagrant box Friday, March 29, 13
  • 6. What is a Vagrant Box? Is a previously builted Vagrant virtual machine image, ready-to-run Available in a lot of platforms (Linux, Windows, BSD) You can create one! :) Friday, March 29, 13
  • 7. How I add a box? Great box repository: www.vagrantbox.es Run this command: $ vagrant box add <name> <url> <provider> # virtualbox Friday, March 29, 13
  • 8. How I create a environment? Inside your project, create a Vagrantfile: $ vagrant init <your box name> Friday, March 29, 13
  • 9. How I create a environment? # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and commented below. For a complete reference, # please see the online documentation at vagrantup.com. # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "my_precious_box" # ... # A list of options here # ... end Friday, March 29, 13
  • 10. How I start to use it? Simply run this command: $ vagrant up Friday, March 29, 13
  • 11. How I connect to it? Easy: $ vagrant ssh Friday, March 29, 13
  • 12. How I stop it? Easy: $ vagrant halt Friday, March 29, 13
  • 13. How I restart it? Easy: $ vagrant reload Friday, March 29, 13
  • 14. How I access it? You need to set forwarding ports between guest and host to work (bind on 0.0.0.0!) Just add the following code in your Vagrantfile, restart server and access in browser: # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # ... config.vm.network :forwarded_port, guest: 3000, host: 3000 # ... end Friday, March 29, 13
  • 15. How I customize it? You can change memory, CPU cores and other things in Vagrantfile Just see VBoxManage options Example: # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # ... config.vm.provider :virtualbox do |vb| vb.customize [ 'modifyvm', :id, '--memory', '1024' ] vb.customize [ 'modifyvm', :id, '--cpus', '4' ] end # ... end Friday, March 29, 13
  • 16. That’s it? Of course, no! :) It’s time to configure environment using available provisioners to install required software: Chef Solo Chef Server Puppet Apply Puppet Server Shell CFEngine (experimental) Friday, March 29, 13
  • 17. Using Chef Solo First, run chef-solo installation based on Opscode website in your guest: $ sudo true && curl -L https://www.opscode.com/chef/install.sh | sudo bash Friday, March 29, 13
  • 18. Using Chef Solo Get all necessary recipes from Opscode site Great repo with a lot of recipes Manual recipe dependency resolution sometimes # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # ... config.vm.provision :chef_solo do |chef| chef.add_recipe 'apt' chef.add_recipe 'build-essential' chef.add_recipe 'ruby1.9' chef.add_recipe 'mondodb' chef.add_recipe 'redis' end # ... end Friday, March 29, 13
  • 19. Using Chef Solo Or Install berkshelf Vagrant plugin very similar to Bundler generate a Berksfile in app root and run: source :opscode cookbook 'mysql' cookbook 'nginx', '~> 0.101.5' $ berks install --path vendor/cookbooks Friday, March 29, 13
  • 20. Using Chef Server Configure Vagrantfile to use a Chef Server as a repository Requires a URL and a PEM key to connect # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # ... config.vm.provision :chef_client do |chef| chef.chef_server_url = 'https://your-chef-server.devops.com' chef.validation_key_path = 'your-private-key.pem' end # ... end Friday, March 29, 13
  • 21. Using Puppet Apply Install Puppet from official repository in your guest VM: # wget http://apt.puppetlabs.com/puppetlabs-release-squeeze.deb # dpkg -i puppetlabs-release-squeeze.deb Friday, March 29, 13
  • 22. Using Puppet Apply Change Vagrantfile to use Puppet manifest files: # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # ... config.vm.provision :puppet do |puppet| puppet.manifests_path = 'manifests' puppet.manifest_file = 'my-devops-puppet-manifest.pp' end # ... end Friday, March 29, 13
  • 23. Using Puppet Apply Write Puppet manifest with all software that your app needs Depending of what you need, some additional configuration is required Friday, March 29, 13
  • 24. Using Puppet Server Change Vagrantfile to connect on a Puppet Server Set node hostname if you need Add some options too # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # ... config.vm.provision :puppet_server do |puppet| puppet.puppet_server = 'http://your-master-of-puppets.devops.com' puppet.puppet_node = 'my-precious-puppet.devops.com' puppet.options = '--verbose --debug' end # ... end Friday, March 29, 13
  • 25. Using Shell Create a single bash script that installs all you need: #!/bin/bash apt-get update # base apt-get install --yes python nginx mongodb-server redis-server # others apt-get install --yes curl tmux htop (...) # some additional configuration here (...) Friday, March 29, 13
  • 26. Installing software Easy: $ vagrant provision Friday, March 29, 13
  • 27. Creating a custom box You can create custom boxes to distribute between development teams Requires a fresh installation of a virtual machine based on Vagrant conventions and some manual configuration Awesome advantage: you can repackage a existent Vagrant package after updating a existent VM Next steps are based on Debian distro as VM with VirtualBox as provider Friday, March 29, 13
  • 28. Creating a custom box Installation steps: set root password: vagrant create a user with login vagrant and pwd vagrant machine name: vagrant-debian-squeeze machine host: vagrantup.com Friday, March 29, 13
  • 29. Creating a custom box Post-installation steps: Install sudo on virtual machine Add a group permission with visudo: %admin ALL=NOPASSWD: ALL Download SSH insecure pair files: https://github.com/mitchellh/vagrant/tree/master/keys/ Save public key on GUEST in ~/.ssh/authorized_keys and all keys in HOST Or generate a custom pair of SSH keys and distribute it Friday, March 29, 13
  • 30. Creating a custom box Post-installation steps: Install VirtualBox Guest Additions with /Cmd|Ctrl/-D Remove pre-installed packages: # apt-get remove --purge virtualbox-ose-* Friday, March 29, 13
  • 31. Creating a custom box Post-installation steps: VirtualBox needs xorg drivers, kernel headers and gcc to correctly build Guest Additions kernel module. Run: # apt-get install linux-headers-$(uname -r) build-essential xorg Friday, March 29, 13
  • 32. Creating a custom box Post-installation steps: Run VirtualBox Guest Additions installer: # mount /media/cdrom # sh /media/cdrom/VBoxLinuxAdditions.run Friday, March 29, 13
  • 33. Creating a custom box After all steps, shutdown your VM Execute in host: $ vagrant package <vm-name> --base <package-name> --output <box-file> $ vagrant box add <package-name> <box-file> virtualbox Friday, March 29, 13
  • 34. Creating a custom box If you don’t want to build step-by-step, try veewee https://github.com/jedi4ever/veewee Supports VMWare Fusion, VirtualBox and KVM Enable boxing based on a ISO file Run as a Vagrant Plugin Friday, March 29, 13
  • 35. Performance Tips Slow I/O on Guest Enable Host I/O cache on SATA Controller Slow with CPU-bound tasks Set Motherboard Chipset to ICH9 Still searching for a solution to slow webserver bootstrap (Ruby / Python) Anomalous kernel CPU execution time while loading Friday, March 29, 13
  • 36. FAQ Time It’s time to make a question! :) Friday, March 29, 13
  • 37. Thank you! :) Friday, March 29, 13