Skip to content

HashiCorp Vagrant Configuration and scripting files

License

Notifications You must be signed in to change notification settings

jatutert/Vagrant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Vagrant Install

Installing and configuring Vagrant on your own laptop and/or PC may seem complicated, but it is not at all.

To get Vagrant working, you need to perform 7 steps. I have described these 7 steps below. I myself work with Vagrant within Windows. Hopefully I have described all steps for MACos correctly. If not, please let me know !

I make the assumption that VMware Workstation Pro or VMware Fusion Pro is installed. If not, this should be done first. VMware Workstation Pro and VMWare Fusion Pro is now free for personal use. So that shouldn't be a problem.

VMWare Workstation 17.6 Pro for Windows Download

VMware Workstation 17.6 Pro for Linux Download

VMware Fusion 13.6 Pro for MACos Download

[Step 1] Downloading the software

Windows

Download Vagrant 2.4.3 Download

Download Vagrant VMware Plugin Download

MacOS

Download Vagrant 2.4.3 Download

Download Vagrant VMware Plugin Download

[Step 2a] Installation of Vagrant

Install Vagrant 2.4.3 and reboot your laptop or PC (don't skip the reboot!]

Just click Next, Next, Finish during the installation (default settings).

[Step 3] Installation of VMware Plugin

Install Vagrant VMware Plugin (this time no reboot is needed !)

Just click Next, Next, Finish during the installation.

[Step 4] Configuration

Start Terminal

Windows

setx /M VAGRANT_DEFAULT_PROVIDER "vmware_desktop"
setx /M VAGRANT_EXPERIMENTAL "1"
setx /M VAGRANT_SUPPRESS_GO_EXPERIMENTAL_WARNING "1"
setx /M VAGRANT_VAGRANTFILE "Vagrantfile-latest.rb"
exit

Configure VMWare Workstation PRO (or Fusion PRO) to be the default hypervisor for the virtual machines.

I want to use the latest options of Vagrant, so i set the Experimental settings to ON using 1.

The default name of the vagrantfile is set to Vagrantfile-latest.rb.

It is very important to close the terminal. Otherwise the settings are not loaded !

Windows

setx VAGRANT_CWD "C:\Users\ [your username]  "
setx VAGRANT_VMWARE_CLONE_DIRECTORY "x:\Directory of your choice where virtual machines should be stored"
setx VAGRANT_HOME "x:\Directory of your choice where Vagrant stores the settings and downloaded boxes"
exit

The VAGRANT_CWD is the location where VAGRANT searches for the vagrantfile (the configuration file for Vagrant).

The VAGRANT_VMWARE_CLONE_DIRECTORY is the location where VAGRANT stores the created virtual machines by Vagrant.

Examples:

setx VAGRANT_CWD "C:\Users\John" (I use my standard user directory for this)

setx VAGRANT_VMWARE_CLONE_DIRECTORY "D:\VirtualMachines\Vagrant" (I want to store the virtual machines on drive D:)

It is very important to close the terminal. Otherwise the settings are not loaded !

More information at Vagrant Docs

[Step 5] Initialization (Windows/MACos)

del %userprofile%\Vagrantfile-latest.rb
vagrant init
exit

[Step 6] VMware Desktop Plugin installation (Windows/MACos)

vagrant plugin install vagrant-vmware-desktop
exit

Terminal must be closed to load the environment variables

[Step 7] Replace Vagrantfile

Download My Custom Vagrantfile.

Put this file in the folder Downloads (Windows).

Windows

Remove the default vagrantfile

del %HOMEDRIVE%\vagrantfil*.*
exit

Replace the default vagrantfile with the one i created

copy %HOMEDRIVE%\Downloads\Vagrantfile-latest.rb %HOMEDRIVE%
exit

MACos

del ~/vagrant.d/vagrantfil*.*
exit

! DON'T FORGET !

Store the custom vagrantfile (Vagrantfile-latest.rb) in ~/vagrant.d/

[Step 8] Check Vagrant

vagrant global-status
exit

The message should be:

There are no active Vagrant environments on this computer!

Or, you haven't destroyed and recreated Vagrant environments that were started with an older version of Vagrant.

[Step 9] Adding Linux boxes (Windows/MACos)

Start terminal

vagrant box add gusztavvargadr/ubuntu-server-2404-lts --clean --provider vmware_desktop
vagrant box add gusztavvargadr/ubuntu-desktop-2404-lts --clean --provider vmware_desktop
exit

The Linux boxes use about 4 gigabyte of diskspace per box.

[Step 10] Adding Windows boxes (Windows/MACos)

Start terminal

vagrant box add xenov/windows-10 --clean --architecture amd64 --provider vmware_desktop --box-version 2202.1740574724
vagrant box add gusztavvargadr/windows-11 --clean --architecture amd64 --provider vmware_desktop
vagrant box add gusztavvargadr/windows-server-2022-standard --clean --architecture amd64 --provider vmware_desktop --box-version 2102.0.2503
exit

Each box takes about 5 to 10 minutes to download and install ! Time for a drink .. or snack .. or both !

The Windows boxes use about 15 gigabyte of diskspace per box.

Start the fun !

That was it then. You're all set with the installation and configuration of the environment.

Let's start the fun !

Ubuntu Server 24.04 LTS

Generic with 16 GB of RAM (XL = 16 GB, L = 8 GB, M = 4 GB, S = 2 GB)

vagrant up U24-LTS-S-BCV-XL-001

Docker

vagrant up U24-LTS-S-DCKR-001
vagrant ssh U24-LTS-S-DCKR-001
sudo ~/ubuntu-config-V3-latest.sh docker
exit
vagrant ssh U24-LTS-S-DCKR-001
docker stop portainer
docker start portainer
ip addr show eth0

The ubuntu-config-V3-latest.sh script does the installation of the latest version of Docker within the box.

Start your webbrowser and go to https://xxx.xxx.xxx.xxx:9443 (use the ip address from ETH0:)

For the password use something simple like Password1234

Use pwsh to start Microsoft Powershell 7.5.x within the box.

Want to use Cockpit ? The go to https://xxx.xxx.xxx.xxx:1234 (use the ip address from ETH0:)

Windows 10 Enterprise

Generic with 8 GB of RAM (XL = 16 GB, L = 8 GB, M = 4 GB, S = 2 GB)

vagrant up W10-ENT-D-B-XV-L001

Go to VMWare Workstation and login with the user vagrant and password vagrant

Right click on the START button and select Windows Powershell(Admin)

cmd
winget update
Y
winget install Microsoft.PowerShell
winget install Microsoft.DotNet.DesktopRuntime.8
winget install Microsoft.WindowsTerminal
winget install Microsoft.VisualStudio.Code
winget install GNU.Nano
exit
exit

Windows Server 2022 Standard

Generic with 8 GB of RAM (XL = 16 GB, L = 8 GB, M = 4 GB, S = 2 GB)

vagrant up W22-STD-S-B-GR-L001

Powershell 7 can also be installed within the Windows Server 2022 Standard virtual machine.

Follow the instructions as described above under Windows 10.

SSH into the virtual macine

For Example:

vagrant ssh W10-ENT-D-B-XV-L001
vagrant ssh W22-STD-S-B-GR-L001

Shutting down

For Example:

vagrant halt W10-ENT-D-B-XV-L001
vagrant halt W22-STD-S-B-GR-L001

Remove Virtual machine

For Example:

vagrant halt W10-ENT-D-B-XV-L001
vagrant destroy W10-ENT-D-B-XV-L001 --force

More Info

More information on Vagrant configuration files can be found on Vagrant docs

License / Copyright / Trademarks

  • Vagrant by Hashicorp Inc. (hashicorp.com)
  • Virtualbox by Oracle Corporation (oracle.com)
  • VMware by VMware Company (vmware.com) / Broadcom (broadcom.com)
  • Windows by Microsoft Corporation (microsoft.com)

Everything I describe is intended for personal or educational use. In my case, that is primarily educational use.

All references to and quotations from external sources are licensed and/or copyright the respective owners. I make no claim to ownership of these sources. References to and quotations from these sources have been used on the basis of assumption of reasonableness and fair use. To my knowledge, no copyright or other rights have been infringed. If it is believed that references to and/or quotations from certain external sources violate any rules, rights or interests, please contact.

About

HashiCorp Vagrant Configuration and scripting files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published