How to merge profiles' user.vendor-data?

(Daniel Manrique) #1


Is there a way to "merge" two profiles' user.vendor-data? Here's a concrete use case.

I have one profile that sets an apt cache for my containers:

$ lxc profile show aptcache
  user.vendor-data: |
      proxy: ""
    apt_proxy: ""
description: set up apt caching via
devices: {}
name: aptcache

then I have another which creates a user:

$ lxc profile show roadmr
  user.vendor-data: |
      - name: roadmr
        groups: sudo
        shell: /bin/bash
        sudo: ['ALL=(ALL) NOPASSWD:ALL']
    # ensure users shell is installed
      - bash
description: roadmr
name: roadmr

however, those two can't obviously be combined:

lxc init -p default -p roadmr -p aptcache ubuntu:16.04 borked-container

In this case, only aptcache is applied and I don't have my nice precreated user :frowning:

Clearly I could just have a single user.vendor-data in another profile, but, his example is artificial to illustrate the situation; in practice, I don't always want apt caching in containers where I do want the user created, and viceversa. And even if creating "combined" user.vendor-data were acceptable, it quickly becomes unmanageable as the number of possible combinations grow. For instance, I have another profile which enables security.nesting and installs squashfuse via user.vendor-data, which I can't combine with the above two. For these three profiles, I'd need to create 4 different profiles to cover all combinations.

So my question is: Is there a way to have lxd more intelligently combine these user.vendor-data (or really any cloud-config)?

Thanks in advance!

(St├ęphane Graber) #2

Nope, to LXD those are just free-form text config keys. Whichever is applied last wins.

There is ongoing work to have cloud-init use the /dev/lxd/sock interface to get the LXD configuration for the container. With that, cloud-init could in theory grow support for any number of "user.vendor-data.*" keys, applying them in order.

(Daniel Manrique) #3

Thanks for replying! OK, I'll keep an eye out for those changes if they happen, and resign myself to merging my configs manually in the meantime.