lost and found ( for me ? )

Ubuntu 16.04 : install MAAS within Ubuntu 16.04 LXD and manage virtual machines running in KVM with MAAS

Here are logs when setting up MAAS within LXD container and managing virtual machines running in KVM with MAAS.

Here is my environment.
I have single box.

LXD(maas)             nodes ( virtual machine within KVM)
---------------------------------------------------------------------------
Ubuntu host 16.04

Create an LXD profile for maas
hattori@ubuntu:~$ lxc profile copy default maas

Edit the LXD profile.
hattori@ubuntu:~$ lxc profile show maas
name: maas
config:
 raw.lxc: |-
   lxc.cgroup.devices.allow = c 10:237 rwm
   lxc.aa_profile = unconfined
   lxc.cgroup.devices.allow = b 7:* rwm
 security.privileged: "true"
description: ""
devices:
 eth0:
   name: eth0
   nictype: bridged
   parent: virbr4
   type: nic
 eth1:
   name: eth1
   nictype: bridged
   parent: virbr3
   type: nic

Edit the profile
hattori@ubuntu:~$ for i in `seq 0 7`; do lxc profile device add maas loop$i unix-block path=/dev/loop$i; done

hattori@ubuntu:~$ lxc profile show maas
name: maas
config:
 raw.lxc: |-
   lxc.cgroup.devices.allow = c 10:237 rwm
   lxc.aa_profile = unconfined
   lxc.cgroup.devices.allow = b 7:* rwm
 security.privileged: "true"
description: ""
devices:
 eth0:
   name: eth0
   nictype: bridged
   parent: virbr4
   type: nic
 eth1:
   name: eth1
   nictype: bridged
   parent: virbr3
   type: nic
 loop0:
   path: /dev/loop0
   type: unix-block
 loop1:
   path: /dev/loop1
   type: unix-block
 loop2:
   path: /dev/loop2
   type: unix-block
 loop3:
   path: /dev/loop3
   type: unix-block
 loop4:
   path: /dev/loop4
   type: unix-block
 loop5:
   path: /dev/loop5
   type: unix-block
 loop6:
   path: /dev/loop6
   type: unix-block
 loop7:
   path: /dev/loop7
   type: unix-block
hattori@ubuntu:~$

Launch an instance
hattori@ubuntu:~$ lxc launch -p maas ubuntu-xenial xenial-maas
hattori@ubuntu:~$ lxc exec xenial-maas bash

Install maas
root@xenial-maas:~# apt-cache search maas
root@xenial-maas:~# apt-add-repository -y ppa:maas/stable
root@xenial-maas:~# apt-get update
root@xenial-maas:~# apt install maas

Set up MAAS to access to GUI
root@xenial-maas:~# maas createadmin --username=admin
Password:
Again:
Email: a@a.com
root@xenial-maas:~#

Access to the GUI
http:// <maas ip>:5240/MAAS



--

To run maas-dhcpd, we need to configure dhcp configuration manually.

https://maas.ubuntu.com/docs2.0/maascli.html#

On the mass container.
root@xenial-maas:~# systemctl list-unit-files --type=service | grep maas-dhcp
maas-dhcpd.service                         enabled
maas-dhcpd6.service                        enabled

Maas-dhcpd is not running at the moment.
root@xenial-maas:~# systemctl status maas-dhcpd
● maas-dhcpd.service - MAAS instance of ISC DHCP server for IPv4
  Loaded: loaded (/lib/systemd/system/maas-dhcpd.service; enabled; vendor prese
  Active: inactive (dead)
Condition: start condition failed at Wed 2016-10-26 15:39:39 UTC; 25min ago
          ConditionPathExists=/var/lib/maas/dhcpd-interfaces was not met
    Docs: man:dhcpd(8)
root@xenial-maas:~#

Obtain a key.
root@xenial-maas:~# maas-region apikey --username=admin
EaxXNt2NZFvx34wTEF:VcBrSCxhMHsefzNUMN:URtfHuGWtbPLcXQzzCkH3sZeUZxTAdkv

Login
root@xenial-maas:~# maas login my-maas http://127.0.0.1/MAAS/api/2.0 EaxXNt2NZFvx34wTEF:VcBrSCxhMHsefzNUMN:URtfHuGWtbPLcXQzzCkH3sZeUZxTAdkv

You are now logged in to the MAAS server at
http://127.0.0.1/MAAS/api/2.0/ with the profile name 'my-maas'.

For help with the available commands, try:

 maas my-maas --help

root@xenial-maas:~#

2. Enable DHCP and DNS.

I performed that via MAAS GUI.

3. registre nodes.

I will manage virtual machine nodes with maas.

Create a virtual machine disk.
You need to specify preallocation=metadata so that MAAS can recognize a storage size of a VM.
# qemu-img create -o preallocation=metadata -f qcow2 m-node01.qcow2 5g

Create a virtual machine via virt-manager.
.

Add the disk you created with “qemu-img create”

Change boot order
1st : PXE boot
2nd : HDD

Start the VM and then stop the VM forcely.

Register the node via Maas GUI.

Check the MAC address of the VM
root@ubuntu:~# virsh dumpxml m-node02 | grep -i 'mac address'
     <mac address='52:54:00:c4:6a:7f'/>
root@ubuntu:~#



Install ubuntu 16.04 on that virtual machine.


I have registered two nodes.