Quick Start to Vagrant on Windows 10


In this article, I will show you how to install and use Vagrant on Windows 10. First, we will install the required tools and then we will up and run an Ubuntu desktop vagrant box with vagrant commands.

Required Tools

  • Virtualbox
  • Vagrant
  • Git

What does Vagrant do?

– Create and destroy VMs

– Starts, stops, restarts VMs

– Access to VMs

– Networking and WM settings

– Orchestrates “provisioning” for on-demand setup

 Steps to Up and Run Ubuntu Desktop (GUI Mode) via Vagrant

 1- Install Git for Windows

Download URL: https://git-scm.com/download/win

Then during installation steps, select below settings:

  • Use Git from the Windows Command Prompt” with this option you will be able to use Git from both Git Bash and the Windows Command Prompt.
  • Checkout as-is, commit Unix-style line endings

And finish the installation.

2- Install VirtualBox

For the sake of compatibility and in order to eliminate the version problems please install VirtualBox 5.1.14r112924 (Qt5.6.2) version.

 Downlod Link: http://download.virtualbox.org/virtualbox/5.1.4/VirtualBox-5.1.4-110228-Win.exe

 Installation of VirtualBox is pretty straight-forward. Just click the .exe file and click next -> next -> next to finish installation.

Also, download Oracle VM VirtualBox Extension Pack.

 Download Link: http://download.virtualbox.org/virtualbox/5.1.4/Oracle_VM_VirtualBox_Extension_Pack-5.1.4.vbox-extpack

Then, open VirtualBox and click File -> Preferences -> Extensions click the below icon

And select the extension pack and then click “Install” -> “I Agree” -> “Yes

3- Install Vagrant

In order to eliminate compatibility issues, it is better to install Vagrant 1.9.2 version.

 Vagrant Download Link: https://releases.hashicorp.com/vagrant/1.9.2/vagrant_1.9.2.msi

Install the Vagrant it is very easy to install and then restart your machine.

 After these setting you should do below settings to run Vagrant without any problem:

1) Enable VT-X (Intel Virtualization Technology) in your computer bios settings.

2) Disable Hyper-V on program and features page in the control panel.

Download and Run Ubuntu Desktop (GUI) Vagrant Box on Windows 10

Open Git Bash and type “pwd” it should show your user directory as shown below:

/c/Users/onurb

Then, create a folder as “project” by using “mkdir projects” command.

Then, go to that folder with “cd projects

Then create a folder for Ubuntu by using “mkdir ubuntu1404-desktop” command.

and go to that folder with “cd ubuntu1404-desktop” command.

After these steps run below commands sequentially:

vagrant init box-cutter/ubuntu1404-desktop

vagrant up –provider virtualbox

Then, Vagrant download and then run the box.

Vagrant Box Link: https://atlas.hashicorp.com/box-cutter/boxes/ubuntu1404-desktop/versions/2.0.26

 After these settings whenever you will run “vagrant up” command, Vagrant will run and open the Ubuntu in GUI mode as shown below:

Also, you can use any ready Vagrant box from below page.

https://atlas.hashicorp.com/boxes/search

Most Common Vagrant Commands

I will also summarise Vagrant commands with images. This time I will use “hashicorp/precise64” Linux box.

vagrant init: (initialize)

vagrant up: download image and do rest of the settings and power-up the box

vagrant status: Shows status

vagrant suspend: Saves the box’s current state

vagrant halt: shutdown the box (Power-off)

vagrant destroy:  shutdown and delete the box

Vagrant init (Initialize)

Vagrant up (Run the VM)

Vagrant suspend (Save the VM’s State)

Vagrant halt (Shut down the VM)

Vagrant ssh (Connecting non-gui Linux OS)

Vagrant version (Get Version Information)

Version Control of Vagrant by Using Git

You can edit VagrantFile and commit the modifications in a git repo by using below commands.

git version: get version information

git init: initialize the repo

git add: adding files to git repo

git commit -m “comment”: committing a file with a comment

git log –oneline: showing log history one line

git status: showing status of modifications

git ignore: Ignores the file types and do not hold them in the repo.

Create a .gitignore file and add “.vagrant” in it.

Add and Commit it into repo:

QUIZ TIME 🙂

Question 1:

How do you start a virtual machine with Vagrant?

vagrant up

Question 2:

A vagrant box must exist on the local system before the vagrant up command can be called.

No

Question 3:

How does Vagrant allow for keeping files synchronised between the host and the guest?

shared folders

Question 4:

How do we stop our vagrant-managed virtual machine from running?

vagrant suspend (save the state)

vagrant halt (shutdown)

vagrant destroy (shutdown and delete)

Question 5:

The vagrant status command tells us the current state of the vagrant-managed virtual machine for our project.

true

In this article, we learnt how to install, use, up and run a Vagrant Box in windows 10. I hope this helps you in your test environment needs.

Thanks.

-Onur

javafx

Database Operations in JavaFX

By Onur Baskirt / Apr 1, 2016 / 56 Comments
Before started this section, please check the first article and learn How to Start JAVAFX! http://www.swtestacademy.com/getting-started-with-javafx/ At first, part of JavaFX tutorial series, we created a sample JavaFX project, designed the draft version of the UI and set up an...
rest assured

REST API Testing with Rest Assured

By Onur Baskirt / Mar 8, 2016 / 32 Comments
Outline In this post, I will explain what is API and API testing, what is the difference between SOAP and REST services, and how to test REST APIs with Rest Assured Library. What is API? API stands for Application Programming...
extentreports

How to Write Effective CSS Locators

By Onur Baskirt / Oct 1, 2017 / 0 Comments
Hi all, in this tutorial, I will describe you how to write effective CSS locators to interrogate web elements for your automation projects. As a rule of thumb, your interrogation strategy should be in below order: First try to use...
extentreports

Selenium-11: Execute JavaScript with JavascriptExecutor

By Onur Baskirt / Jan 27, 2016 / 15 Comments
Outline Sometimes we cannot handle some conditions or problems with Webdriver, web controls don't react well against selenium commands. In this kind of situations, we use Javascript. It is useful for custom synchronizations, hide or show the web elements, change...
javafx

Getting Started with JavaFX

By Onur Baskirt / Mar 25, 2016 / 0 Comments
When I started to work in my current position, one of my task is to do manual operations for campaign products  every week. After the second week, I thought that I have to automate this task using a GUI based...
extentreports

How to Write Smart XPath Locators

By Onur Baskirt / Sep 24, 2017 / 4 Comments
Hi all, in this tutorial, I will describe you how to write smart and non-brittle XPath locators. When we write our test scripts, we generally prefer to use id, name, class, etc. these kinds of locators. However, sometimes we could not...
extentreports

Selenium-1: Quick Start to Automation with Selenium WebDriver & JAVA & JUnit & Maven & IntelliJ

By Onur Baskirt / Sep 8, 2015 / 26 Comments
Outline Selenium Webdriver is the most popular open source web test automation framework across wide range of browsers and platforms. In this tutorial you will learn how to do web test automation with Selenium Webdriver and the related tools. Audience...
page object model

Page Object Model with C#

By Ege Aksoz / Jun 18, 2017 / 8 Comments
In the previous tutorial, we’ve taken the initial steps and entered the world of automated testing. We also wrote our first automated test. From this point on, since we are not just going to write one test, we need to...
extentreports

How to Select a Date From DatePicker Using Selenium

By Onur Baskirt / Aug 13, 2016 / 6 Comments
When you need to automate a airway, hotel, or similar websites you need to deal with Datepickers and some times it is a little bit cumbersome to select a specific date on the Datepicker or calendar.  In this post, I...
extentreports

Selenium Webdriver Performance testing with Jmeter and Selenium Grid

By Ozgur Kaya / Aug 9, 2016 / 2 Comments
In this post, we will complete Selenium Webdriver Performance testing scenario using Jmeter and Selenium Grid. 1- Install Java 7 or later If necessary https://java.com/tr/download/ 2- Download latest Jmeter version 3.0 or higher. http://jmeter.apache.org/download_jmeter.cgi 3- Download Jmeter PluginsManager JAR file and...
By | 2017-04-02T22:00:30+00:00 April 2nd, 2017|Devops, Vagrant|2 Comments

About the Author:

Onur Baskirt
Onur Baskirt is a senior IT professional with 10+ years of experience. He worked at Bahçesehir University, ST Microelectronics, Huawei and Ericsson as research assistant, design verification engineer and software test leader. Also, he worked as software test leader and software operations manager at Turkey's biggest technology retailer, Teknosa. Now, he is working as Head of Software Testing and Manager of two Development Teams at Kariyer.net. His current research areas are technical software testing, programming, and computer science. Formerly, he has several research works and papers on digital chip design & verification. His hobbies are sport, dancing, traveling, and nutrition. You can find detailed information about him on his linked-in page.

2 Comments

  1. sudhakar September 25, 2017 at 10:22 am - Reply

    Hi am getting the following error please give some suggestion to solve it, thanks in advance

    The box ‘box-cluster/ubuntu1404-desktop’ could not be found or
    could not be accessed in the remote catalog. If this is a private
    box on HashiCorp’s Vagrant Cloud, please verify you’re logged in via
    vagrant login. Also, please double-check the name. The expanded
    URL and error message are shown below:

    URL: [“https://vagrantcloud.com/box-cluster/ubuntu1404-desktop”]
    Error: Failed to connect to vagrantcloud.com port 443: Timed out

Leave A Comment