How to automate and deploy Windows VMs on Windows, Mac, and Linux?

First published: Monday, September 2, 2024 | Last updated: Monday, September 2, 2024

Automate deployment of different versions of Windows VMs on Windows, Mac, and Linux operating systems using VirtualBox, VMware, and Vagrant.


In this blog post, we presented a simple method for automating the creation, deployment, and administration of different versions of Windows virtual machines on Windows, Mac, and Linux operating systems. This was done using type-2 hosted hypervisor software such as VirtualBox and VMware, along with automation tools like Vagrant. These tools enable the seamless and automated deployment of Windows VMs.

Be sure to carefully review the entire blog post for step-by-step instructions on how to perform automated deployment of Windows virtual machines on Windows, Mac, and Linux operating systems.

Install and configure VirtualBox on Windows, Mac, and Linux

The following resources will help you install and configure VirtualBox on Windows, Mac, or Linux operating systems.

  1. How to install and configure VirtualBox on Windows, Mac, and Linux?

Install and configure Git on Windows, Mac, and Linux

Please refer to the following articles for step-by-step instructions on how to download, install, and configure Git on Windows, Mac, or Linux operating systems.

  1. How to install and configure Git on Windows, Mac, and Linux?

Install Vagrant on Windows, Mac, and Linux

Here are the links to articles with detailed, step-by-step instructions for downloading and installing Vagrant on Windows, Mac, or Linux operating systems.

  1. How to install Vagrant on Windows, Mac, and Linux?

Setup our Windows starter-kit from GitHub

At SloopStash, we are proud to offer our own open source Windows starter-kit repository on GitHub. This repository is designed to provide robust support for a wide range of Windows-based operating systems, including Windows 10, Windows 11, and similar equivalents. Additionally, we are committed to creating, uploading, and maintaining our VM images for these operating systems in Vagrant Cloud. Our comprehensive Windows starter-kit has been meticulously curated to encompass all the essential components needed for building and running any Windows-based VM.

Windows

Below are the steps you can use to setup our Windows starter-kit while using the Windows operating system.

  1. Open the Git Bash terminal in administrator mode.
  2. Execute the below commands in the Git Bash terminal to setup our Windows starter-kit.
# Download Windows starter-kit from GitHub to local filesystem path.
$ git clone https://github.com/sloopstash/kickstart-windows.git /opt/kickstart-windows

Mac

Here are the instructions for setting up our Windows starter-kit on a Mac operating system.

  1. Open the terminal.
  2. Execute the below commands in the terminal to setup our Windows starter-kit.
# Download Windows starter-kit from GitHub to local filesystem path.
$ sudo git clone https://github.com/sloopstash/kickstart-windows.git /opt/kickstart-windows

# Change ownership of Windows starter-kit directory.
$ sudo chown -R $USER /opt/kickstart-windows

Linux

You can use the following commands to setup our Windows starter-kit in any Linux-based operating system.

  1. Open the terminal.
  2. Execute the below commands in the terminal to setup our Windows starter-kit.
# Download Windows starter-kit from GitHub to local filesystem path.
$ sudo git clone https://github.com/sloopstash/kickstart-windows.git /opt/kickstart-windows

# Change ownership of Windows starter-kit directory.
$ sudo chown -R $USER:$USER /opt/kickstart-windows

Configure environment variables on Windows, Mac, and Linux

Before you begin the automated deployment of a Windows VM, it’s important to properly configure the following environment variables in your Windows, Mac, or Linux terminals. These variables are crucial for specifying the operating system (Windows 10, Windows 11), processor architecture (AMD64 or ARM64), edition (server or desktop), and hypervisor (VirtualBox or VMware) that will be utilized for the Windows VM deployment.

Supported environment variables

# Allowed values for $OS_NAME variable.
* windows-10
* windows-11

# Allowed values for $OS_ARCHITECTURE variable.
* amd64
* arm64

# Allowed values for $OS_EDITION variable.
* server
* desktop

# Allowed values for $HYPERVISOR variable.
* virtualbox
* vmware

Set environment variables

In this section, we will configure environment variables for building, deploying, and automating the Windows 10 AMD64 desktop operating system using the VirtualBox hypervisor. These environment variables can be adjusted to automate the deployment of virtual machines for different Windows versions, as mentioned earlier.

# Store environment variables.
$ export OS_NAME=windows-10
$ export OS_ARCHITECTURE=amd64
$ export OS_EDITION=desktop
$ export HYPERVISOR=virtualbox

Deploy and manage Windows VMs with Vagrant automation

Vagrant makes it easy to create, start, stop, and remove virtual machines with simple commands. Our Windows starter-kit includes all the necessary configurations for automated deployment of Windows VMs. This allows you to efficiently build, deploy, and automate Windows VMs by running the appropriate Vagrant commands.

If you encounter any issues while deploying Windows VMs, please raise an issue in our Windows starter-kit on GitHub.

Windows

You can use the below commands to create, deploy, and automate Windows VMs on the Windows operating system using Vagrant.

  1. Open the Git Bash terminal in administrator mode.
  2. Execute the below commands in the Git Bash terminal to build, deploy, and automate Windows VMs.
# Switch to Windows starter-kit directory.
$ cd /opt/kickstart-windows

# Boot Windows VM using Vagrant.
$ VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant up

# SSH to Windows VM using Vagrant.
$ VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant ssh

# Exit from Windows VM.
$ exit

# Halt Windows VM using Vagrant.
$ VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant halt

# Provision Windows VM using Vagrant.
$ VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant provision

# Destroy Windows VM using Vagrant.
$ VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant destroy

Mac and Linux

You can use the following commands to build, deploy, and automate Windows VMs on a Mac or Linux operating system using Vagrant.

  1. Open the terminal.
  2. Execute the below commands in the terminal to build, deploy, and automate Windows VMs.
# Switch to Windows starter-kit directory.
$ cd /opt/kickstart-windows

# Boot Windows VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant up

# SSH to Windows VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant ssh

# Exit from Windows VM.
$ exit

# Halt Windows VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant halt

# Provision Windows VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant provision

# Destroy Windows VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant destroy