Overview
Installing MAAS is easy, but building an environment to experiment with it requires more effort. MAAS works by detecting servers attempting to boot via the network (PXE booting), meaning it must be on the same network as the servers.
This can cause issues at home or in an office, as MAAS provides a DHCP server, potentially interfering with your usual network.
A potential MAAS test setup
One option is setting up a separate network with a switch, router, and several servers. One server would run MAAS, and the others would be target servers for MAAS to provision.
However, for casual experimentation, this setup can be overkill. This tutorial will show you how to create a similar environment contained entirely within your PC or laptop.
Multipass
Multipass is a tool that easily creates virtual machines (VMs). In this tutorial, Multipass will create a self-contained VM with both MAAS and an LXD host on your computer.
LXD
Inside the VM, Multipass will use LXD to set up a virtual private switch and router, allowing you to create “nested VMs” (virtual machines inside the VM). These nested VMs will act as servers that MAAS can provision.
By the end of this tutorial, you’ll be able to log into the MAAS server running in the VM on your computer, create nested VMs using LXD, and commission and deploy them. This gives you a quick way to experiment with MAAS without needing a full physical setup.
Requirements
You’ll need:
- Ubuntu Desktop 18.04 or higher
- 16 GB of RAM
- A quad-core CPU with virtualization support (Intel VT or AMD-V)
- Virtualization enabled in the BIOS
- 30 GB of free disk space
The memory and disk space are required to launch nested VMs using MAAS and LXD.
Install Multipass
To install Multipass, run the following:
sudo snap install multipass
Check if Multipass is working by launching a test VM:
multipass launch --name foo
multipass exec foo -- lsb_release -a
You should see the output of the lsb_release -a
command inside the VM.
Delete the test VM:
multipass delete foo && multipass purge
Now you’re ready to create the MAAS and LXD environment.
Check Virtualization
Ensure virtualization is working by running:
sudo apt install cpu-checker
kvm-ok
If virtualization is enabled, the output should confirm that KVM is available.
Get the MAAS Multipass Config File
Download the configuration file needed to set up the environment:
cd ~/Downloads
wget https://raw.githubusercontent.com/antongisli/maas-multipass/main/maas.yml
Verify the download:
ls ~/Downloads/maas.yml
Launch the MAAS and LXD Multipass Environment
Launch the VM with the downloaded config file:
multipass launch --name maas -c 4 -m 8GB -d 32GB --cloud-init ~/Downloads/maas.yml
Once the VM is up, confirm it’s running:
multipass list
Note the two IP addresses: one for the internal network (10.10.10.1) and the other to connect to MAAS from your computer. We will refer to this second IP address as <MAAS IP>
in the following steps.
Log into MAAS
Now that MAAS is running, finalize the setup by configuring DNS and verifying the installation.
From a browser, navigate to:
http://<MAAS_IP>:5240/MAAS
Log in with the username admin
and password admin
. You’ll be prompted to set the DNS forwarder—enter 8.8.8.8
.
Scroll down, click Continue, and leave the browser open.
Set Up an SSH Key Pair
You need an SSH key for MAAS to enable SSH access to the VMs it provisions. Create an SSH key pair inside the MAAS VM:
multipass shell maas
ssh-keygen -t rsa -b 4096
Display the public key:
cat ~/.ssh/id_rsa.pub
Copy the public key and go back to your browser. Under “Source”, select “Upload”, paste the key, and click Import.
Verify and Explore the MAAS and LXD Installation
MAAS may still be downloading Ubuntu images, which can take some time depending on your connection. You can check the status by clicking the Images tab—once synced, the status will read “Synced”.
Next, click the KVM tab, and you should see an LXD server set up. Under the Controllers tab, verify that the rack and region controller
is running with a green status tick.
Create a VM Guest
To create a VM guest, go back to the KVM tab and click the MAAS link under “NAME”. Then click Compose VM.
Fill in the following details:
- Hostname:
AwesomeVM1
- RAM: 6 GB
- Storage: 8 GB
- CPU cores: 2
Click Compose machine.
Commission and Deploy Ubuntu to the VM Guest
MAAS will now begin commissioning the machine, running tests on CPU, memory, and storage. You can view this under the Machines tab.
Once commissioning is complete, the machine will enter a READY
state. From the Machines tab, tick the checkbox for AwesomeVM1
, click the green Take action button, and select Deploy.
After confirming the deployment, MAAS will install Ubuntu on the VM guest.
Verify the VM Guest
Once the VM is deployed, log into it via SSH. First, check that it’s online:
ping <AwesomeVM1 IP>
Then SSH into the VM:
ssh ubuntu@<AwesomeVM1 IP>
You can now ping external sites from the VM to verify connectivity:
ping www.ubuntu.com
That’s it! You’ve created and deployed a VM inside your Multipass VM using MAAS and LXD.
Next Steps
You’ve learned how to:
- Install a MAAS and LXD environment using Multipass
- Create and deploy a VM guest
- Set up MAAS with SSH keys
- Verify MAAS and LXD functionality
You can continue experimenting by creating more VMs or deleting and recreating machines from the Machines and KVM tabs. For more advanced configurations, try modifying the maas.yml
file to change the resources allocated to your MAAS VM.
Explore more about MAAS at maas.io. Consider setting up a real physical environment with MAAS and LXD.