我参考了以下链接尝试安装和测试 MaaS:

https://docs.maas.io/2.1/en/installconfig-lxd-install

在文档的 profile 编辑部分:

  1. 执行 lxc profile edit maas

  2. 将 config 后的 {} 替换为如下内容(不包括 config:):

    1
    2
    3
    4
    5
    6
    
    config:
      raw.lxc: |-
        lxc.cgroup.devices.allow = c 10:237 rwm
        lxc.apparmor.profile = unconfined
        lxc.cgroup.devices.allow = b 7:* rwm    
      security.privileged: "true"
    
  3. 在 launch 步骤遇到如下报错:

    1
    2
    3
    
    $ lxc launch -p maas ubuntu:16.04 xenial-maas
    Creating xenial-maas
    Error: Failed container creation: Failed to load raw.lxc
    

这是因为我用的是 LXD 3.0,上述配置键已经过时。 根据这个评论,lxd 2.1 之后 lxc.aa_profile 改成了 lxc.apparmor.profile

所以解决方法如下:

  1. 再次执行 lxc profile edit maas

  2. lxc.aa_profile 替换为 lxc.apparmor.profile

    1
    2
    3
    4
    5
    6
    
    config:
      raw.lxc: |-
        lxc.cgroup.devices.allow = c 10:237 rwm
        lxc.apparmor.profile = unconfined
        lxc.cgroup.devices.allow = b 7:* rwm    
      security.privileged: "true"
    
  3. 重新运行 launch 命令

    1
    2
    3
    
    $ lxc launch -p maas ubuntu:16.04 xenial-maas
    Creating xenial-maas
    Starting xenial-maas