Build CentOS Image For MAAS

TurnToJPG -->

MAAS could only deploy Ubuntu in its official support, this artcle will introduce how to Build CentOS based images.


First you need a Ubuntu14.04 machine with kvm enabled.

$ sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade
$ sudo apt-get install build-essential

Get Build Scripts

Get the source code from the launchpad, and run following command for preparing the building environment.

$  bzr branch lp:maas-image-builder
$ cd maas-images-builder
$ make install-dependencies

For speed-up building, I use china mainland’s repository,
Replace the like following:

$ vim ./src/mib/builders/

$ vim ./contrib/centos/centos6/centos6-amd64.ks
repo --name="repo0" --baseurl=
repo --name="repo1" --baseurl=
repo --name="repo2" --baseurl=

Build Images

Install python-dev and begin to make:

# apt-get install python-dev
# make

Now begin to generate the image:

#./bin/maas-image-builder -o centos6-amd64-root-tgz centos --edition 6


After building the image is listed as:

# ls -l centos6-amd64-root-tgz 
-rw-r--r-- 1 root root 353086181 Apr 29 13:16 centos6-amd64-root-tgz

Import Images

First login into your own profile with following command:

$ maas login my-maas ntQBr8QTPgeTyfYuMq:xxxxxxxxxxxxxxxxxxxxxxxxx7HNspYLch4kc6RLs
$ maas my-maas boot-sources read

Above command will readout the boot-sources, now we need to import our newly-built images, import it via:

$ maas my-maas boot-resources create name=centos/centos6 architecture=amd64/generic content@=/home/Trusty/centos6-amd64-root-tgz


Use following commands:

maas@MassTestOnUbuntu1404:~$ ssh cloud-user@
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is a5:57:5b:d1:ac:c0:8f:67:32:43:d8:6f:17:67:65:cb.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
[cloud-user@CentOS ~]$ ls
[cloud-user@CentOS ~]$ cat /etc/issue
Kernel \r on an \m

[cloud-user@CentOS ~]$ uname -a
Linux CentOS 3.10.0-229.1.2.el7.x86_64 #1 SMP Fri Mar 27 03:04:26 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

From Now on,you could use CentOS 6 for deploying!!!!!!!!!!!!!!1

ENJOY IT!!!!!!!

Trouble Shooting

The version could not be speicified via –edition, everytime we got CentOS 7 based image , so we need to manually change the file:

 root@BuildMaasImage:~/Code/once# vim src/mib/builders/
    def populate_parser(self, parser):
        """Add parser options."""
            #'--edition', default='7',
            #help="CentOS edition to generate. (Default: 7)")
            '--edition', default='6',
            help="CentOS edition to generate. (Default: 6)")

Now re-generate the image again, we got CentOS 6.5 based images.
How to generate the CentOS 6.5/6.4/6.3 version? we always get the newest CentOS 6 images.