The Immutable Infrastructure as Code Workstation project bootstraps your localhost for developing Immutable Infrastructure as Code (IIaC). The IIaC toolchain is built around Ansible, which must be installed manually before you begin (see Prerequisites), and as such the workstation is designed to be run from Linux. Windows 11 users can use the Windows Linux Subsystem v2 (WSL2) and its support for GUI apps to run the IIaC toolchain (with a little assistance from Chocolatey.
The full provided IIaC toolchain is as follows:
- Ansible, including pywinrm for developing Windows images base version installed manually, see Prerequisites
- VirtualBox Windows 11 users, see see Prerequisites
- Docker Windows 11 users, see see Prerequisites
- Vagrant
- Terraform
- Packer
- Git
- Visual Studio Code, including extensions for Docker, Vagrant, Terraform, Packer, and Ansible
All users must install Ansible manually before proceeding. Windows 11 users have some additional steps to perform to set up a WSL2 Ubuntu environment for use with the IIaC toolchain.
Note: Once the Windows 11 specific steps are complete, all instructions assume Windows 11 users are operating from within their WSL2 Ubuntu environment.
Ansible only runs under Unix-like operating systems, so Windows 11 users must operate within a WSL2 Ubuntu environment. Further, a WSL Ubuntu environment cannot run VirtualBox or Docker. So, these two tools must also be installed before proceeding with the Ansible install. We will use Chocolatey to facilitate these installations.
- Ensure the WSL2 is installed and up to date
- Determine if WSL2 is installed by running
wsl --status
from an elevated command prompt - If WSL2 is not installed, install it by running
wsl --install
from an elevated command prompt (you will be prompted to reboot, after which execute the following step) - If WSL2 is installed, update it by running
wsl --update
from an elevated command prompt and follow any additional prompts - Confirm WSL2 is fully installed and up to date by running
wsl --status
from an elevated command prompt, again
- Determine if WSL2 is installed by running
- Install Chocolatey
- Install VirtualBox by running
choco install virtualbox
from an elevated command prompt, verify it installed correctly by launching from the Start Menu - Install Docker by running
choco install docker-desktop
from an elevated command prompt, verify it installed correctly by launching from the Start Menu and accepting the license - Install WSL2 Ubuntu environment from the Microsoft Store by launching the Microsoft Store, searching for Ubuntu and clicking the Get button, then launch it from the start menu and follow prompts to create your Ubuntu user
Follow the official Installing Ansible on specific operating systems instructions to install Ansible. Windows 11 users, remember to follow these instructions in your WSL2 Ubuntu environment.
Note, these instructions must be run inside the WSL2 environment.
- Download the iiac-wsl2-env.yaml file to your computer by running
wget https://raw.githubusercontent.com/j-simmons-phd/iiac-workstation/v1.0.0-alpha/iiac-wsl2-env.yaml
- Apply the WSL2 specific environment variables to your .bashrc file by running
ansible-playbook -i,localhost ./iiac-wsl2-env.yaml
- Source your .bashrc file to enable the new environmnet variables by running
source ~/.bashrc
Note, these instructions are for all users, including Windows 11 running inside a WSL2 environment.
- Download the requirements.yaml file to your computer by running
wget https://raw.githubusercontent.com/j-simmons-phd/iiac-workstation/v1.0.0-alpha/requirements.yaml
- Download the iiac-workstation.yaml file to your computer by running
wget https://raw.githubusercontent.com/j-simmons-phd/iiac-workstation/v1.0.0-alpha/iiac-workstation.yaml
- Install the requirements by running
ansible-galaxy install -r requirements.yaml
- Execute the playbook by running
ansible-playbook -i,localhost --ask-become-pass ./iiac-workstation.yaml
Note: If you run into an Vagrant error about chmod
under WSL2 on Windows 11, see the fix at Error `chmod’: Operation not permitted @ chmod_internal.