How to build MAAS images (snap/2.9/UI)
MAAS Image Builder is an alternative to Packer for creating MAAS images.
In order to use MAAS Image Builder, you must purchase Ubuntu Advantage for Infrastructure.
With the MAAS Image Builder, you can do five key operations:
- install MAAS Image Builder via a private Canonical PPA (which you can request)
- create custom CentOS images
- create custom RHEL images
- create Windows images
- create other kinds of custom images
You can customise most images as much or as little as you wish, then use them to commission machines with MAAS.
Install MAAS Image Builder
To get MAAS Image Builder, you must be subscribed to a private PPA provided by Canonical Support to those customers who have purchased Ubuntu Advantage for Infrastructure. Note that the steps below will fail if you have not purchased Ubuntu Advantage and been subscribed to the private PPA by your Canonical support rep.
Once subscribed, you need to obtain your credentials at this external link:
Also, you must add the repository with the
add-apt-repository command. Note: Be sure to substitute your unique URL in the command below:
$ sudo add-apt-repository \ “https://LaunchpadID:Password@private-ppa.launchpad.net/maas-image-builder-partners/stable/ubuntu"
Once you have added the private PPA, you can install the Image Builder like this:
$ sudo apt-get install maas-image-builder
All done? Great! Now you can build and customise images for MAAS machines, as shown in the sections below.
Create custom CentOS images
MAAS already provides the latest available CentOS 6, CentOS 7, and CentOS 8 for automatic download. If you need something else, though, MAAS Image Builder supports the ability to create various CentOS images.
Access to the Internet is required, since you will need to start with one of these three sites:
- http://mirror.centos.org - OS, updates, and extra repositories
- https://download.fedoraproject.org - EPEL
- https://copr-be.cloud.fedoraproject.org - Canonical maintained cloud-init repository
Creating images behind a proxy
MAAS Image Builder can create CentOS images behind a proxy – just set the ‘http_proxy’ environment variable to your particular proxy. Once deployed,
yum will use this MAAS-configured proxy.
Creating the images
maas-image-builder is designed to automate the process of generating the images for MAAS and
curtin. Here are some specific examples:
$ sudo maas-image-builder -o centos6-amd64-root-tgz --arch amd64 centos --edition 6 $ sudo maas-image-builder -o centos6-i386-root-tgz --arch i386 centos --edition 6 $ sudo maas-image-builder -o centos7-amd64-root-tgz --arch amd64 centos --edition 7
Customising CentOS images
Starting from MAAS Image Builder 1.0.4, customisation of CentOS images is now supported. You can provide a custom kickstart, in addition to the kickstart that MAAS Image Builder uses to create the images. You can customise your image like this:
$ sudo maas-image-builder -o centos7-amd64-root-tgz --arch amd64 centos --edition 7 --custom-kickstart ./custom.ks
Uploading the image into MAAS
Custom CentOS images can be uploaded to MAAS as shown in the command below. Do note that the name must start with ‘centos’ and must be one line:
maas admin boot-resources create name=centos/centos6-custom architecture=amd64/generic content@=./build-output/centos-amd64-root-tgz
You can use the MAAS WebUI to check that your custom CentOS image is valid and selectable for deployment.
Building RHEL images
Currently, MAAS only supports RHEL as a custom image. In future versions of MAAS, RHEL will be natively supported.
In order to create RHEL images, you will need access to these three sites:
- A RHEL DVD ISO - Contains all RHEL archives which are not available without a license
- https://download.fedoraproject.org - Access to the EPEL repository to install required deps
- https://copr-be.cloud.fedoraproject.org - Access to the Canonical maintained cloud-init copr repository
Creating images behind a proxy
MAAS image builder supports creating RHEL images behind a proxy. To use a proxy when building a RHEL image, just set the ‘http_proxy’ environment variable to your local proxy. Once deployed,
yum will use the MAAS-configured proxy.
Creating the images
To generate a usable RHEL image,
maas-image-builder automates image generation; these images can be used by MAAS and
$ sudo maas-image-builder -a amd64 -o rhel7-amd64-root-tgz rhel --rhel-iso blah.iso
Install into MAAS
The custom RHEL image can be uploaded to MAAS, but note that the name must start with ‘rhel’ and must be expressed as a single line, like this:
maas admin boot-resources create name=rhel/7 title="RedHat Enterprise Linux 7" architecture=amd64/generic content@=rhel7-amd64-root-tgz
Building Windows Images
Since Windows is a proprietary operating system, MAAS can’t download these images. You need to manually generate images to use with MAAS. On the upside, the end result will be much simpler, since there are CLI and WebUI tools to upload a Windows ISO – which helps automate the process.
Hyper-V 2012 R2
In this example, Windows Hyper-V 2012 R2 is used, but rest assured that multiple versions are supported. Download the Hyper-V 2012 R2 ISO from Microsoft, so it can be used in the image generation process. You can obtain the download at:
There are six other supported versions (for --windows-edition):
MAAS Image builder can automate the process of generating images for MAAS and
curtin. In this instance, though, you need Windows drivers for your specific hardware. You can obtain these windows drivers with the following command:
sudo maas-image-builder -o windows-win2012hvr2-amd64-root-dd windows \ --windows-iso ~/Downloads/2012hvr2.ISO \ --windows-edition win2012hvr2 [--windows-updates] \ [--windows-drivers <folder/>] [--windows-language en-US]
As an example, consider:
sudo maas-image-builder -o windows-win2012hvr2-amd64-root-dd windows \ --windows-iso win2012hvr2.iso --windows-edition win2012hvr2 \ --windows-updates --windows-drivers ~/Win2012hvr2_x64/DRIVERS/ --windows-language en-US
Please note that this will not install any Windows updates. In order to obtain an up-to-date image of Windows, be sure provide the
–windows-updates flag. This requires access to a bridged connection with a DHCP server, an interface that can be specified with
Also note that you may be required to have specific Windows drivers for this image to work in your hardware. Be sure you inject those drivers when installing them. Those drivers are the default
You can debug the Windows installation process by connecting to
localhost:5901 using a VNC client.
Install into MAAS
The generated images need to be placed into the correct directories so MAAS can deploy them onto a node:
maas admin boot-resources create name=windows/win2012hvr2 \ architecture=amd64/generic filetype=ddtgz \ content@=./build-output/windows-win2012hvr2-amd64-root-dd
Now, using the MAAS WebUI, a node can be selected to use Windows Hyper-V 2012 R2. This selection gets reset when a node is stopped, so make sure to set it before starting nodes. You can also set the default operating system (and release) in the settings menu, which removes the need to set it per-node.
Dealing with other custom images
To install other custom images, use the following command sequence:
maas <user> boot-resources create name=<custom-image-codename> title="Ubuntu Custom Image" \ architecture=amd64/generic content@=/location/of/custom/image/ubuntu-custom-root-tgz
As an example:
maas admin boot-resources create name=custom1 \ title=”Ubuntu Custom Image” architecture=amd64/generic \ content@=/home/ubuntu/ubuntu-custom-root-tgz