Minimal MAAS Setup

How to run a LXD container-based MAAS lab using an Impish host

Host preparation

  • LXD >= 4.20

Networking

Create a network for the control plane (MAAS, DB and KVM host):

lxc network create net-lab --type=bridge \
    dns.domain=net-lab \
    ipv4.address=10.0.1.1/24 \
    ipv4.dhcp=true \
    ipv4.dhcp.ranges=10.0.1.16-10.0.1.31 \
    ipv4.nat=true \
    ipv6.address=none

Create an un-managed network for the VMs:

lxc network create net-test --type=bridge \
    ipv4.address=none \
    ipv4.dhcp=false

Allow remote access to the host LXD daemon

lxc config set core.https_address [::]:8443

Create projects for MAAS

lxc project create proj-maas -c features.images=false -c features.profiles=false
lxc project create proj-lab -c features.images=false -c features.profiles=false

Create a profile for MAAS

This will make easier to create MAAS containers later

lxc profile create prof-maas-lab
cat <<EOF | lxc profile edit prof-maas-lab
config:
    user.vendor-data: |
        #cloud-config
        packages:
        - jq
        runcmd:
        - cat /dev/zero | ssh-keygen -q -N ""
        ssh_authorized_keys:
        - $(cat ${HOME}/.ssh/id_rsa.pub | cut -d' ' -f1-2)
description: MAAS lab env
devices:
    eth0:
        type: nic
        name: eth0
        network: net-lab
    eth1:
        type: nic
        name: eth1
        network: net-test
EOF

Containers

Create service containers in the project proj-maas

lxc project switch proj-maas

DB

cat <<EOF | lxc launch ubuntu: lab-db
config:
    user.user-data: |
        #cloud-config
        packages:
        - postgresql
        runcmd:
        - cat /dev/zero | sudo -u ubuntu -- ssh-keygen -q -N ""
        ssh_authorized_keys:
        - $(cat ${HOME}/.ssh/id_rsa.pub | cut -d' ' -f1-2)
description: MAAS database
devices:
    eth0:
        type: nic
        name: eth0
        network: net-lab
EOF

# wait for container initialization
lxc exec lab-db -- cloud-init status --wait
lxc list

Login in the container and prepare the DB

$ ssh ubuntu@10.0.1.31
ubuntu@lab-db:~$

Configure the database

# enable remote access
echo "host sameuser all 10.0.1.0/24 md5" | sudo tee -a /etc/postgresql/12/main/pg_hba.conf
echo "listen_addresses ='*'" | sudo tee -a /etc/postgresql/12/main/postgresql.conf
sudo systemctl restart postgresql

sudo -u postgres bash

# create MAAS postgresql user and database
createuser maas -P
createdb -O maas maas

Create MAAS container

lxc launch ubuntu:focal maas-edge -p default -p prof-maas-lab

# wait for container initialization
lxc exec maas-edge -- cloud-init status --wait
lxc list

Login in the container before executing the remaining commands in this section

$ ssh ubuntu@10.0.1.19
ubuntu@maas-edge:~$

Configure the unmanaged network interface:

sudo tee /etc/netplan/99-net-test.yaml <<EOF
network:
    version: 2
    ethernets:
        eth1:
            addresses:
                - 10.0.2.1/24
EOF

sudo netplan apply

Install MAAS from the SnapStore

sudo snap install maas --channel=3.1/edge

Initialize MAAS controller, replace DBUSER and DBPASSWD appropriately.

sudo maas init region+rack --database-uri=postgres://DBUSER:DBPASSWD@lab-db/maas

sudo maas createadmin

Get your API key from MAAS UI and authenticate the CLI

maas login admin http://10.0.1.19:5240/MAAS API_KEY

Enable NAT

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Tasks done using the UI

  • Enable DHCP on net-test
  • Configure MAAS as network gateway
  • Add Host as a KVM