scottmuc / infrastructure

Documentation / Automation for personal third-party infrastructure
The Unlicense
10 stars 2 forks source link

Enable WSL on Windows #12

Closed scottmuc closed 4 years ago

scottmuc commented 4 years ago

Objective

I want to repurpose my macbook Airr which means I won't have a stable unix-terminal to perform my routine administration of my home network.

This must be easily replicated upon re-pave.

Done When

I can update my DNS records via my existing unix tool-chain.

scottmuc commented 4 years ago

Some good details on WSL here (as in what's the difference between WSL 1 and 2): https://wiki.ubuntu.com/WSL

scottmuc commented 4 years ago

Going through the Microsoft Store installer of the recommended version of Ubuntu.

More good info here: https://docs.microsoft.com/en-us/windows/wsl/compare-versions

scottmuc commented 4 years ago

When launching the Ubuntu App, the shell begins in $HOME in the container which is /home/username.

If I launch wsl from cmd.exe I started a unix path where my Windows homedir is mounted /mnt/c/Users/summer.

scottmuc commented 4 years ago

Line endings are a thing: https://stackoverflow.com/questions/44694331/what-is-the-m-notation-and-where-is-it-documented

scottmuc commented 4 years ago

There's a known issue that the filesystem mounted from windows adds ^M line endings: https://www.scivision.dev/git-line-endings-windows-cygwin-wsl/

scottmuc commented 4 years ago

Here's someone reporting the file permissions differences: https://www.turek.dev/post/fix-wsl-file-permissions/

scottmuc commented 4 years ago

Moar WSL drvfs stuff: https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/

scottmuc commented 4 years ago

Setting up DNS

Ultimately the line-ending cruft of the comments above pointed to just cloning in the container, rather than using the mounted filesystem.

Some hurdles along the way:

Unlocking the git repository

Revealed that certain homedir scripts weren't in the path like easy-op. Once added to the path, it revealed op and jq were not installed. jq seemed to be uninstallable via apt-get install for reasons we don't understand. An apt package name for op didn't stand out. We downloaded a zip from the website (which required the installation of unzip. Once those were installed and working, needed to install git-crypt.

Terraforming DNS

Next phase was to be able to run ./scripts/terraform init dns. This resulted in the need to install terraform (and a 0.12.x specific version). As well as golang to compile the gandi-terraform provider. The existing script was built specifically for osx so some intervention was required.

Eventually, a no-op DNS change was able to execute.

scottmuc commented 4 years ago

Looking at nix might be interesting: https://hugoreeves.com/posts/2019/nix-home/

scottmuc commented 4 years ago

There's a lot more to dive into with WSL. The setup of the linux container is one thing. The downloading and configuring of the linux guest containers is another. I still don't know if WSL1 or WSL2 is more fitting for my use case.

I think I need to start placing usable cross-platform scripts into their own location. Though I'm worried about the web of dependency complexity that I might be introducing. This will be further explored when I actually use WSL more often.

The pain reaching the definition of done was mainly due to much of the prior scripting being written in an macOS specific environment.

A quick summary of improvements that need to be made:

scottmuc commented 4 years ago

For future work, this link is good at describing how to download and install a specific Linux distro: https://docs.microsoft.com/en-us/windows/wsl/install-manual