Installing MAAS CLI on WSL 2
Installing MAAS CLI on WSL2
This is a short post on how to install MAAS CLI on WSL2 so you can administer your MAAS environments for your Windows system.
If anyone reading this is confused as to what MAAS (Metal-as-a-Service) is, it’s an open source cloud platform from Canonical allowing you to manage bare-metal infrastructure, such as networking and server deployments within your DC. https://maas.io/how-it-works
There are a number of blog post going into deeper depth from my colleague Matthew Quickenden here: https://www.cryingcloud.com/blog/tag/%23MAAS
TL;DR
Here's all the command you need to run:
# Setup repo
MAAS_VERSION=3.5
sudo apt-add-repository ppa:maas/${MAAS_VERSION}
# Install OpenSSL Python module
sudo apt install python3-pip
pip install pyOpenSSL
# Install MAAS CLI
sudo apt install maas-cli
Installing MAAS CLI
Following the official documentation for installing the CLI, it tells you to initially run this command:
sudo apt install maas-cli
When you attempt via WSL2 for the first time, you're likely to see the following error:
E: Unable to locate package maas-cli
To get around this you need to run the following:
MAAS_VERSION=3.5
sudo apt-add-repository ppa:maas/${MAAS_VERSION}
Running sudo apt install maas-cli
will give you something similar to this:
Dependent on your setup, you may need to run the following to install the OpenSSL Python module
# Install pip if not available
sudo apt install python3-pip
# Install OpenSSl module
pip install pyOpenSSL
If the module isn't present, you'll get an error like this:
When the pre-reqs are in place running the maas
command should return something similar:
Updating Azure CLI on WSL2
I came across an issue on my local system when attempting to update Azure CLI to the latest version so that I could check out the Azure Arc HCIBox Jumpstart (It needs at least version 2.40.0).
I’m running Windows 11, with WSL2 Ubuntu-20.04 and I installed the AZ CLI using the one line install command. At the time, it was version 2.39.0
I tried to use the ‘az upgrade’ command, but it didn’t work.
So I went to the link provided https://aka.ms/doc/InstallAzureCli
There was nothing regarding the issue I had, so I figured I had to remove the cli and re-install.
Here’s the command I ran to remove the CLI
rm -r $HOME/lib/azure-cli
rm $HOME/bin/az
sed -i '/$HOME\/lib\/azure-cli\/az.completion/d' $HOME/.bash_profile
hash -r
I figured I should use apt for the re-install:
sudo apt-get update && sudo apt-get install --only-upgrade -y azure-cli
Checking the version shows I now have the latest version:
And it looks like running ‘az upgrade’ should work…
Cool! Now it’s time to check out the HCIBox ;)
Terraform and WSL2 issue
Here’s a quick note on an issue that I encountered today (plus it seems, many other people).
I went to run a Terraform workflow on my system via WSL2, but I cam across a number of problems.
First, was that I couldn’t obtain the State that was stored in an Azure Storage account container. Previously, I used the following config:
backend "azurerm" {
resource_group_name = ""
storage_account_name = ""
container_name = "terraform-backend"
key = ""
}
At runtime, I would specify the values like the example below.
export TF_CLI_ARGS_init="-backend-config=\"storage_account_name=${TERRAFORM_STATE_CONTAINER_NAME}\" -backend-config=\"resource_group_name=${RESOURCE_GROUP_NAME}\" -backend-config=\"access_key=${STG_KEY}\""
However, today, that didn’t work as it just stalled trying to connect to the storage container.
I thought it was something wrong with my credentials, so for troubleshooting purposes, I added the storage account key to see if that made a difference
backend "azurerm" {
resource_group_name = ""
storage_account_name = ""
container_name = "terraform-backend"
key = ""
access_key = ""
}
I added the primary storage key and lo and behold, this time, it worked.
Strange, as I hadn’t updated the terraform cli or providers.
The next problem I saw was that when I tried to run
terraform plan
it would not complete, seemingly freezing. To troubleshoot this, I ran
export TF_LOG="TRACE"
before running the plan to tell me what was happening in the background.
This in turn produces a verbose output, but something that did catch my was this:
Strange. I know I have internet connectivity and I could certainly connect to Azure using az cli, so I did some Goole-fu and found the following: https://github.com/microsoft/WSL/issues/8022
It was exactly the same problem I had encountered.
Applying the fix https://github.com/microsoft/WSL/issues/5420#issuecomment-646479747 worked for me and persisted beyond a reboot.
(run the code below in your WSL2 instance)
sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf
It appears to have occurred in the latest Windows update and affects WSL2. It only appears to affect Go / Terraform as far as I can tell.
Hopefully this will help anyone having a similar issue until the Go provider is fixed.
Topic Search
-
Securing TLS in WAC (Windows Admin Center) https://t.co/klDc7J7R4G
Posts by Date
- March 2025 1
- February 2025 1
- October 2024 1
- August 2024 1
- July 2024 1
- October 2023 1
- September 2023 1
- August 2023 3
- July 2023 1
- June 2023 2
- May 2023 1
- February 2023 3
- January 2023 1
- December 2022 1
- November 2022 3
- October 2022 7
- September 2022 2
- August 2022 4
- July 2022 1
- February 2022 2
- January 2022 1
- October 2021 1
- June 2021 2
- February 2021 1
- December 2020 2
- November 2020 2
- October 2020 1
- September 2020 1
- August 2020 1
- June 2020 1
- May 2020 2
- March 2020 1
- January 2020 2
- December 2019 2
- November 2019 1
- October 2019 7
- June 2019 2
- March 2019 2
- February 2019 1
- December 2018 3
- November 2018 1
- October 2018 4
- September 2018 6
- August 2018 1
- June 2018 1
- April 2018 2
- March 2018 1
- February 2018 3
- January 2018 2
- August 2017 5
- June 2017 2
- May 2017 3
- March 2017 4
- February 2017 4
- December 2016 1
- November 2016 3
- October 2016 3
- September 2016 5
- August 2016 11
- July 2016 13