How to create Virtual Machine[VM] on Windows 10 using Vagrant/Virtual Box.
In this exercise, we will see the following sections/topics/activities:
Let us consider the below two activities.
I. How to Install Vagrant and VirtualBox ?
II. How to Initialize our first virtual environment with Vagrant setup ?
I. How to Install Vagrant and VirtualBox ?:
Step1: Selecting the Virtual Box
Initially, we need to install the software required to manage a virtual machine
environment, which is a hypervisor as well as the Vagrant software itself.
In this activity, we will install VirtualBox to use it with Vagrant.
VirtualBox is an open source hypervisor that was initially made as the only
hypervisor and supported by Vagrant.
The VirtualBox is broadly supported by the Vagrant community.
Before we install the VirtualBox and Vagrant software, we need to obtain its latest versions.
VirtualBox can be downloaded from its project website at http://virtualbox.org.
Please note, in this exercise we are going to use for Linux installations [VMs] only. Also note, in this exercise I am using Windows10 as OS. Hence I need to select for my use the windows version under Windows hosts.
When we click on it, it downloads the file named as “VirtualBox-5.2.16-123759-Win”, as on date this is the file exists. [it might vary time to time]. You can install it on your desktop/Laptop now.
A new installation of VirtualBox will display a welcome message in a window titled as
“Oracle VM VirtualBox Manager”.
When you have created more than one virtual machines, this dialog displays information about the machines created using VirtualBox.
Step2: Getting Vagrant to operate the Virtual Box
Now, we need to get the Vagrant file to install.
Vagrant packages are operating system-specific and can be downloaded from the
Vagrant website at http://vagrantup.com.
Download the appropriate version for your system [example: Windows10].
You can find, Windows 32-bit or 64-bit. In my current Laptop, I use 64 bit.
You can find the file as “vagrant_2.1.5_x86_64” to download the same.
Now install it after its download.
Vagrant setup wizard will drive you with it easy guidelines.
It installs by default into:C:\HashiCorp\Vagrant\
It takes few minutes to copy the files and install into your Desktop/Laptop.
Step3: Identify the Vagrant installation
Now, It will ask you to reboot your machine. Once you rebooted your system, please follow the below steps.
How Vagrant works?:
Let us understand; Vagrant followed the below procedure in the above Step2.
The Vagrant installer extracted and copied its files, and added the vagrant command to the executable path.
On Windows OS, this will install Vagrant to the default OS X Applications/ directory.
Also let us note; Vagrant is a command-line driven application, there are no programs
accessed from this OS.
Now, by opening a command prompt [CMD in windows] let us verify that Vagrant is working. We need to do it by executing: “vagrant version” command in CMD.
We can see the below screen output in CMD window:
=== CMD window output ====>
Installed Version: 2.1.5
Latest Version: 2.1.5
You’re running an up-to-date version of Vagrant!
From the above output;
It is confirmed, we are ready to start using Vagrant!
Note: Please visit https://docs.vagrantup.com/v2 , to know further the Vagrant installation guidelines.
Let us recap, What we have done is; we installed a working Vagrant environment which consists of:
a) A hypervisor application that can contain virtual machines.
b) Also let us note; Vagrant is a tool that makes managing these machines simpler and available.
c) It is important here to note that Vagrant is simply a framework to manage virtual machines.
d) It is not an application to create and host virtual machines.
II. How to Initialize our first virtual environment with Vagrant setup ?:
As mentioned in the above sections, once we have a working Vagrant environment with a hypervisor, we can initialize our first environment.
There are two ways we can work with Vagrant to achieve this task:
a) In a new environment with a newly initialized Vagrantfile.
b) In an environment which is maintained in source control system (such as Git, SVN, etc.), which has a Vagrantfile included in a project and keeping Vagrantfiles for different purposes of the projects.
This is a powerful technique to manage and track changes in Vagrant environments. This kind of method can be more useful to build the Environments easily with the concept of Infrastructure As a Code [IAC] under DevOps culture. Which is also a script driven [automated IAC] process.
But in this example, we will initialize a new environment with the basic configuration of a Vagrantfile.
Step1: Let us create a vagrantfile with vagrant init command as below to get an ubuntu 16.04 machine with 32 bit.
I have copied my screen display with used commands for this process.
I need to have a different folder and used the below command in that folder”.
vagrant init puppetlabs/ubuntu-16.04-32-nocm
=== Screen output ===>
C:\>md dir vagrant-files
C:\vagrant-files>vagrant init puppetlabs/ubuntu-16.04-32-nocm
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.
==== We have created a vagrantfile now===>
Step2: Making Vagrant up
Before running this step please make sure you have installed the Oracle VirtualBox as mentioned in the previous section.
Now, In Command Window execute the below command.
This command might output several results; I am copying my screen output which was displayed. It takes few minutes to complete this activity.
=== Screen output for vagrant up=====>
Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Box ‘puppetlabs/ubuntu-16.04-32-nocm’ could not be found. Attempting to find and install…
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box ‘puppetlabs/ubuntu-16.04-32-nocm’
default: URL: https://vagrantcloud.com/puppetlabs/ubuntu-16.04-32-nocm
==> default: Adding box ‘puppetlabs/ubuntu-16.04-32-nocm’ (v1.0.0) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/puppetlabs/boxes/ubuntu-16.04-32-nocm/versions/1.0.0/providers/virtualbox.box
default: Download redirected to host: s3.amazonaws.com
==> default: Successfully added box ‘puppetlabs/ubuntu-16.04-32-nocm’ (v1.0.0) for ‘virtualbox’!
==> default: Importing base box ‘puppetlabs/ubuntu-16.04-32-nocm’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘puppetlabs/ubuntu-16.04-32-nocm’ is up to date…
==> default: Setting the name of the VM: vagrant-files_default_1536967979621_87087
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:
This option can be disabled globally with an environment variable:
or on a per folder basis within the Vagrantfile:
config.vm.synced_folder ‘/host/path’, ‘/guest/path’, SharedFoldersEnableSymlinksCreate: false
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
==> default: Forwarding ports…
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM…
==> default: Waiting for machine to boot. This may take a few minutes…
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection reset. Retrying…
default: Warning: Remote connection disconnect. Retrying…
default: Warning: Connection aborted. Retrying…
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default: Inserting generated public key within guest…
default: Removing insecure key from the guest if it’s present…
default: Key inserted! Disconnecting and reconnecting using new SSH key…
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM…
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default: Guest Additions Version: 5.0.20
default: VirtualBox Version: 5.2
==> default: Mounting shared folders…
default: /vagrant => C:/vagrant-files
=== End of Vagrant up process ====>
Please note with the above activity is completed, your VirtualBox window will show this VM as its status “running”. It means you are able to see this newly created VM in your “Oracle VM VirtualBox Manager”.
Step3: Checking the box
Now let us use check this VM in a Command line:
After Vagrant returns to the command line, executing the “vagrant ssh” command will open a command-line interface into the newly initialized Virtual Machine[VM].
You can see the screen output:
==== vagrant ssh ====>
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-21-generic i686)
* Documentation: https://help.ubuntu.com/
New release ‘18.04.1 LTS’ available.
Run ‘do-release-upgrade’ to upgrade to it.
At the same time you can also go to your “Oracle VM VirtualBox Manager”, and double click on it. It will show a button “Show”, you can click on it. Opens a window with this VM.
Please note; In this exercise we have created the base box only. Hence we are not going to use this VM for our future operation.
You can see the local dir as:
== Current dir details ===>
Volume in drive C has no label.
Volume Serial Number is 5A33-A94E
Directory of C:\vagrant-files
09/14/2018 04:14 PM <DIR> .
09/14/2018 04:14 PM <DIR> ..
09/14/2018 04:25 PM <DIR> .vagrant
09/14/2018 04:12 PM 3,108 Vagrantfile
1 File(s) 3,108 bytes
3 Dir(s) 96,101,879,808 bytes free
Step4: Destroying the Virtual box
Now, we will see : a) How to exit, b) How to Destroy this VM.
a) How to exit: We can exit it by using the command :
“control-d command, or by typing exit”
b) How to Destroy this VM: We can Destroy the virtual machine, by discarding the entire working environment. This can be done with the “vagrant destroy” command.
When you use this command, Vagrant will now prompt you to make sure that you want to destroy the environment; type “y” to proceed with destroying the environment and deleting the VM.
=== Output for Destroy===>
VM must be running to open SSH connection. Run `vagrant up`
to start the virtual machine.
default: Are you sure you want to destroy the ‘default’ VM? [y/N]
==> default: Destroying VM and associated drives…
You can also check in the GUI of the “Oracle VM VirtualBox Manager”. It will not have this VM.
In this simple vagrant exercise in summary we have done the below steps;
- We have downloaded and configured “Oracle VM VirtualBox Manager”.
- We have installed Vagrant.
- Created a Vagrant virtual box.
- We could connect to it in a command line interface and checked the linux [ls] commands. We also cross verified it in “Oracle VM VirtualBox Manager” on its appearance as VM.
- Finally, we destroyed this VM.
That is all about this exercise. You can create any number of VMs like this.
You can keep checking this site or follow it to get the new/updated blogs.
If you are interested in learning AWS, go through my blogs:
How to create and activate a new account in AWS ?:
In this blog, you will see the required steps for creating and activating your new AWS account. Once have the activated account, you can start your other lab practices as I discuss in the class timely.
The following are the main 4 steps process we need to follow:
STEP1: Creating your account. It consists of 2 steps: a) Providing a valid e-mail address and choosing a password. b) Providing your contact information and setting your preferences.
STEP2: Add a payment method Please note; you need to have a valid CC to give its details. Amazon verifies its transaction also with a tiny charge and with a credit back. If by mistaken given wrong data please note; your account registration process will not be activated. You will be intimated by mail. This way Amazon is authenticating/authorizing us for AWS usage.
STEP3: Verify your phone number. You need to Provide a phone number where you can be reached in next few minutes, while creating your account.
STEP4: Choose the AWS Support plans. Time to time the AWS plans will be published. You need to choose the plan from the currently available plans for your needs. The relevant URL is given in the detailed steps section in this blog.
As a consolidated process, we can understand from the below flow chart. Which is from the collection of AWS process charts.
I am not copying the screens due to privacy.
STEP1: Detailed steps for Creating your account.
a). You need to go to Amazon Web Services home page URL: https://aws.amazon.com/
b). Now, Choose Sign Up. Click on Create an AWS account. You can see new page with Create an AWS account. You need to enter the required details. E-mail id, Pwd, AWS Account name [you can give any name for this]. And choose continue to go to next page. Please note; The above steps are valid for the new users of AWS. If you enter your email address entered incorrectly, you might not be able to access your account or change your password in the future. So you need to be careful on your data entry part. Let us assume; if you’ve signed in to AWS recently, it might say Sign In to the Console. So you need to login into your existing Account.
c). Now in the current page, choose Professional or personal. These two areas will give equal services. Depends on your need You can choose one of the options.
d). From the above options choosed, type the requested company or personal information entries. Note; At this point, You need to go through the AWS Customer Agreement to know their policies and procedures to follow while operating.
e). Finally, you choose Create Account and Continue options in the bottom.
f). Please note; at this point you will receive an e-mail to confirm that your account is created. Now, you can sign in to your new account using the valid email address and valid password you have supplied earlier.
Please note; we have done the Step1 only, the activation process is not yet completed to use the AWS services. Still we need to follow 3 more steps.
STEP2: Add a payment method- Detailed steps:
At this point; On the Payment Information page,
a) Choose the payment method as per the payment gateway standards which is displayed.
b) Type the requested information associated with your payment method. Please make sure the address for your payment method is the same as the address you provided for your account. Note; If your billing address is different; then choose Use a new address, type the billing address for your payment method.
c) Now, choose Secure Submit.
STEP3: Verify your phone number.
Please keep a valid and handy phone number at this point.
a) On this Phone Verification page, type a phone number where can use to accept incoming phone calls.
b) Enter the code displayed in the captcha. When you’re ready to receive a call, choose Call me now option.
c) In a few moments, an automated system will call you to your given phone number. Even it might have SMS feature also, if you are outside North America region.
d) Type the provided PIN on your phone’s keypad of the AWS screen. e) After the process is complete, choose Continue.
STEP4: Choose the AWS Support plans.
a) At this point please visit the below URL: https://aws.amazon.com/premiumsupport/features/
You can select the AWS support plans from the given list.
b) After your selection of a Support plan, a confirmation page denotes that your account is being activated.
c) Please note; Accounts are usually activated within a few minutes, but the process might take up to 24 hours. This process includes the validation of Bank/CC account given there.
d) Hence keep looking for a mail on this subject from Amazon to start your AWS services usage.
Assuming everything went well, and your AWS account is activated now. Congratulations!
We can look into next lab with reference to the class session.
2. AWS: WordPress[WP] infrastructure creation using a free tier account
If you are interested to learn Virtualization with Vagrant visit:
If you are not a student of my class, and looking for it please contact me by mail with your LinkedIn identity. And send a connection request with a message on your need. You can use the below contacts. Please note; I teach globally.
I am publishing series of blogs on DevOps tools practice. The interested people can keep watching this site or you can subscribe/follow.
In this blog we will see what are the pre-requisites for Jenkins 2.9 to install and how to install Jenkins.
To setup Jenkins, you need to have Java 9 in your local machine.
Hence in the Step1 to setup Java, you need to follow the below steps:
STEP1: How to download and install JDK SE Development kit 9.0.1 ?:
go to URL:
You will see the below page [as on today’s display]
From this web page, Click on Windows file jdk-9.0.1_windows-x64_bin
It will download.
Double click on the file.
You will see the series of screens, while it is doing installation. I have copied some of them here.
You can change the directory if you want, in the above screen.
Finally you should get the below screen as installed it successfully.
Now, you need to set the Java environment and path variable in Windows setting.
My Java directory path is:
You need to edit the below path variables also for the latest path:
After you have done the settings, you can check the java version as below in a command prompt:
You should get the same version.
Now, You need a simple java program to run and check your compiler and runtime environment.
Please goto google search and check for “Java Hello wordl program”.
Follow the below URL:
Copy the program into a text file named as hellowworld.java
Then compile and run the program as below:
If you are getting the above, then your installed java software is working fine.
You need to remember the below:
To compile this program you need to use the below command in command prompt of that program directory:
To run the java program you need to use the below command:
Now, you can plan for setting up Jenkins.
STEP2: How to setup Jenkins on Windows ?:
Follow the below link to download Jenkins for Windows-x64
It downloads the installer as below:
You can see the downloaded installer file for Jenkins.
How to install Jenkins?:
Now you can copy this file into a new directory as Jenkins.
I have copied into the below directory.
You need to unzip this file.
You can see the new directory is created with its unzipped files:
You can double click on it and can see the below screen:
I have changed the path as below:
Click on install and say “Yes” in windows confirmation screen.
You can see the below screen:
Once you click on finish, it will take you to a browser:
Jenkins will have a default user id as “admin” and the password.
The password is available from the given path.
You can open this file in notepad as below:
Now, copy this password as below into windows clipboard.
Now you goto the Jenkins browser and paste this password.
Close your notepad.
Now, on browser press continue.
You can see the Jenkins initial screen as below for plugins selection:
Jenkins will have 100s of plugins. But there are default plugins those can be used initially to save you disk space and time. Hence now, you click on “Install suggested plugins”.
It will show the below screen as it is working for this activity:
You can see in the right side window the tasks what Jenkins is doing:
You can also watch as it is doing one by one the plugins installation and the tasks on right side.
It might take more than 30 mts depends on your internet speed and the RAM.
I am copying some of the screens as it is moving on …
Once the plugins are installed, you can see the 1st screen to setup your 1st admin user id and password as below:
You can enter the details and click on “Save and Finish” button.
Now, it shows the below screen with Jenkins readyness to use:
When you click on “Start using Jenkins” button,
You can see the below screen as in the beginning of the Jenkins usage:
Please observe the right corner and verify your created user id.
Now, let us do some login and logout operations to make sure it is working.
When you logout you can see the below screen:
Now let us understand the url of Jenkins server which we are using:
When we install Jenkins in any machine either Windows or Linux.
By default its url should be : http://localhost:8080/
Your local host is your current machine Ip address.
You can see the screen now with the above url:
Now, you can try one more option, check your ip address from command prompt as below:
You can pickup the 1st IP address which displays from the command prompt screen.
And key-inn the below url in your browser:
Your ip need to be used in place of 192.168.137.1
Now, let us see What is 8080?:
Every server software creates a port address to access its web pages from the installed machine. In our case Jenkins has been configured on 8080 port as default. The 8080 is a default port for Jenkins. Similarly other server softwares also will have their specific ports.
Now, I have used a different browser using the above url to access Jenkins web page as below:
Using the login screen I am logging into my admin user id: vskumar2017 , which was created earlier.
You can also check in your windows services on Jenkins running status.
Please note on this setup, you have made a standalone Jenkins by using your PC or Laptop.
Now, you can restart your windows machine. You need to start Jenkins as fresh service.
- Open command prompt.
- Go to the directory where your war file is placed and run the following command: java -jar jenkins.war
- OR One more option is; go to your Jenkins directory in CMD window and execute: jenkins.exe start
Open browser and Use you can check the Jenkins access. It should be showing the login page.
How to remove Jenkins from your system?:
If you want to remove Jenkins from your system, you can find the Jenkins Windows installer file from the Jenkins directory and double click on it. You can see the below window to choose your action:
So far we have seen the installation of Java 9 and Jenkins.
Some times, you might need to configure other servers [Ex:Tomcat, etc,]. They might also use 8080 port. Hence there will be conflict. We need to change the port# in that case.
Now, How to change your 8080 port to other port#?:
Please find Jenkins.xml in Jenkins dir:
In my system I have the URL:D:\Jenkins\Jenkins 2.9
You need to replace 8080 with the required port# in the below line:
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar “%BASE%\jenkins.war” –httpPort=8080 –webroot=”%BASE%\war”</arguments>
In the next blog we can see some simple exercise with Jenkins by creating and running the project into different builds.
Note to the reader/user of this blog:
If you are not a student of my class, and looking for it please contact me by mail with your LinkedIn identity. And send a connection request with a message on your need. You can use the below contacts. Please note; I teach globally.
If you want to learn for Ubuntu installation you can visit: