Using Vagrant

Hello and welcome to todays video presentation
on using Vagrant with Oracle Linux. In this video we will cover: What is Vagrant How to install it Deploy a Vagrant box or image And how to connect, halt and destroy the image
after completing your development project So let’s get started….. So what is Vagrant and why is it used? Written in Ruby, Vagrant is an easy-to-use
open source software product from HashiCorp for building and maintaining virtual machine
environments. Developers, Operators ( known as DevOps) and
Designers use Vagrant for automation and setup of their environments. Doing this will ensure consistent, reliable,
and reproducible results in the workflow. Vagrant can provision these environments on
top of VirtualBox, VMWare, Hyper-V and other providers. Then Vagrant can use shell scripts, Ansible,
Chef, or Puppet to automatically install and configure additional software. Now that we know the purpose of Vagrant, let
see how to use it with Oracle Linux. Oracle provides Vagrant images, known as boxes,
for Oracle Linux 6, 7, and 8. These boxes are provided as-is, free, and
without support. Details on these images can be found at
and will be the source of our demo in this video. So let’s jump into this demo. The system we are using is loaded with Oracle
Linux 7. To ensure we have the necessary repositories
installed perform the following steps: Open your terminal At your prompt, cd to slash etc slash yum
dot repos dot d Once in that directory, type ls to get a listing
of the installed repositories. From the listing shown you can see we have
the necessary Oracle Developer, Oracle EPEL, and Oracle Software Collection repos installed. Now open your browser and navigate to On this website you will find a quick introduction
to Vagrant and detailed specifications about the available Vagrant Boxes that Oracle publishes
using Oracle Linux. There are Vagrant boxes available for Oracle
Linux 8, Oracle Linux 7 and Oracle Linux 6. In order for this demo to work we need to
install the prerequisite of Oracle VirtualBox and Vagrant So let’s walk through those installs step-by-step. To start, open a browser tab or window and
go to Click Download on the left side menu Then find Oracle Linux 7 in the list and right
click the link and select Copy Link Location Now go back to your terminal. As part of installing VirtualBox, the installer
will build the vbox driver modules which are loaded into your running kernel. To ensure that step is successful, key packages
must be installed. Next, first clear your terminal Type sudo yum install kernel-uek-devel-$(uname
-r) gcc make perl bzip2 dkms In this command, sudo will run yum with the required escalated
privileges uname -r will ensure we get the current uek
kernel version and install the matching development packages Lastly, the dkms package from the EPEL repo
provides dynamic kernel module support and will allow for automatic building of the installed
modules if a new kernel is installed. Hit Enter Type your password for sudo and the install
will begin. Prior to install, the yum package manager
will handle any package dependencies. The output displayed during your install may
vary slightly from what is shown on my screen based on what you have installed in your existing
environment. With these packages installed, we can successfully
install VirtualBox by typing sudo yum install … and paste in the VirtualBox rpm link we
copied earlier. Yum will first download and then install the
VirtualBox rpm If you already have VirtualBox installed you
can use yum upgrade instead of yum install. Validate you have successfully installed VirtualBox
by typing lsmod | grep vbox to see if the kernel modules are loaded Type vboxmanage –help and then vboxmanage
–version to ensure the CLI is working. We now have VirtualBox installed on Oracle
Linux and we can move on to install Vagrant. To install Vagrant, first open its website
at Click the Download button We are using version 2.2.6 at the time of
this recording Scroll down to CentOS which is another rpm
based Linux distro like Oracle Linux. Right click the 64-bit link and select Copy
Link Location Back in the terminal type sudo yum install
… and paste in the copied link to the vagrant rpm file. Hit Enter Type your password for sudo and the install
of Vagrant will begin With VirtualBox and Vagrant now installed,
we can return to the Oracle Linux Vagrant Boxes website and complete the sample demo. The first step when running Vagrant is to
download the box or operating system image your VM will use. This is accomplished using the command vagrant
box add –name ol7-latest and pass the url from the website. I ran this step previously. We can verify the box downloadeded by Opening your terminal and typing vagrant box
list This will display a list of your downloaded
boxes. On this system I have Oracle Linux 7.7 and
Oracle Linux 7 latest The link to download this image comes from
the Oracle Linux Vagrant Boxes website. Back in the terminal, clear the screen Create a working directory by typing mkdir
demo I created this in the root of my home directory Clear the screen again Now create the default Vagrantfile which defines
this specific virtual environment which we will deploy to VirtualBox Type vagrant init and pass the box name you
will use. I will use ol7-latest for this demo. Vagrant generates the Vagrantfile. You can look at the details of this Vagrantfile
by typing more Vagrantfile in the terminal The Vagrantfile has ruby listed as its interpreter
at the top of the file and lower down defines the box we chose to make this environment. More details about the items in this file
can be found in the Vagrant docs website Clear the screen To start the environment type vagrant up in
the terminal This will start to deploy the environment
against VirtualBox. During deployment vagrant will create the
VM, assign the network interfaces, and rcreate a forward port for ssh. The default port is 2222 and if that port
is in use, Vagrant will detect that and dynamically pick a different port. Vagrant will also pickup any proxy settings
if configured from your host and ensure the Guest Additions are up to date for VirtualBox. If the VirtualBox Guest Additions are not
at the version matching the host, then vagrant will download the necessary packages and update
the software automatically. Now that the Vagrant VM environment has been
deployed, updated and rebooted, it is ready for us to connect. To connect to the environment, Issue the command
vagrant ssh Once connected you can test your setup by
issuing several command such as hostname, and cat /etc/os-release to see the VM is running
Oracle Linux 7. Clear the screen Type ip addr and we can see the network interfaces
assigned to the VM. The VM has two interfaces. The loopback adapter listening on localhost
and a eth0 ethernet adapter using NAT which VirtualBox assigns the default address of Once completing your work in the VM, issue
exit and clear the screen Next issue the command vagrant halt. This will perform a graceful shutdown of the
VM when you are done performing your necessary tasks. Lastly when you are done with the environment,
you can execute the command vagrant destroy. This will remove the VM from VirtualBox, delete
the disks and leave only the Vagrantfile. The Vagrant file is portable and can be provided
to others to ensure they have an environment that matches yours. In this demo, we only scratched the surface
rof what you can do with Vagrant. It is recommend you check out the Vagrant
documentation site for additional details. In todays video we covered the basics of an: Install Deployment And finally how to Connect, Halt and Destroy
the environment when finished. Thank you for watching and I hope you enjoyed
this video. To find additional resources on Oracle Linux
please check out: Our Oracle Linux Curriculum at Oracle Cloud Infrastructure at And attentional training on Oracle Linux on
Oracle Cloud Infrastructure at

Leave a Reply

Your email address will not be published. Required fields are marked *