Skip to content
This repository has been archived by the owner on Oct 27, 2023. It is now read-only.

Automating provisoning ubuntu 20.04 with Ansible on WSL 2

License

Notifications You must be signed in to change notification settings

ministryofjustice/provision-ubuntu2004-on-wsl2

Repository files navigation

Notice of deprecation

The Lan&WIFI (DevOps) Team, no longer use Windows PC's therefore this repo is no longer maintained.

We have moved to our Mac developer provisioner script: linuxify

Provision Ubuntu 2004 on WSL2

Automating provisioning Ubuntu 20.04 with Ansible on WSL 2

Uses ansible, in a pipenv, in a WSL 2 Ubuntu instance to provision locally.

Intended to be re-runnable (idempotent) to maintain and update when required.

Getting Started

Prerequisites

  1. Windows 10

  2. WSL 2 (to enable, run the below commands in an elevated powershell prompt)

  3. dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

  4. dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

  5. Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

  6. wsl --set-default-version 2

  7. wsl --shutdown

  8. List available wsl distros wsl --list --online

  9. Ubuntu 20.04 installed via cmd wsl --install -d Ubuntu-20.04

  10. Generate an SSH key in your Ubuntu instance and add to Github

  11. In PowerShell type ipconfig and note/copy the "Default Gateway" ip for "Wireless LAN adapter WiFi:"

  12. Temp fix DNS echo "<default gateway ip>" > /etc/resolv.conf

  13. Now you can clone this repo!

Fix known DNS issues with WSL2

  1. ./scripts/fix_dns.sh -n "192.168.x.x" -h "a-host-name" (your home router IP)

Configure Python & pipenv (only need to do this once)

  1. Install Make sudo apt install make
  2. sudo apt-get update
  3. make prep
  4. make env

Clone and Run (the first time)

  1. make shell
  2. ansible-galaxy install -r requirements.yml
  3. ansible-playbook playbook.yml -i inventory --ask-become-pass

Updating after adding new tasks or applications

  1. cd provision-ubuntu2004-on-wsl2
  2. make shell
  3. make update

What is Installed?

Notes

Description Command
Find all local info ansible localhost -m setup
Run only rbenv ansible-playbook playbook.yml -i inventory --ask-become-pass --tags "rbenv"
Purge deps pipenv uninstall --all

See vars.yml to configure which tasks get run.

References

About

Automating provisoning ubuntu 20.04 with Ansible on WSL 2

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •