Skip to main content

Vagrant: Notes

Vagrant Logo

Vagrant is a tool for building and managing virtual machine environments in a single workflow.

Download the latest version of Vagrant for your operating system at https://www.vagrantup.com/downloads.html

Sign up a free account at https://www.vagrantup.com/

Vagrant cheat sheet

vagrant validate : validate Vagrantfile [to save your time]
vagrant init
vagrant up
vagrant ssh
vagrant halt
vagrant destroy
vagrant box list
vagrant box add
vagrant box remove

Vagrantfile

A very simple Vagrantfile to get a 32-bit ubuntu server with codename 'precise' up and running.

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/precise32"
end

Environmental variables

List of Vagrant's environmental variables

VAGRANT_HOME

VAGRANT_HOME can be set to change the directory where Vagrant stores global state. By default, this is set to ~/.vagrant.d (on Linux) or %USERPROFILE%\.vagrant.d (on Windows). The Vagrant home directory is where things such as boxes are stored, so it can actually become quite large on disk.

D:\HashiCorp\Vagrant> mkdir .vagrant.d

D:\HashiCorp\Vagrant>cd \Projects\junos

D:\Projects\junos>vagrant init juniper/vqfx10k-re
Vagrant failed to initialize at a very early stage:

The home directory you specified is not accessible. The home
directory that Vagrant uses must be both readable and writable.

You specified: D:/HashiCorp/Vagrant/.vagrant.d

D:\Projects\junos>cd \HashiCorp\Vagrant

D:\HashiCorp\Vagrant>icacls .vagrant.d /grant BUILTIN\Users:F
processed file: .vagrant.d
Successfully processed 1 files; Failed processing 0 files

Default .vagrant.d folder


List boxes

vagrant box list

Install vagrant on Fedora Workstation

Download https://releases.hashicorp.com/vagrant/2.2.6/vagrant_2.2.6_x86_64.rpm and use dnf/yum to install.

[tuyen@g73jh ~]$ sudo dnf install Downloads/vagrant_2.2.6_x86_64.rpm 
[sudo] password for tuyen: 
Last metadata expiration check: 0:09:39 ago on Thu 24 Oct 2019 07:28:14 AM +07.
Dependencies resolved.
================================================================================
 Package         Architecture   Version              Repository            Size
================================================================================
Installing:
 vagrant         x86_64         1:2.2.6-1            @commandline          40 M

Transaction Summary
================================================================================
Install  1 Package

Total size: 40 M
Installed size: 114 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : vagrant-1:2.2.6-1.x86_64                               1/1 
  Verifying        : vagrant-1:2.2.6-1.x86_64                               1/1 

Installed:
  vagrant-1:2.2.6-1.x86_64                                                      

Complete!
[tuyen@g73jh ~]$ which vagrant
/usr/bin/vagrant
[tuyen@g73jh ~]$ vagrant version
Installed Version: 2.2.6
Latest Version: 2.2.6
 
You're running an up-to-date version of Vagrant!
[tuyen@g73jh ~]$ 

Notes

Use Vagrant with VMware for improved stability, performance, and support: $79 per seat.

From Vagrant website: Vagrant is free and open source. While the VMware providers are not, the revenue is used to continue to develop, support, and grow Vagrant and the community around it.

F:\Projects\ubuntu\bionic64>vagrant plugin install vagrant-vmware-desktop
Installing the 'vagrant-vmware-desktop' plugin. This can take a few minutes...
Fetching: vagrant-vmware-desktop-2.0.3.gem (100%)
Installed the plugin 'vagrant-vmware-desktop (2.0.3)'!

F:\Projects\ubuntu\bionic64>vagrant up
A valid license is required to run the Vagrant VMware
provider. Please visit http://www.vagrantup.com to purchase
a license. Once you purchase a license, you can install it
using `vagrant plugin license`.

F:\Projects\ubuntu\bionic64>

Validate Vagrant file to save time

[tuyen@g73jh ~]$ vagrant validate
Vagrantfile validated successfully.
[tuyen@g73jh lthwk8s]$ 

Vagrant - Setup GitLab server

D:\Projects\lthwgitlab>vagrant up
Vagrant failed to initialize at a very early stage:

The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:

  vagrant plugin repair

If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:

  vagrant plugin expunge --reinstall

Or you may want to try updating the installed plugins to their latest
versions:

  vagrant plugin update

Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-host-shell (= 0.0.4)'

D:\Projects\lthwgitlab>notepad .vagrant

D:\Projects\lthwgitlab>notepad Vagrantfile

D:\Projects\lthwgitlab>vagrant plugin update
Updating installed plugins...
Fetching vagrant-host-shell-0.0.4.gem
Fetching vagrant-junos-0.2.1.gem
Fetching micromachine-3.0.0.gem
Fetching vagrant-vbguest-0.30.0.gem
Updated 'vagrant-vbguest' to version '0.30.0'!

D:\Projects\lthwgitlab>vagrant validate
Vagrantfile validated successfully.

D:\Projects\lthwgitlab>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/ubuntu-16.04'...

Popular posts from this blog

Microsoft Windows Server 2012 R2 Standard Evaluation Product Key

Microsoft Windows Server 2012 R2 Standard Evaluation D2N9P-3P6X9-2R39C-7RTCD-MDVJX DBGBW-NPF86-BJVTX-K3WKJ-MTB6V

ManageEngine ServiceDesk Plus - Reset password

Let's reset the default administrator's password to 'admin'

hmailserver: Notes from the field

hmailserver is one of free open source mail servers running on Microsoft Windows operating system.