How to Set Hostname and Subnet on MAAS

Juju is able to bootstrap on MAAS and automatically create the KVM VM but I can’t figure out how to set the hostname or the subnet that the VM should be created on. It appears the subnet directive isn’t supported on MAAS or I’ve got a typo. Here is what I’ve tried.

juju bootstrap \
    --bootstrap-constraints "mem=4G cores=2 root-disk=50G" \
    --to cloud1.maas \
    --to subnet=10.0.3.0/24 \
    maas-cloud \
    juju-controller-1
1 Like

Sorry to hear that you’re getting stuck.

Deploying to cloud1.maas

It looks like --to cloud1.maas should be the region parameter to the cloud.

juju bootstrap \
    ...
    maas-cloud/cloud1 \
    ...

Use juju regions maas-cloud to confirm that cloud1.maas is mapped to cloud1.

Subnet management

Network management occurs via “spaces”. If you create a network space within your MAAS console, you should be able to run juju reload-spaces to make Juju aware of it.

Then, you can add the space as a constraint.

juju bootstrap \
  --bootstrap-constraints "mem=4G cores=2 root-disk=50G space=<space>" \
  ...

Let me know if I’ve misunderstood anything. Happy to provide more help!

According to Juju there isn’t a constraint called space it’s called spaces but when I try to create a controller using that option I just get an error.

I’ve run juju reload-spaces but it just complains about there not being a controller.

administrator@cloudmgr1:~$ juju reload-spaces
ERROR No selected controller.

Please use "juju switch" to select a controller.

Here is my maas space.

"id": 3,
        "name": "vm",
        "resource_uri": "/MAAS/api/2.0/spaces/3/",
        "vlans": [
            {
                "vid": 13,
                "mtu": 1500,
                "dhcp_on": true,
                "external_dhcp": null,
                "relay_vlan": null,
                "space": "vm",
                "id": 5006,
                "name": "vm-vlan",
                "secondary_rack": null,
                "fabric_id": 0,
                "fabric": "10gb-fabric",
                "primary_rack": "tdcbdy",
                "resource_uri": "/MAAS/api/2.0/vlans/5006/"
            }
        ]

And my bootstrap command

juju bootstrap --debug \
    --bootstrap-constraints "mem=4G cores=2 root-disk=50G spaces=vm" \
    --to cloud1.dev.brocktec.com \
    maas-cloud \
    juju-controller-1

And the exception I get.

15:12:34 ERROR juju.cmd.juju.commands bootstrap.go:697 failed to bootstrap model: cannot start bootstrap instance: failed to acquire node: allocation constraints response schema check failed: constraints_by_type.interfaces.0: expected list, got nothing

I think we’re getting mixed on what I’m trying to do. I’m trying to bootstrap a juju controller via a maas pod on a bare metal kvm installation and I need to make the Juju controller vm get created under a specific subnet.

Looking at the documentation more it looks like I’ll just have to create the controllers vm manually and then I can pick the subnet for all future Juju created vms.

This looks a lot like a bug in Juju. We should at least have a better error message.

I think Juju isn’t expecting a space for bootstrap. According to the docs it supports MAAS spaces.