Bootstrap MAAS

MAAS, or Metal as a Service, streamlines hardware management for data centers and clouds. It turns servers into a flexible resource pool, enabling rapid deployments and easy scalability. From setup to orchestration, MAAS simplifies complex tasks, making hardware management a breeze. Let’s dive in and unlock the potential of MAAS together.


Before mastering MAAS, ensure you have the essentials:

  1. Hardware: Ensure that the hardware (where you want to install MAAS) meets the minimum requirements.

  2. OS Knowledge: Familiarity with Ubuntu and basic Linux commands is beneficial.

  3. Network Skills: Understanding IP, subnetting, DNS, DHCP, and basic cloud networking makes MAAS much easier to set up.

  4. MAAS Server: A MAAS server generally needs Internet connectivity (though there is an air-gapped configuration.

  5. Admin Access: You’ll need administrative privileges for MAAS installation and configuration.

With these prerequisites, you’re ready to install MAAS.


Let’s leverage the potential of MAAS. To install MAAS on your Ubuntu host:

  1. Update your package index and install dependencies:

    sudo apt update
    sudo apt install snapd lxd lxd-client python3-lxc python3-openstackclient
  2. Install the MAAS snap package:

    sudo snap install maas
  3. Install the PostgreSQL database:

    sudo apt install postgresql postgresql-contrib
  4. Switch to the postgres user and open the PostgreSQL shell:

    sudo su - postgres
  5. Create a database user for MAAS:

    CREATE USER maas WITH PASSWORD 'password';
  6. Create the MAAS database:

    CREATE DATABASE maasdb OWNER maas;
  7. Exit PostgreSQL and return to your regular user:

  8. Edit /etc/postgresql/12/main/pg_hba.conf, adding a line like the one below, to allow the MAAS user to connect:

    sudo vi /etc/postgresql/12/main/pg_hba.conf
    host    maasdb    maas    0/0     md5
  9. Initialize MAAS, specifying the PostgreSQL URL:

    sudo maas init region+rack --database-uri postgres://maas:password@localhost/maasdb
  10. Make a note of the URL this command returns, of the form – you’ll need it later:

  11. Visit the web UI at the URL you just noted and create your admin account.

MAAS is now installed, marking the first step toward efficient hardware management, but your journey with MAAS is just beginning. With the core installation done, you’re set to explore its powerful features, including configuring, optimizing, commissioning, deploying nodes, and seamless infrastructure integration in the upcoming section.

Initial configuration

Now that you’ve installed MAAS, it’s time to optimize your environment for efficient hardware management. In this section, we’ll guide you through configuring the web-based interface, DNS settings, SSH keys, and more. Your MAAS installation will be finely tuned, ready for managing and provisioning nodes.

After installing, complete the initial configuration:

  1. Access MAAS at this address, where $API_HOST is the MAAS URL which was generated earlier:


    Log in using the login information you created when initializing MAAS.

  2. In the web UI, go to Settings > General and set a forward DNS server, such as “”.

  3. Under Images, select the Ubuntu release to sync; you can usually accept the default.

  4. Under Accounts, import your SSH public key from Launchpad or GitHub, or upload your existing public key. Follow the on-screen instructions.

  5. Review remaining config options like proxy usage, NTP, etc.

MAAS can now manage and provision nodes.

Setting up LXD

For this tutorial, we’ll use LXD containers, alongside any physical servers you may choose to enlist:

  1. Install the LXD snap:

    sudo snap install lxd
  2. Initialize the LXD configuration:

    sudo lxd init

    Choose appropriate options for networking, storage pools, etc.

  3. Disable LXD’s built-in DHCP server:

    lxc network set lxdbr0 ipv4.dhcp=false 

Configuring Networking and DHCP

Finally, you’ll need to configure DHCP on the subnet that bridges the LXD instance:

  1. Identify the LXD bridge IP address:

    ip addr show lxdbr0
  2. In MAAS, go to Subnets and identify the VLAN for that subnet.

  3. Select the VLAN and configure DHCP with the bridge IP as the gateway.

MAAS now provides networking and DHCP for provisioning, putting your hardware resources under its watchful eye. In the following sections, we’ll explore advanced topics, helping you maximize this powerful tool for hardware management. Stay tuned to continue your MAAS journey to the next level.

Bootstrapping a virtual machine

With MAAS installed and configured, you now have the foundation for streamlined hardware management – but we’ve only just scratched the surface of MAAS’s capabilities. Now it’s time to take things to the next level by bootstrapping your MAAS environment.

Bootstrapping is the process of adding and commissioning machines, so that MAAS has something to manage. By bootstrapping, you empower MAAS to take control of your infrastructure and begin managing nodes.

Let’s walk through the bootstrapping process together. We’ll create a couple of LXD test machines to see MAAS in action. You’ll learn how to use the MAAS UI to:

  • Create a VM host and some LXD virtual machines
  • Commission at least one virtual machine
  • Acquire and deploy these VMs
  • Debug issues and customize the bootstrapping process

With these key skills under your belt, you’ll gain hands-on experience bringing machines under MAAS’s control. The bootstrapping journey marks a major milestone, equipping you with the knowledge to automate node deployment at scale.
With MAAS installed and configured, you’ve laid the foundation for streamlined hardware management. Now, let’s bootstrap your MAAS environment, empowering it to manage your infrastructure. In this process, we’ll:

  • Create LXD virtual machines
  • Commission at least one virtual machine
  • Acquire and deploy these VMs
  • Debug issues and customize bootstrapping

These skills will enable you to automate node deployment at scale, marking a significant milestone in your MAAS journey.

Create a VM host

You can use physical or virtual machines with MAAS. Since there are so many variations of physical hardware – and potentially a lot of configuration steps – we’ll simplify this exercise by using LXD as a VM host.

To create a LXD VM host (with a MAAS-generated certificate):

  1. Select KVM > LXD.

  2. Select Add KVM.

  3. Enter a Name for the KVM host.

  4. Optionally, select a non-default Zone.

  5. Optionally, select a non-default Resource pool.

  6. Enter the LXD address as the gateway address of the bridge for that LXD instance. For example, if lxdbr0 has address, the default gateway address is

  7. Select Generate new certificate.

  8. Select Next.

  9. Select Add trust to LXD via command line.

  10. Copy the bash command and certificate from the text box.

  11. In a terminal, paste the copied command and make sure that it runs.

  12. Select Check authentication. You’ll switch screens; if all goes well, you’ll see Connected with a green check-mark.

  13. Select Add new project or Select existing project. Be aware that if you select an existing project, any VMs already in that project will begin to commission.

  14. Select Next. You will drop out to a dashboard for the VM host.

You can then add virtual machines to this new VM host as desired.

Add a LXD virtual machine

MAAS automatically commissions newly-added machines. “Commissioning” just means that MAAS boots the machine with a special, ephemeral (in-RAM) version of Ubuntu, and then uses that version to learn everything it can about the hardware. This smooths the deployment process later.

To add a virtual machine from the MAAS UI:

  1. Select KVM > LXD.

  2. Select the desired VM host by clicking on its name.

  3. Select Add VM.

  4. Optionally enter the VM name.

  5. Select Use any available core(s) or Pin VM to specific core(s), as desired. Enter specific core identities as appropriate.

  6. Enter the RAM desired.

  7. Select Show advanced if you want to edit the Domain, Zone, Resource pool, or Architecture. Make those changes as desired.

  8. Optionally Define interfaces.

  9. Optionally Add disks.

  10. Select Compose machine to create the virtual machine.

You can switch from here to the Machine list to watch the commissioning process in action.

Acquiring a “Ready” machine

Acquisition – also called allocation by a quirk of terminology – claims the machine for your use. Once you’ve acquired it, nobody else can control it until you release it:

  1. Select a machine which is in the “Ready” state.

  2. Drop down the Take action menu.

  3. Select Allocate and confirm your choice on the following screen.

MAAS will allocate the selected machine for your exclusive use. You can now find it in the list of “Allocated” machines, under your ownership.

Deploying your newly acquired machine

Deployment is the pivotal moment where your newly-acquired machine becomes useful. Later on, you’ll learn how to use cloud-init to deploy specific workloads; for now, we’ll just get it up and running, and then log into it with SSH to examine the results.

To deploy directly from MAAS,

  1. Select an allocated machine and choose Deploy.

  2. On the follow-on options screen, don’t worry about deviating from the default OS, release, and kernel, at least not for now.

  3. When you’re ready, press Deploy… to get the machine up and running.

While deploying, the status will change several times, as MAAS steps through the process. Once finished, the status settles on the name of the OS (e.g. ‘Ubuntu 18.04 LTS’).

Admiring your handiwork

As long as you’ve added your SSH key to MAAS, you can connect to the newly-deployed machine. SSH to the machine’s IP with username ubuntu; there’s no password, since you’re using your SSH key to login. Explore the machine you just fielded. You can type sudo -i for root access.

For further study

In this tutorial, we’ve effectively transformed a blank canvas into a fully operational server, showcasing the way MAAS automates and streamlines server provisioning. There’s a lot more to learn:

  • If you’re interested in theory, consult the reading list in the explanation section.
  • If you want to get your hands dirty now, you can always dive into the how-to guides, which follow the typical MAAS workflow.
  • If there’s some particular machine type you’re interested in deploying, or you want more detail on scripting MAAS operations, consult the reference section.

Hopefully, this short walk-through gave you some confidence to explore further.

Last updated 6 days ago.