In this guide, I will show you how I (primarily a Linux user) setup a Windows workstation to get:
- a nice terminal emulator (Cmder)
- a package manager to automate installing and updating software (Chocolatey)
- a UNIX-like build environment (MSYS2)
- a good text editor that won’t mess with formatting (Notepad++)
- a solution to create and manage virtual machines (VirtualBox and Vagrant)
Why would I do this? Link to heading
Though I’m using Linux most of the time, I sometimes work with:
- software running exclusively on Windows
- cross-platform software that runs on Linux and Windows hosts
- corporate development teams who are provided with Windows workstations, but work in Linux VMs and deploy to Linux servers
In such situations, it is useful to have a development and command-line environment that resembles what is available in the UNIX world, with some level of automation when setting up new workstations.
OS Information Link to heading
- Windows 7
- Professional Edition
- 64-bit
Step 1: Install the Chocolatey package manager Link to heading
With Chocolatey, we will be able to install and manage software packages on Windows,
much like package managers available on Linux (apt-get
, pacman
, yum
, etc.) or macOs (brew
).
Thanks to an active community, there are many packages available, most of which can be installed non-interactively (no user input nor interaction with the setup wizard required).
Under the hood, packages come as:
- NSIS installers;
- portable Zip archives;
- binaries.
Follow Installing Chocolatey to set it on your computer!
Once installed, we will be able to run commands such as:
$ choco install -y git
Step 2:Install the Cmder terminal emulator and shell session manager Link to heading
Cmder is a terminal emulator based on ConEmu, with extra bells and whistles.
It is available on Chocolatey as cmdermini
:
$ choco install -y cmdermini
Step 3: Install the Notepad++ text editor Link to heading
Notepad++ is a fast, lightweight and handy text editor, with syntax highlighting support for many programming languages.
$ choco install -y notepadplusplus
Step 4: Install the MSYS2 build environment Link to heading
MSYS2 is a software distribution and building platform for Windows. It relies on Cygwin to provide native builds of GNU and UNIX shell utilities, and provides a plethora of installable packages.
MSYS2 is available on Chocolatey as msys2
:
$ choco install -y msys2
Step 5: Install VirtualBox and Vagrant to manage virtual machines Link to heading
VirtualBox Link to heading
VirtualBox is a convenient virtualization solution available for Windows, Linux and MacOS, that comes with a graphical interface, and good drivers for graphics, CPU, RAM, networking and storage virtualization.
VirtualBox is available on Chocolatey as virtualbox
:
$ choco install -y virtualbox
Before creating new virtual machines, you may want to configure:
- networking: host, bridge or NAT
- graphics drivers: to run a graphical environment inside a VM (such as Gnome or KDE)
- CPU, RAM and storage quotas: to provide appropriate resources to virtual machines
- folder synchronization: to share data between the host (your Windows computer) and the guest (the virtual machine)
- USB passthrough: to use USB devices from inside a VM
A limitation here is that to spin up a VM, you have to either:
- use the installation image (ISO) and go through the full installation wizard;
- start with an image of an existing VM, that may have incomplete or incorrect configuration (or someone else’s credentials, even).
As setting up a new VM can quite time-consuming as well as error-prone, this is where Vagrant will help!
Vagrant Link to heading
Vagrant is a tool by HashiCorp that automates setting up virtual machines with various virtualization providers, such as VirtualBox.
Vagrant is available on Chocolatey as vagrant
:
$ choco install -y vagrant
Once installed, you can use Vagrant to create and start virtual machines, such as:
- a graphical environment, display manager and desktop environment that can be used for development;
- a headless environment to run databases and servers.
Vagrant reads a Vagrantfile, that:
- defines which provider is used to provision (create and manage) virtual machines;
- describes the configuration and desired state of the virtual machines;
- can invoke tools such as Ansible or Puppet to provision virtual machines.
Instead of starting from scratch, Vagrant comes with existing, pre-configured virtual machine templates, called Boxes.
With many boxes available from the Vagrant team and the community, this will make setting up new VMs a breeze!
Use cases Link to heading
Some scenarii I have been putting the tools mentioned above to good use.
Throw-away VMs Link to heading
- Write a
Vagrantfile
to define and configure a new VM - Run
vagrant up
to create and start the VM - (…)
- Run
vagrant halt
to stop the VM - Run
vagrant destroy
to delete the VM
Local development servers Link to heading
- Configure VirtualBox networking so the VMs are created with a local IP address that can be reached from your host;
- Write a
Vagrantfile
to define and configure one (or several) VMs - Run
vagrant up
to create and start the VMs - Reuse existing scripts, Ansible playbooks or Puppet manifests to provision the VMs
- Deploy your applications to the VMs and run tests
- Run
vagrant halt
to stop the VM - Run
vagrant destroy
to delete the VM
Local development environments Link to heading
Same as the above, with the addition of:
- a graphical environment, display manager and desktop environment (Gnome, KDE, i3, etc.)
- your favourite text editor or IDE
- additional development tools such as Git, Postman, DBeaver, etc.
Shared development environment templates Link to heading
I have successfully (and repeatedly) used Vagrant, VirtualBox and Ansible to:
- create a template VM
- provision it with Ansible, using:
- the same Ansible roles as on production servers
- additional roles to setup a graphical environment, development tools, IDEs, etc.
- adapted playbooks
- archive the resulting VM as an base image
- publish it to a shared location that can be used by developers to create their own VMs from
This ensures all developers:
- start with a functional VM, with all requirements installed and pre-configured
- can then configure their VMs to their needs
- can quickly recreate a new VM