Using MAAS with Juju

MAAS treats physical servers (or KVM guests) as a public cloud treats cloud instances.

Note: The Juju 2.x series is compatible with both the 1.x and 2.x series of MAAS.

Adding a MAAS cloud

Use the interactive add-cloud command to add your MAAS cloud to Juju's list of clouds. You will need to supply a name you wish to call your cloud and the unique MAAS API endpoint.

For the manual method of adding a MAAS cloud, see below section Manually adding MAAS clouds.

juju add-cloud

Example user session:

Cloud Types
  maas
  manual
  openstack
  oracle
  vsphere

Select cloud type: maas

Enter a name for your maas cloud: maas-cloud

Enter the API endpoint url: http://10.55.60.29:5240/MAAS

Cloud "maas-cloud" successfully added
You may bootstrap with 'juju bootstrap maas-cloud'

We've called the new cloud 'maas-cloud' and used an endpoint of 'http://10.55.60.29:5240/MAAS'.

Now confirm the successful addition of the cloud:

juju clouds

Here is a partial output:

Cloud        Regions  Default          Type        Description
.
.
.
maas-cloud         0                   maas        Metal As A Service

Manually adding MAAS clouds

This example covers manually adding a MAAS cloud to Juju (see Adding clouds manually for background information). It also demonstrates how multiple clouds of the same type can be defined and added.

The manual method necessitates the use of a YAML-formatted configuration file. Here is an example:

clouds:
   devmaas:
      type: maas
      auth-types: [oauth1]
      endpoint: http://devmaas/MAAS
   testmaas:
      type: maas
      auth-types: [oauth1]
      endpoint: http://172.18.42.10/MAAS
   prodmaas:
      type: maas
      auth-types: [oauth1]
      endpoint: http://prodmaas/MAAS

This defines three MAAS clouds and refers to them by their respective region controllers.

To add clouds 'devmaas' and 'prodmaas', assuming the configuration file is maas-clouds.yaml in the current directory, we would run:

juju add-cloud devmaas maas-clouds.yaml
juju add-cloud prodmaas maas-clouds.yaml

Adding credentials

The Credentials page offers a full treatment of credential management.

Use the interactive add-credential command to add your credentials to the new cloud:

juju add-credential maas-cloud

Example user session:

Enter credential name: maas-cloud-creds

Using auth-type "oauth1".

Enter maas-oauth:

Credentials added for cloud maas-cloud.

We've called the new credential 'maas-cloud-creds'. When prompted for 'maas-oauth', you should paste your MAAS API key.

Note: The API key will not be echoed back to the screen.

Typically you will have a MAAS user of your own. The MAAS API key can be found on your user preferences page in the MAAS web UI, or by using the MAAS CLI, providing you have sudo access:

sudo maas-region apikey --username=$PROFILE

Where $PROFILE is to be replaced by the MAAS username.

Creating a controller

You are now ready to create a Juju controller for cloud 'maas-cloud':

juju bootstrap maas-cloud maas-cloud-controller

Above, the name given to the new controller is 'maas-cloud-controller'. MAAS will allocate a node from its pool to run the controller on.

For a detailed explanation and examples of the bootstrap command see the Creating a controller page.

Next steps

A controller is created with two models - the 'controller' model, which should be reserved for Juju's internal operations, and a model named 'default', which can be used for deploying user workloads.

See these pages for ideas on what to do next:

© 2018 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.