SlideShare a Scribd company logo
1 of 25
Download to read offline
Keep calm and
vagrant up
(ok, clear the cache)
DrupalSH Meetup
June, 19th 2013
Shanghai, China
Daniel Lopes
http://dgo.to/@dscl
WAIT!
vagrant
what ???
NOT SO FAST...
1. Who am I?
2. What is vagrant?
3. Motivations
4. Common vs. Virtualized environments
5. Boxes
6. Provisioning
7. Other points (hands-on)
8. Useful links
First, our agenda…
Daniel Lopes
Brazilian Software Architect living in
China since dez/2011
Working with PHP since 1999 (php3)
and with Drupal since 2009 (Drupal 6)
Drupal Translator and Reviewer for
the Brazilian Portuguese team since
2010
http://dgo.to/@dscl
http://www.linkedin.com/in/danielscl
http://www.facebook.com/danielscl
Who am I?
What is vagrant?
Vagrant is a tool for building complete development environments.
With an easy-to-use workflow and focus on automation, Vagrant
lowers development environment setup time, increases
development/production parity, and makes the "works on my
machine" excuse a relic of the past.
Create and configure lightweight,
reproducible, and portable
development environments.
- vagrantup.com
Motivations…
Setting up a fully configured environment for the Drupal Global
Training Day attendees to work on as fast as possible and as
effortless as possible
Anyone, technical or non-technical people, should be able to set it up
by following a step-by-step tutorial
The solution should be small and lightweight
But it should remain useful after the training
Real motivations…
I heard a lot about Vagrant for development and even for production
server, and I was looking for an opportunity to use it!
Common ones:
● Upper-case vs. Lower-case
● Windows line break vs. Unix-like line break
● / vs. /my-project
● Different versions of the software (L|W|M)AMP
I am tired of having infrastructure related issues within my teams and
projects.
I want to have an homogenous configuration among my development
team.
The initial environment setup for new developers takes too long to be
done.
Common Dev environment
Drupal itself runs over a web server
(usually, Apache) with PHP on it and a
database (usually, MySQL). And all of them
can be running on Linux, Windows or
MacOS.
There are a few installer to help you to configure this in your computer
like:
For Windows: WAMP - http://www.wampserver.com/en/
For MacOS: MAMP - http://www.mamp.info/en/index.html
For Linux? Come on, you have it already by default...
Virtualized Dev environment
The developer needs to simply load a VM (Virtual Machine) based on
Ubuntu using Vagrant and Virtualbox so you have everything running
very fast and almost effortless.
Required downloads:
Virtualbox 4.2+: https://www.virtualbox.org/wiki/Downloads
Vagrant 1.2.2: http://downloads.vagrantup.com/tags/v1.2.2
Ubuntu 12.04 box: http://files.vagrantup.com/precise32.box
Boxes
Boxes are the skeleton from which Vagrant machines are constructed.
They are portable files which can be used by others on any platform
that runs Vagrant to bring up a working environment.
Boxes are provider-specific.
Providers are the virtualization tools which are supported by vagrant.
So you must obtain the proper box depending on what provider you're
using, like:
- Virtualbox, which is out-of-the-box in the open-source version;
- VMWare. vagrant paid version (http://www.vagrantup.com/vmware);
- and even AWS (https://github.com/mitchellh/vagrant-aws).
$ vagrant box add base http://files.vagrantup.com/precise32.box
$ vagrant init
$ vagrant up
This is the name of
your box.
Always use 'base'
for your first one.
Vagrantfile
The only configuration file needed by vagrant to work.
It defines the box that the VM will run, as well as several other
configuration like:
● config.vm.box_url:
URL from where the box can be downloaded.
● config.vm.guest:
defines the OS that the VM is running.
● config.vm.network:
general network configuration. (details later)
● config.vm.provider:
the provider software or platform for this VM.
● config.vm.provision:
how is the VM going to be provisioned.
● config.vm.synced_folder:
folder to be shared between the host and the VM.
Provisioning
Provisioning is the action that allows you to install/remove/update
software and add or alter any kind of configuration into the VM system
while getting it up.
Vagrant uses 6 different ways of provisioning, which are:
● Shell script
● Ansible (YAML)
● Chef Solo
● Chef Client
● Puppet apply (serverless)
● Puppet agent
But I will show only 2 of them:
● Shell script
● Puppet apply (serverless)
Provisioning with Shell Script
This is pretty straight-forward shell scripting.
You can use it in-line and also create an external file that will be pushed
to the VM during the process of getting this up.
Heads-up!
Keep in mind that every time you hit vagrant up or vagrant reload,
this script will be executed. So care about the execution flow of the
script commands (if-else, loops, etc)
Provisioning with Puppet
Puppet is a complete server provisioner that allows you to deeply
manage any configuration within your server. You can even control
deployments using it.
With Vagrant it is used to have a better way to manage the VM
configuration and installed software.
Puppet have a lot of modules that can be used to add new features to
it. Find more about it at: https://forge.puppetlabs.com/
Network
Vagrant allows you to map ports used by services from inside the VM
to port numbers in the host machine.
By default, it suggests you to use port number over 2200.
It also allows you to use private network, which can use IPs that are
only accessible from the host machine.
In case you use a private network IP, we'll be able to use ANY port
number in the forwarded_port option.
Synced folders
Vagrant allows you to easily map folders from the host machine
(physical) to the guest VM.
Great way to keep using your current local projects` files instead of
pushing everything to inside the VM.
In the following example you can see a way to replace Apache's
default docroot ( /var/www ) with your local directory for projects (..
/projects ).
Synced folders
HEADS UP!
● Note that the local directory is being referenced through a relative
path. For this you should consider the directory where the
Vagrantfile is as the current directory, then navigate any way you
like;
● When dealing with Windows host machines, keep the
Vagrantfile and the folder you want to sync in the same partition
(e.g.: C: or D:).
Packing and Distributing
Packing means creating new box files from a machine that is currently
present in your system.
You can easily pack new boxes from a your current machine using:
$ vagrant package [vm-name] –output desired-name.box
There are other option for this command to allow you, for instance,
pack a Vagrantfile as part of your new box file.
Packing and Distributing
Distributing means making the box file that you've just created
available to your team or to anyone over the Internet.
You can push it to github, Dropbox or any other place of your taste,
and then send a Pull request to Vagrantbox.es so you can get this
added to their list.
More about boxes...
If you want to, you can even create a new ones from scratch with
Veewee (https://github.com/jedi4ever/veewee)
From scratch means getting your favorite OS, favorite apps and so on,
and put it together.
How to use Veewee?
Read!
http://github.com/jedi4ever/veewee/blob/master/doc/vagrant.md
Watch!
http://www.youtube.com/watch?v=3vaLTVkKCPI
Useful links
Vagrant docs: http://docs.vagrantup.com/v2/
Vagrant boxes: http://vagrantbox.es
Veewee: https://github.com/jedi4ever/veewee
Aegir-up: https://drupal.org/project/aegir-up
Puppet docs: http://docs.puppetlabs.com/
Puppet modules: https://forge.puppetlabs.com/
THANKS A
LOT FOR
YOUR TIME

More Related Content

What's hot

Docker workshop
Docker workshopDocker workshop
Docker workshop
Evans Ye
 
Vagrant are you still develop in a non-virtual environment-
Vagrant  are you still develop in a non-virtual environment-Vagrant  are you still develop in a non-virtual environment-
Vagrant are you still develop in a non-virtual environment-
Anatoly Bubenkov
 

What's hot (20)

Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
 
Vagrant-Overview
Vagrant-OverviewVagrant-Overview
Vagrant-Overview
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized Development
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Using vagrant
Using vagrantUsing vagrant
Using vagrant
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...
AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...
AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...
 
Docker Container - Mesaque Silva
Docker Container - Mesaque SilvaDocker Container - Mesaque Silva
Docker Container - Mesaque Silva
 
[drupalday2017] - Devel - D8 release party
[drupalday2017] - Devel - D8 release party[drupalday2017] - Devel - D8 release party
[drupalday2017] - Devel - D8 release party
 
Drupal refcard
Drupal refcardDrupal refcard
Drupal refcard
 
Intro to vagrant
Intro to vagrantIntro to vagrant
Intro to vagrant
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Minicurso de Vagrant
Minicurso de VagrantMinicurso de Vagrant
Minicurso de Vagrant
 
Devel for Drupal 8
Devel for Drupal 8Devel for Drupal 8
Devel for Drupal 8
 
OpenNebulaConf 2016 - LAB ONE - Vagrant running on OpenNebula? by Florian Heigl
OpenNebulaConf 2016 - LAB ONE - Vagrant running on OpenNebula? by Florian HeiglOpenNebulaConf 2016 - LAB ONE - Vagrant running on OpenNebula? by Florian Heigl
OpenNebulaConf 2016 - LAB ONE - Vagrant running on OpenNebula? by Florian Heigl
 
The future of the php development environment
The future of the php development environmentThe future of the php development environment
The future of the php development environment
 
Vagrant are you still develop in a non-virtual environment-
Vagrant  are you still develop in a non-virtual environment-Vagrant  are you still develop in a non-virtual environment-
Vagrant are you still develop in a non-virtual environment-
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Drupal Developer Days Keynote
Drupal Developer Days KeynoteDrupal Developer Days Keynote
Drupal Developer Days Keynote
 
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
Apache Flink Crash Course by Slim Baltagi and Srini PalthepuApache Flink Crash Course by Slim Baltagi and Srini Palthepu
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
 

Viewers also liked

Modernize Your Drupal Development
Modernize Your Drupal DevelopmentModernize Your Drupal Development
Modernize Your Drupal Development
Chris Tankersley
 
A Manifesto Of Reading The Bible As Scripture
A Manifesto Of Reading The Bible As ScriptureA Manifesto Of Reading The Bible As Scripture
A Manifesto Of Reading The Bible As Scripture
guest4b2021
 
Krishna And The Demigods
Krishna And The DemigodsKrishna And The Demigods
Krishna And The Demigods
Yahshua Hosch
 
Narada Muni Instructs Vyasadeva
Narada Muni Instructs VyasadevaNarada Muni Instructs Vyasadeva
Narada Muni Instructs Vyasadeva
Yahshua Hosch
 
Concept voor Habitat for Humanity, 8UO, 26 maart 2010, Amsterdam
Concept voor Habitat for Humanity, 8UO, 26 maart 2010, AmsterdamConcept voor Habitat for Humanity, 8UO, 26 maart 2010, Amsterdam
Concept voor Habitat for Humanity, 8UO, 26 maart 2010, Amsterdam
Inge Kuijper
 
Material Problems And Spiritual Solutions
Material Problems And Spiritual SolutionsMaterial Problems And Spiritual Solutions
Material Problems And Spiritual Solutions
Yahshua Hosch
 
Material Problems And Spiritual Solutions
Material Problems And Spiritual SolutionsMaterial Problems And Spiritual Solutions
Material Problems And Spiritual Solutions
Yahshua Hosch
 
Upadesamrita (Text 1)
Upadesamrita (Text 1)Upadesamrita (Text 1)
Upadesamrita (Text 1)
Yahshua Hosch
 

Viewers also liked (20)

Getting Started with Drupal VM
Getting Started with Drupal VMGetting Started with Drupal VM
Getting Started with Drupal VM
 
KEEP CALM AND SPEAK THE TRUTH
KEEP CALM AND SPEAK THE TRUTHKEEP CALM AND SPEAK THE TRUTH
KEEP CALM AND SPEAK THE TRUTH
 
Modernize Your Drupal Development
Modernize Your Drupal DevelopmentModernize Your Drupal Development
Modernize Your Drupal Development
 
A Manifesto Of Reading The Bible As Scripture
A Manifesto Of Reading The Bible As ScriptureA Manifesto Of Reading The Bible As Scripture
A Manifesto Of Reading The Bible As Scripture
 
Ch 3 Bhagavatam
Ch 3 BhagavatamCh 3 Bhagavatam
Ch 3 Bhagavatam
 
McCann Sydney PowerPoint Karaoke 2
McCann Sydney PowerPoint Karaoke 2McCann Sydney PowerPoint Karaoke 2
McCann Sydney PowerPoint Karaoke 2
 
Ch 3 Bhagavatam
Ch 3 BhagavatamCh 3 Bhagavatam
Ch 3 Bhagavatam
 
Krishna And The Demigods
Krishna And The DemigodsKrishna And The Demigods
Krishna And The Demigods
 
Narada Muni Instructs Vyasadeva
Narada Muni Instructs VyasadevaNarada Muni Instructs Vyasadeva
Narada Muni Instructs Vyasadeva
 
Concept voor Habitat for Humanity, 8UO, 26 maart 2010, Amsterdam
Concept voor Habitat for Humanity, 8UO, 26 maart 2010, AmsterdamConcept voor Habitat for Humanity, 8UO, 26 maart 2010, Amsterdam
Concept voor Habitat for Humanity, 8UO, 26 maart 2010, Amsterdam
 
International Piracy Pan Am Days 2008
International Piracy  Pan Am Days 2008International Piracy  Pan Am Days 2008
International Piracy Pan Am Days 2008
 
Material Problems And Spiritual Solutions
Material Problems And Spiritual SolutionsMaterial Problems And Spiritual Solutions
Material Problems And Spiritual Solutions
 
McCann Sydney Powerpoint Karaoke 1
McCann Sydney Powerpoint Karaoke 1McCann Sydney Powerpoint Karaoke 1
McCann Sydney Powerpoint Karaoke 1
 
Week 11 (Pengenalan Html 1) Student
Week 11 (Pengenalan Html 1)   StudentWeek 11 (Pengenalan Html 1)   Student
Week 11 (Pengenalan Html 1) Student
 
First Instruction In Bhagavatam
First Instruction In BhagavatamFirst Instruction In Bhagavatam
First Instruction In Bhagavatam
 
McCann Sydney PowerPoint Karaoke 3
McCann Sydney PowerPoint Karaoke 3McCann Sydney PowerPoint Karaoke 3
McCann Sydney PowerPoint Karaoke 3
 
Material Problems And Spiritual Solutions
Material Problems And Spiritual SolutionsMaterial Problems And Spiritual Solutions
Material Problems And Spiritual Solutions
 
Upadesamrita (Text 1)
Upadesamrita (Text 1)Upadesamrita (Text 1)
Upadesamrita (Text 1)
 
Krishna And The Demigods2
Krishna And The Demigods2Krishna And The Demigods2
Krishna And The Demigods2
 
Drupaldelphia 2014 - Standardize Environments with Vagrant
Drupaldelphia 2014 - Standardize Environments with VagrantDrupaldelphia 2014 - Standardize Environments with Vagrant
Drupaldelphia 2014 - Standardize Environments with Vagrant
 

Similar to Keep calm and vagrant up

BLCN532 Lab 1Set up your development environmentV2.0.docx
BLCN532 Lab 1Set up your development environmentV2.0.docxBLCN532 Lab 1Set up your development environmentV2.0.docx
BLCN532 Lab 1Set up your development environmentV2.0.docx
moirarandell
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
Luis Rodríguez Castromil
 
DevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day DevelopmentDevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day Development
Rob Reynolds
 

Similar to Keep calm and vagrant up (20)

BLCN532 Lab 1Set up your development environmentV2.0.docx
BLCN532 Lab 1Set up your development environmentV2.0.docxBLCN532 Lab 1Set up your development environmentV2.0.docx
BLCN532 Lab 1Set up your development environmentV2.0.docx
 
Take Home Your Very Own Free Vagrant CFML Dev Environment
Take Home Your Very Own Free Vagrant CFML Dev Environment Take Home Your Very Own Free Vagrant CFML Dev Environment
Take Home Your Very Own Free Vagrant CFML Dev Environment
 
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
 
Vagrant - Version control your dev environment
Vagrant - Version control your dev environmentVagrant - Version control your dev environment
Vagrant - Version control your dev environment
 
Vagrant and puppet: Deployment made easy
Vagrant and puppet: Deployment made easyVagrant and puppet: Deployment made easy
Vagrant and puppet: Deployment made easy
 
Security Testing Using Infrastructure-As-Code
Security Testing Using Infrastructure-As-CodeSecurity Testing Using Infrastructure-As-Code
Security Testing Using Infrastructure-As-Code
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Vagrant workshop 2015
Vagrant workshop 2015Vagrant workshop 2015
Vagrant workshop 2015
 
Step-by-Step Introduction to Apache Flink
Step-by-Step Introduction to Apache Flink Step-by-Step Introduction to Apache Flink
Step-by-Step Introduction to Apache Flink
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Vagrant for local and team WordPress Development
Vagrant for local and team WordPress DevelopmentVagrant for local and team WordPress Development
Vagrant for local and team WordPress Development
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3 Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
 
Local development environment through virtualisation
Local development environment through virtualisationLocal development environment through virtualisation
Local development environment through virtualisation
 
Using Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and JenkinsUsing Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and Jenkins
 
DevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day DevelopmentDevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day Development
 
Developing web apps
Developing web appsDeveloping web apps
Developing web apps
 

Recently uploaded

Recently uploaded (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Keep calm and vagrant up

  • 1. Keep calm and vagrant up (ok, clear the cache) DrupalSH Meetup June, 19th 2013 Shanghai, China Daniel Lopes http://dgo.to/@dscl
  • 4. 1. Who am I? 2. What is vagrant? 3. Motivations 4. Common vs. Virtualized environments 5. Boxes 6. Provisioning 7. Other points (hands-on) 8. Useful links First, our agenda…
  • 5. Daniel Lopes Brazilian Software Architect living in China since dez/2011 Working with PHP since 1999 (php3) and with Drupal since 2009 (Drupal 6) Drupal Translator and Reviewer for the Brazilian Portuguese team since 2010 http://dgo.to/@dscl http://www.linkedin.com/in/danielscl http://www.facebook.com/danielscl Who am I?
  • 6. What is vagrant? Vagrant is a tool for building complete development environments. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases development/production parity, and makes the "works on my machine" excuse a relic of the past.
  • 7. Create and configure lightweight, reproducible, and portable development environments. - vagrantup.com
  • 8. Motivations… Setting up a fully configured environment for the Drupal Global Training Day attendees to work on as fast as possible and as effortless as possible Anyone, technical or non-technical people, should be able to set it up by following a step-by-step tutorial The solution should be small and lightweight But it should remain useful after the training
  • 9. Real motivations… I heard a lot about Vagrant for development and even for production server, and I was looking for an opportunity to use it! Common ones: ● Upper-case vs. Lower-case ● Windows line break vs. Unix-like line break ● / vs. /my-project ● Different versions of the software (L|W|M)AMP I am tired of having infrastructure related issues within my teams and projects. I want to have an homogenous configuration among my development team. The initial environment setup for new developers takes too long to be done.
  • 10. Common Dev environment Drupal itself runs over a web server (usually, Apache) with PHP on it and a database (usually, MySQL). And all of them can be running on Linux, Windows or MacOS. There are a few installer to help you to configure this in your computer like: For Windows: WAMP - http://www.wampserver.com/en/ For MacOS: MAMP - http://www.mamp.info/en/index.html For Linux? Come on, you have it already by default...
  • 11. Virtualized Dev environment The developer needs to simply load a VM (Virtual Machine) based on Ubuntu using Vagrant and Virtualbox so you have everything running very fast and almost effortless. Required downloads: Virtualbox 4.2+: https://www.virtualbox.org/wiki/Downloads Vagrant 1.2.2: http://downloads.vagrantup.com/tags/v1.2.2 Ubuntu 12.04 box: http://files.vagrantup.com/precise32.box
  • 12. Boxes Boxes are the skeleton from which Vagrant machines are constructed. They are portable files which can be used by others on any platform that runs Vagrant to bring up a working environment. Boxes are provider-specific. Providers are the virtualization tools which are supported by vagrant. So you must obtain the proper box depending on what provider you're using, like: - Virtualbox, which is out-of-the-box in the open-source version; - VMWare. vagrant paid version (http://www.vagrantup.com/vmware); - and even AWS (https://github.com/mitchellh/vagrant-aws).
  • 13. $ vagrant box add base http://files.vagrantup.com/precise32.box $ vagrant init $ vagrant up This is the name of your box. Always use 'base' for your first one.
  • 14. Vagrantfile The only configuration file needed by vagrant to work. It defines the box that the VM will run, as well as several other configuration like: ● config.vm.box_url: URL from where the box can be downloaded. ● config.vm.guest: defines the OS that the VM is running. ● config.vm.network: general network configuration. (details later) ● config.vm.provider: the provider software or platform for this VM. ● config.vm.provision: how is the VM going to be provisioned. ● config.vm.synced_folder: folder to be shared between the host and the VM.
  • 15. Provisioning Provisioning is the action that allows you to install/remove/update software and add or alter any kind of configuration into the VM system while getting it up. Vagrant uses 6 different ways of provisioning, which are: ● Shell script ● Ansible (YAML) ● Chef Solo ● Chef Client ● Puppet apply (serverless) ● Puppet agent But I will show only 2 of them: ● Shell script ● Puppet apply (serverless)
  • 16. Provisioning with Shell Script This is pretty straight-forward shell scripting. You can use it in-line and also create an external file that will be pushed to the VM during the process of getting this up. Heads-up! Keep in mind that every time you hit vagrant up or vagrant reload, this script will be executed. So care about the execution flow of the script commands (if-else, loops, etc)
  • 17. Provisioning with Puppet Puppet is a complete server provisioner that allows you to deeply manage any configuration within your server. You can even control deployments using it. With Vagrant it is used to have a better way to manage the VM configuration and installed software. Puppet have a lot of modules that can be used to add new features to it. Find more about it at: https://forge.puppetlabs.com/
  • 18. Network Vagrant allows you to map ports used by services from inside the VM to port numbers in the host machine. By default, it suggests you to use port number over 2200. It also allows you to use private network, which can use IPs that are only accessible from the host machine. In case you use a private network IP, we'll be able to use ANY port number in the forwarded_port option.
  • 19. Synced folders Vagrant allows you to easily map folders from the host machine (physical) to the guest VM. Great way to keep using your current local projects` files instead of pushing everything to inside the VM. In the following example you can see a way to replace Apache's default docroot ( /var/www ) with your local directory for projects (.. /projects ).
  • 20. Synced folders HEADS UP! ● Note that the local directory is being referenced through a relative path. For this you should consider the directory where the Vagrantfile is as the current directory, then navigate any way you like; ● When dealing with Windows host machines, keep the Vagrantfile and the folder you want to sync in the same partition (e.g.: C: or D:).
  • 21. Packing and Distributing Packing means creating new box files from a machine that is currently present in your system. You can easily pack new boxes from a your current machine using: $ vagrant package [vm-name] –output desired-name.box There are other option for this command to allow you, for instance, pack a Vagrantfile as part of your new box file.
  • 22. Packing and Distributing Distributing means making the box file that you've just created available to your team or to anyone over the Internet. You can push it to github, Dropbox or any other place of your taste, and then send a Pull request to Vagrantbox.es so you can get this added to their list.
  • 23. More about boxes... If you want to, you can even create a new ones from scratch with Veewee (https://github.com/jedi4ever/veewee) From scratch means getting your favorite OS, favorite apps and so on, and put it together. How to use Veewee? Read! http://github.com/jedi4ever/veewee/blob/master/doc/vagrant.md Watch! http://www.youtube.com/watch?v=3vaLTVkKCPI
  • 24. Useful links Vagrant docs: http://docs.vagrantup.com/v2/ Vagrant boxes: http://vagrantbox.es Veewee: https://github.com/jedi4ever/veewee Aegir-up: https://drupal.org/project/aegir-up Puppet docs: http://docs.puppetlabs.com/ Puppet modules: https://forge.puppetlabs.com/