Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Editing Setting Up Vagrant Environment

Hosam Shahin edited this page Nov 5, 2015 · 14 revisions

Introduction

Vagrant designed to run through multiple platforms including currently Mac OS X, Microsoft Windows, Debian, Ubuntu, CentOS, RedHat and Fedora, in this document we will handle how to configure and run OpenDSA-server virtual development environment through Vagrant from scratch to up and running, on Ubuntu environments.

Ubuntu Environment

To configure Vagrant inside Ubuntu environment, we should to follow the following sections

·        Installing Vagrant

·        Create Vagrant Machine Folders

·        Creating New Virtual Machine

·        Downloading Virtual Machine Configuration Script Shell

·        Configuring Permissions for Virtual Machine Configuration Script Shell

Installing Vagrant

First thing, you need to install vagrant packages from advanced packaging tool apt-get.

This will require you to enter your password, enter it and confirm to download.

administrator@host01:~$ sudo apt-get install vagrant
[sudo] password for administrator:
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following extra packages will be installed:
bsdtarcurl dkms libgsoap3 libruby1.9.1 libsdl1.2debian libyaml-0-2 ruby
ruby-childprocess ruby-erubis ruby-ffi ruby-i18n ruby-log4r ruby-net-scp
ruby-net-ssh ruby1.9.1 virtualbox virtualbox-dkms virtualbox-qt
Suggested packages:
bsdcpio debhelper ri ruby-dev ruby1.9.1-examples ri1.9.1 graphviz
ruby1.9.1-dev ruby-switch virtualbox-guest-additions-iso vde2
The following NEW packages will be installed:
bsdtar curl dkms libgsoap3 libruby1.9.1 libsdl1.2debian libyaml-0-2 ruby
ruby-childprocess ruby-erubis ruby-ffi ruby-i18n ruby-log4r ruby-net-scp
ruby-net-ssh ruby1.9.1 vagrant virtualbox virtualbox-dkmsvirtualbox-qt
0 upgraded, 20 newly installed, 0 to remove and 11 not upgraded.
Need to get 25.2 MB of archives.
After this operation, 94.8 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y

Create Vagrant Machine Folders

Folders could be created based on your choice; in our case, we will create the following folder in the home folder:

Vagrant -> Projects -> OpenDSA

administrator@host01:~$ mkdir Vagrant
administrator@host01:~$ mkdir Vagrant/Projects
administrator@host01:~$ mkdir Vagrant/Projects/OpenDSA
administrator@host01:~$ cd ~/Vagrant/Projects/OpenDSA
administrator@host01:~/Vagrant/Projects/OpenDSA$

Creating New Virtual Machine

We should create new virtual machine for our usage based on the trusty64 box, to do so we will download vagrantfile in the folder already created for this virtual machine OpenDSA, we should initialize the virtual machine there.

administrator@host01:~/Vagrant/Projects/OpenDSA$ wget https://raw.githubusercontent.com/OpenDSA/OpenDSA-server/NewKA/Vagrantfile
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
administrator@host01:~/Vagrant/Projects/OpenDSA$ ls
Vagrantfile

Vagrantfile will contain any custom settings you want to add on the virtual machine like amount of memory, networking, shared folders, settings … Anything specified here will override the defaults.

Downloading Virtual Machine Configuration Script Shell

We need to download this file to execute it inside the newly created virtual machine, currently we have file version OpenDSA-server-Provisioning.sh, and we will download it directly inside the virtual machine folder in the host so it will be already shared inside our guest virtual machine.

administrator@host01:~/Vagrant/Projects/OpenDSA$ wget https://raw.githubusercontent.com/OpenDSA/OpenDSA-server/NewKA/OpenDSA-server-Provisioning.sh

Configuring Permissions for Virtual Machine Configuration Script Shell

Before executing the configuration script shell, it requires giving it proper permissions; else, we will face many errors during script execution, we need specifically the permission to execute or run the file as a program, this permission will be given through the following command.

administrator@host01:~/Vagrant/Projects/OpenDSA$ chmod +x OpenDSA-server-Provisioning.sh

Running the Virtual Machine

Now is the time to run the created virtual machine for first time.

administrator@host01:~/Vagrant/Projects/OpenDSA$ vagrant up
Bringing machine 'default' up with 'virtualbox'provider...
[default] Importing base box 'trusty64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant

By default it forward the port 22 (ssh) to port 2222 and mounts the shared folder where the virtual machine located OpenDSA to /vagrant in the virtual machine.

Connecting to the Virtual Machine

Let’s start to use our new virtual machine, first we need to connect through ssh, it will open a ssh console to the virtual.

administrator@host01:~/Vagrant/Projects/OpenDSA$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)

* Documentation:https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
vagrant@trusty64:~$

To close ssh just type exit as below, you might to type it twice

vagrant@trusty64:~$ exit
logout
There are stopped jobs.
vagrant@trusty64:~$ exit
logout
Connection to 127.0.0.1 closed.

administrator@host01:~/Vagrant/Projects/OpenDSA$

Running the Virtual Machine Configuration Script Shell

We need to configure virtual machine to make it ready for course work; this will be through running the configuration script inside the newly created virtual machine, it will just ask you about your account’s password to be used during configuration and just wait to finish, it will take some time to finish.

vagrant@trusty64:~$ /vagrant/OpenDSA-server-Provisioning.sh
Enter password to be used for sudo commands:vagrant
Complete MySQL installation steps, you will need to provide root password. Also follow the instructions to create Django admin account.

Access OpenDSA-server

Now you can access OpenDSA-server through http://192.168.33.10:8080/

Suspending and Shutting Down Virtual Machine

After you finish your working, you need either to suspend and resume your virtual machine or turn it off; you can use one of the following commands upon your choice.

administrator@host01:~/Vagrant/Projects/OpenDSA$ vagrant suspend
administrator@host01:~/Vagrant/Projects/OpenDSA$ vagrant resume
administrator@host01:~/Vagrant/Projects/OpenDSA$ vagrant halt