MAAS on Ubuntu: Turn 100 Physical Servers into a ‘Cloud’ Instantly

Ubuntu tutorial - IT technology blog
Ubuntu tutorial - IT technology blog

Quick Start: Set up a MAAS Lab in 5 Minutes

If you want to quickly tinker with MAAS on a fresh Ubuntu server, run this command block in your terminal. This is the method I usually use to demo for clients or set up a quick test environment before deploying a real system.

# Update the system
sudo apt update && sudo apt upgrade -y

# Install MAAS via Snap - Fast, clean, and Canonical standard
sudo snap install maas

# Initialize MAAS with built-in DB (Lab/Test only)
sudo maas init region+rack --database-uri maas-test-db:///

# Create admin account
sudo maas createadmin --username admin --email [email protected] --password mypassword123

Once finished, access http://<Server-IP>:5240/MAAS. Log in with the account you just created and enjoy the initial results.

Why struggle with USB Boot when you have MAAS?

In the past, every time the company imported 30 Dell R740s, my team and I would break a sweat. We all had to laboriously plug in USBs, type out IP configurations, and add SSH keys for each one. The whole process took at least 2 full days and was very prone to errors.

MAAS (Metal as a Service) was born to solve that “pain.” It makes your Bare Metal infrastructure as flexible as AWS. You just need to plug in the network cable and power it on. MAAS handles everything from recognition (Discovery) and hardware testing (Commissioning) to OS installation (Deploy) via a single API command.

The MAAS system operates based on two core components:

  • Region Controller: The brain that controls and manages the database and the Web/API interface.
  • Rack Controller: The extended arm responsible for PXE booting and providing DHCP to servers in the rack.

Proper Setup for Production Environments

Don’t use maas-test-db if you plan to run it for real. To handle hundreds of nodes, you must use a dedicated PostgreSQL instance to ensure performance and regular backups.

1. Install Dedicated PostgreSQL

sudo apt install -y postgresql

# Create a dedicated User and DB for MAAS
sudo -u postgres psql -c "CREATE USER "maas" WITH ADMIN OPTION PASSWORD 'your_secure_password';"
sudo -u postgres createdb -O "maas" "maasdb"

# Open port if the DB is on a different server
echo "host maasdb maas 0/0 md5" | sudo tee -a /etc/postgresql/14/main/pg_hba.conf

2. Connect MAAS to the Actual Database

Instead of using the default database, point MAAS to the PostgreSQL instance you just configured:

sudo maas init region+rack --database-uri "postgres://maas:your_secure_password@localhost/maasdb"

3. Network Configuration: Avoid DHCP Conflicts

The most common mistake for beginners is that the child nodes don’t receive IPs. My experience: Let MAAS handle the DHCP. Don’t try to use the main router’s DHCP unless you want to spend all day troubleshooting DHCP Relays.

  • Go to Subnets on the Web interface.
  • Select the VLAN and enable DHCP.
  • Set a Dynamic Range wide enough for the expected number of servers.

When a new server powers on and prioritizes PXE Boot, it will receive an IP from MAAS. Then, the machine will load a small image into RAM to scan CPU, RAM, and Disk info before reporting back to the Dashboard in a New state.

The ‘Pitfalls’ I Encountered After 6 Months of Operation

Working with hardware is always full of surprises. Here are 3 key points to help you operate more smoothly.

Power Management

To let MAAS remotely power servers on/off, you must configure IPMI (iDRAC on Dell, iLO on HP). Without this, every time you deploy, you’ll have to walk to the rack to press the power button. It’s tedious and unprofessional.

Go to the node configuration, select Power type as IPMI. Next, fill in the management IP along with the credentials for that machine’s management card.

Using Commissioning Scripts

Want to check if a hard drive has bad sectors before installing the OS? MAAS allows you to run custom scripts during the testing phase. I often include scripts to automatically update BIOS Firmware here to ensure all nodes have consistent versions.

# Simple CPU temperature check script
#!/bin/bash
sensors | grep "Core 0"

Speeding Up with Local Image Mirror

By default, MAAS pulls images from Canonical servers abroad. If the undersea cable is cut, deploying an Ubuntu 22.04 instance could take an hour. Set up a local mirror. It will help reduce deployment time to just 5-7 minutes per machine.

Advanced: Optimizing with Custom Images via Packer

In reality, we rarely install a vanilla Ubuntu version. I often use packer to pre-build images with Docker installed and SSH hardening configured. When uploaded to MAAS, you’ll have a ‘battle-ready’ server as soon as the OS installation is complete.

# Command to upload the packaged image
maas admin boot-resources create name='custom/ubuntu-hardened' \
    architecture='amd64/generic' filetype='tgz' \
    content@=/path/to/your/image.tar.gz

Final Thoughts for SysAdmins

MAAS is not merely a tool for casual OS installation. It is a foundation for building a true Private Cloud. When combined with Terraform, you can spin up an entire Kubernetes cluster on physical machines with a single command.

If your infrastructure starts to exceed 10 servers, don’t hesitate. Install MAAS now. Just stick to the Network and IPMI configurations as I shared, and your system will run smoothly and be extremely easy to manage.

Share: