Vagrant on Ubuntu

mohammedrafi@NOC-RAFI:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty

mohammedrafi@NOC-RAFI:~$ sudo apt-get install virtualbox

mohammedrafi@NOC-RAFI:~$ sudo apt-get install vagrant

mohammedrafi@NOC-RAFI:~$ vagrant –help
Usage: vagrant [-v] [-h] command []

-v, –version Print the version and exit.
-h, –help Print this help.

Available subcommands:
box manages boxes: installation, removal, etc.
destroy stops and deletes all traces of the vagrant machine
halt stops the vagrant machine
help shows the help for a subcommand
init initializes a new Vagrant environment by creating a Vagrantfile
package packages a running vagrant environment into a box
plugin manages plugins: install, uninstall, update, etc.
provision provisions the vagrant machine
reload restarts vagrant machine, loads new Vagrantfile configuration
resume resume a suspended vagrant machine
ssh connects to machine via SSH
ssh-config outputs OpenSSH valid configuration to connect to the machine
status outputs status of the vagrant machine
suspend suspends the machine
up starts and provisions the vagrant environment

For help on any individual command run `vagrant COMMAND -h`

mohammedrafi@NOC-RAFI:~$ vagrant –version
Vagrant 1.4.3

mohammedrafi@NOC-RAFI:~$ mkdir vbox

mohammedrafi@NOC-RAFI:~$ cd vbox

http://www.vagrantbox.es/

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

mohammedrafi@NOC-RAFI:~/vbox$ vagrant box add precise32 http://files.vagrantup.com/precise32.box
Downloading box from URL: http://files.vagrantup.com/precise32.box
Extracting box…te: 1907k/s, Estimated time remaining: 0:00:01)
Successfully added box ‘precise32’ with provider ‘virtualbox’!

mohammedrafi@NOC-RAFI:~/vbox$ vagrant box list
precise32 (virtualbox)
mohammedrafi@NOC-RAFI:~/vbox$ vagrant init precise32
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.

mohammedrafi@NOC-RAFI:~/vbox$ vagrant up
Bringing machine ‘default’ up with ‘virtualbox’ provider…
[default] Importing base box ‘precise32’…
[default] Matching MAC address for NAT networking…
[default] Setting the name of the VM…
[default] Clearing any previously set forwarded ports…
[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 machine to boot. This may take a few minutes…
[default] Machine booted and ready!
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
prevent things such as shared folders from working properly. If you see
shared folder errors, please make sure the guest additions within the
virtual machine match the version of VirtualBox you have installed on
your host and reload your VM.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.3
[default] Mounting shared folders…
[default] — /vagrant

mohammedrafi@NOC-RAFI:~/vbox$ vagrant status
Current machine states:

default running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
mohammedrafi@NOC-RAFI:~/vbox$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing!
VAGRANTFILE_API_VERSION = “2”

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = “precise32”

# The url from where the ‘config.vm.box’ box will be fetched if it
# doesn’t already exist on the user’s system.
# config.vm.box_url = “http://domain.com/path/to/above.box”

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing “localhost:8080” will access port 80 on the guest machine.
# config.vm.network :forwarded_port, guest: 80, host: 8080

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network :private_network, ip: “192.168.33.10”

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network :public_network

# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder “../data”, “/vagrant_data”

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider :virtualbox do |vb|
# # Don’t boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize [“modifyvm”, :id, “–memory”, “1024”]
# end
#
# View the documentation for the provider you’re using for more
# information on available options.

# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file precise32.pp in the manifests_path directory.
#
# An example Puppet manifest to provision the message of the day:
#
# # group { “puppet”:
# # ensure => “present”,
# # }
# #
# # File { owner => 0, group => 0, mode => 0644 }
# #
# # file { ‘/etc/motd’:
# # content => “Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n”
# # }
#
# config.vm.provision :puppet do |puppet|
# puppet.manifests_path = “manifests”
# puppet.manifest_file = “site.pp”
# end

# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
# config.vm.provision :chef_solo do |chef|
# chef.cookbooks_path = “../my-recipes/cookbooks”
# chef.roles_path = “../my-recipes/roles”
# chef.data_bags_path = “../my-recipes/data_bags”
# chef.add_recipe “mysql”
# chef.add_role “web”
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => “foo” }
# end

# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision :chef_client do |chef|
# chef.chef_server_url = “https://api.opscode.com/organizations/ORGNAME”
# chef.validation_key_path = “ORGNAME-validator.pem”
# end
#
# If you’re using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = “ORGNAME-validator”
end

mohammedrafi@NOC-RAFI:~/vbox$ tree .vagrant/
.vagrant/
`– machines
`– default
`– virtualbox
|– action_provision
|– action_set_name
`– id

3 directories, 3 files
mohammedrafi@NOC-RAFI:~/vbox$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)

* Documentation: https://help.ubuntu.com/
New release ‘14.04.5 LTS’ available.
Run ‘do-release-upgrade’ to upgrade to it.

Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
vagrant@precise32:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION=”Ubuntu 12.04 LTS”

vagrant@precise32:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:12:96:98 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
inet6 fe80::a00:27ff:fe12:9698/64 scope link
valid_lft forever preferred_lft forever

vagrant1.png
——————————-

mohammedrafi@NOC-RAFI:~$ vagrant box add centos https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box
Downloading box from URL: https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box
Successfully added box ‘centos’ with provider ‘virtualbox’!
mohammedrafi@NOC-RAFI:~$ vagrant box list
centos (virtualbox)
precise32 (virtualbox)

mohammedrafi@NOC-RAFI:~$ mkdir centosbox

mohammedrafi@NOC-RAFI:~$ cd centosbox/

mohammedrafi@NOC-RAFI:~/centosbox$ vagrant init centos
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.

mohammedrafi@NOC-RAFI:~/centosbox$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing!
VAGRANTFILE_API_VERSION = “2”

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = “centos”

# The url from where the ‘config.vm.box’ box will be fetched if it
# doesn’t already exist on the user’s system.
# config.vm.box_url = “http://domain.com/path/to/above.box&#8221;

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing “localhost:8080” will access port 80 on the guest machine.
# config.vm.network :forwarded_port, guest: 80, host: 8080

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network :private_network, ip: “192.168.33.10”

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network :public_network

# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder “../data”, “/vagrant_data”

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider :virtualbox do |vb|
# # Don’t boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize [“modifyvm”, :id, “–memory”, “1024”]
# end
#
# View the documentation for the provider you’re using for more
# information on available options.

# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file centos.pp in the manifests_path directory.
#
# An example Puppet manifest to provision the message of the day:
#
# # group { “puppet”:
# # ensure => “present”,
# # }
# #
# # File { owner => 0, group => 0, mode => 0644 }
# #
# # file { ‘/etc/motd’:
# # content => “Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n”
# # }
#
# config.vm.provision :puppet do |puppet|
# puppet.manifests_path = “manifests”
# puppet.manifest_file = “site.pp”
# end

# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
# config.vm.provision :chef_solo do |chef|
# chef.cookbooks_path = “../my-recipes/cookbooks”
# chef.roles_path = “../my-recipes/roles”
# chef.data_bags_path = “../my-recipes/data_bags”
# chef.add_recipe “mysql”
# chef.add_role “web”
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => “foo” }
# end

# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision :chef_client do |chef|
# chef.chef_server_url = “https://api.opscode.com/organizations/ORGNAME&#8221;
# chef.validation_key_path = “ORGNAME-validator.pem”
# end
#
# If you’re using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = “ORGNAME-validator”
end

mohammedrafi@NOC-RAFI:~/centosbox$ vagrant up
Bringing machine ‘default’ up with ‘virtualbox’ provider…
[default] Importing base box ‘centos’…
[default] Matching MAC address for NAT networking…
[default] Setting the name of the VM…
[default] Clearing any previously set forwarded ports…
[default] Fixed port collision for 22 => 2222. Now on port 2200.
[default] Clearing any previously set network interfaces…
[default] Preparing network interfaces based on configuration…
[default] Forwarding ports…
[default] — 22 => 2200 (adapter 1)
[default] Booting VM…
[default] Waiting for machine to boot. This may take a few minutes…
[default] Machine booted and ready!
[default] Mounting shared folders…
[default] — /vagrant

mohammedrafi@NOC-RAFI:~/centosbox$ tree .vagrant/
.vagrant/
`– machines
`– default
`– virtualbox
|– action_provision
|– action_set_name
`– id

3 directories, 3 files

mohammedrafi@NOC-RAFI:~/centosbox$ vagrant ssh
Last login: Sat May 30 12:27:44 2015 from 10.0.2.2
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS release 6.6 (Final)

[vagrant@localhost ~]$ free -m
total used free shared buffers cached
Mem: 996 152 843 0 7 56
-/+ buffers/cache: 88 907
Swap: 1011 0 1011

[vagrant@localhost ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:2d:82:3a brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
inet6 fe80::a00:27ff:fe2d:823a/64 scope link
valid_lft forever preferred_lft forever

vagrant2.png

mohammedrafi@NOC-RAFI:~$ ls -l .vagrant.d/boxes/
total 8
drwxrwxr-x 3 mohammedrafi mohammedrafi 4096 Mar 31 01:29 centos
drwxrwxr-x 3 mohammedrafi mohammedrafi 4096 Mar 31 00:05 precise32

mohammedrafi@NOC-RAFI:~$ ls -l .vagrant.d/boxes/centos/virtualbox/
total 356440
-rw——- 1 mohammedrafi mohammedrafi 364962304 Mar 31 01:29 box-disk1.vmdk
-rw——- 1 mohammedrafi mohammedrafi 13586 Mar 31 01:29 box.ovf
-rw-rw-r– 1 mohammedrafi mohammedrafi 150 Mar 31 01:29 info.json
-rw-rw-r– 1 mohammedrafi mohammedrafi 25 Mar 31 01:29 metadata.json
-rw-r–r– 1 mohammedrafi mohammedrafi 505 Mar 31 01:29 Vagrantfile

mohammedrafi@NOC-RAFI:~$ cat .vagrant.d/boxes/centos/virtualbox/metadata.json
{“provider”:”virtualbox”}

mohammedrafi@NOC-RAFI:~$ cat .vagrant.d/boxes/centos/virtualbox/info.json
{“url”:”https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box&#8221;,”downloaded_at”:”2017-03-30 19:59:21 UTC”}

mohammedrafi@NOC-RAFI:~$ cat .vagrant.d/boxes/centos/virtualbox/box.ovf

List of the virtual disks used in the package

Logical networks used in the package

Logical network used by this appliance.

A virtual machine

The kind of installed guest operating system
RedHat_64
RedHat_64

Virtual hardware requirements for a virtual machine

Virtual Hardware Family
0
centos-6.6-x86_64
virtualbox-2.2

1 virtual CPU
Number of virtual CPUs
1 virtual CPU
1
3
1

MegaBytes
1024 MB of memory
Memory Size
1024 MB of memory
2
4
1024

0
ideController0
IDE Controller
ideController0
3
PIIX4
5

1
ideController1
IDE Controller
ideController1
4
PIIX4
5

0
sataController0
SATA Controller
sataController0
5
AHCI
20

0
disk1
Disk Image
disk1
/disk/vmdisk1
6
5
17

0
true
cdrom1
CD-ROM Drive
cdrom1
7
3
15

0
true
cdrom2
CD-ROM Drive
cdrom2
8
4
15

true
Ethernet adapter on ‘NAT’
NAT
Ethernet adapter on ‘NAT’
9
E1000
10

Complete VirtualBox machine configuration in VirtualBox format

Advertisements

One thought on “Vagrant on Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s