MAAS snap experience

In the pursuit of making it easier to consume MAAS and deliver a production ready MAAS in a few simple commands the MAAS project is switching from debs to snaps (snapcraft.io). Currently building all the debs for MAAS outputs 12 different deb packages and `apt install maas` installs a total of 164 new packages on a clean Xenial cloud image.

I wanted to get this down to just one snap with all of the requirements bundled in that one snap. This was a challenge as the 12 different deb packages were created in such a way to allow different operating modes.

DEB modes:
  • `apt install maas` - Fully running MAAS with Postgres, regiond, and rackd.
  • `apt install maas-region-api` - MAAS regiond with external database.
  • `apt install maas-rack-controller` - MAAS rackd connected to remote region.
  • `apt install maas-region-api maas-rack-controller - MAAS regiond with external database and rackd.
To enable this I implemented a way of changing the operating mode of the new MAAS snap. This allows a user to easily configure the operation mode of the controller in the MAAS deployment.

Initial snap modes:
  • all - Fully running MAAS with Postgres, regiond and rackd.
  • region - MAAS regiond with external database.
  • rack - MAAS rackd connected to remote region.
  • region+rack - MAAS regiond with external database and rackd.

Initially when the snap was created it always started out in the ‘all’ mode. Which meant a Postgres database would be created and the MAAS database migrations would be performed. This took quite a while to complete and was a lot of computation and disk space for a controller that might just be a region controller (external database) or a rack controller.

To prevent the need to create a database on every MAAS snap installation I added a new mode, the ‘none’ mode. ‘none’ mode is now the default mode upon MAAS snap installation. The ‘none’ mode has no MAAS services running and is completely unconfigured.

The ‘none’ mode did cause an issue of how does a user get from ‘none’ to an actual operating mode. Enter the new ‘maas init’ command. The ‘maas init’ command walks a user through the process of configuring the operating mode of the snap.

$ sudo snap install maas --devmode
$ sudo maas init
Mode (all/region+rack/region/rack/none) [default=all]? all
MAAS URL [default=http://192.168.1.1:5240/MAAS]: http://192.168.122.1:5240/MAAS
Create first admin account:
Username: admin
Password:
Again:
Email: admin@localhost
Import SSH keys [] (lp:user-id or gh:user-id): blake-rouse
SSH import protocol was not entered.  Using Launchpad protocol (default).

The ‘maas init’ command can be used to also change the operation mode of the snap, it’s not just one time use. It is also possible to provide options to the ‘maas init’ command and only the unanswered questions will be asked.

$ sudo maas init --mode all
MAAS URL [default=http://192.168.1.1:5240/MAAS]: http://192.168.122.1:5240/MAAS
Create first admin account:
Username: admin
Password:
Again:
Email: admin@localhost
Import SSH keys [] (lp:user-id or gh:user-id): blake-rouse
SSH import protocol was not entered.  Using Launchpad protocol (default).

When you need to view the current configuration of the MAAS snap the ‘maas config’ command is used. It also allows changing the current configuration of the snap without having to walk through the whole process again like ‘maas init’ does.

$ sudo maas config
Mode: all
Settings:
maas_url=http://192.168.122.1:5240/MAAS

Change from ‘all’ mode to ‘rack’ mode. Switching out of ‘all’ mode always requires the `--force` parameter, because it causes the database to be deleted. Not providing the `--force` parameter will cause an error and prevent you from switching.

$ sudo maas config --mode rack --maas-url http://192.168.122.1:5240/MAAS \
--rpc-secret 67aecd8acd74dc1a933cfd25d7cc75cc --force
$ sudo maas config
Mode: rack
Settings:
maas_url=http://192.168.122.1:5240/MAAS
rpc_secret=67aecd8acd74dc1a933cfd25d7cc75cc

A MAAS controller runs many services including DNS (bind9), DHCP (isc-dhcp), NTP (ntpd), proxy (Squid), iSCSI (tgtd), and MAAS’s own services. Depending on the mode of the snap different services will be running. To check what services are running in the current mode and the status of those services the `maas status` command has been added.

$ sudo maas config --mode all --maas-url http://192.168.122.1:5240/MAAS
$ sudo maas status
bind9                            RUNNING   pid 19720, uptime 1:21:04
dhcpd                            STOPPED   Not started
dhcpd6                           STOPPED   Not started
ntp                              RUNNING   pid 20764, uptime 1:19:59
postgresql                       RUNNING   pid 19721, uptime 1:21:04
proxy                            RUNNING   pid 20498, uptime 1:20:16
rackd                            RUNNING   pid 19719, uptime 1:21:04
regiond:regiond-0                RUNNING   pid 19714, uptime 1:21:04
regiond:regiond-1                RUNNING   pid 19713, uptime 1:21:04
regiond:regiond-2                RUNNING   pid 19718, uptime 1:21:04
regiond:regiond-3                RUNNING   pid 19712, uptime 1:21:04
tgt                              RUNNING   pid 19711, uptime 1:21:04

Summary of commands that manipulate the MAAS snap and provide information.
  • `maas init` - Initialize controller.
  • `maas config` - View or change controller configuration.
  • `maas status` - Status of controller services.

That's all folks!

Comments