How to modify the networking setup of a deployed node in MAAS

Case1: you need to add a subnet/space in a deployed node in MAAS, and make Juju aware of it in order to deploy services on LXD containers (which require spaces). CASE2: you need to modify the MAC addresses of the network interfaces of a deployed node following a replacement of the network board

Instructions

  1. Log in to the MAAS node

  2. Log in to the database (in our case MAAS is in HA managed by Stolon):

    # psql -U maas -h localhost -p 25432 -d maasdb
    

N.B:

maas user password is written in /etc/maas/regiond.conf

Some useful commands:

-  \l: show databases;
- \dt: show tables;
- \d: describe table
- select example: select hostname, status from maasserver_node where hostname='ct1-r4-gpu01';

The nodes are recorded in the table maasserver_node.

  1. Update node, set status=4 (ready):

    update maasserver_node set status=4 where hostname='node_name';
    

The node becomes ready and we can modify its configuration from the GUI!

  1. Update node, set status=6 (deployed):

    update maasserver_node set status=6 where hostname='node_name';
    

N.B. The administrator need to apply the actual configuration of the node: netplan configuration, netplan apply, possibly reboot of the existing LXD containers to make them aware of the changes…

N.B for case 2:

If the node NICs are configured in Bond it is possible to change the MAC address of the Bond interface from the GUI, selecting Bond -> Edit bond, select “Manual MAC address”. However, it is not possible to modify the MAC address of the physical interfaces. Use the MAAS CLI to modify them:

# get MACHINE_ID from GUI, use it to get the machine's data
maas maas interfaces read $MACHINE_ID > /tmp/interfaces_$MACHINE_ID.json

# Read IDs of the two 25Gb NICs
read NIC1 NIC2 <<< $( cat /tmp/interfaces_$MACHINE_ID.json  | jq '.[] | select(.link_speed==25000)  .id' | xargs echo )

# Update MAC Address of the two NICs
maas maas interface update $MACHINE_ID $NIC1 mac_address="xx:xx:xx:xx:xx"