Merge 'raw.lxc' configuration from profiles

Is there a possibility to merge certain keys, e.g. raw.lxc, when applying multiple profiles?

For example given two profiles

  raw.lxc: lxc.apparmor.profile = unconfined


  raw.lxc: lxc.cgroup.devices.allow = c 42:23 rw

Is there a way to add both profiles to a container, so that the resulting configuration would be:

  raw.lxc: |-
    lxc.apparmor.profile = unconfined
    lxc.cgroup.devices.allow = c 42:23 rw

Nope, LXD always overrides config keys wholesale, there is no merging possible between profiles and containers.

The raw.* keys would also be the hardest to do this with as LXD doesn’t know what makes a valid LXC config. Some keys can only be specified once in a LXC config, some can be specified multiple times but then act as multiple entries in a list, some others need to be reset to empty prior to being set again, …

An option in this case may be to just add a unix-char device with major=42 and minor=23 to your container, this will effectively cause LXD to do that lxc.cgroup.devices.allow and so get rid of that difference between your two container configs.