Passing arbitrary options to distrobuilder

Hello,

I’m interested in the best way to pass arbitrary options to distrobuilder from the CLI. I’ll show what I mean by an example. This is what I’m currently doing to mount a directory passed as a CLI argument in the container.

The command:

distrobuilder build-lxc $distro.yaml $distro --options image.description=$datadir

The relevant section of the config file:

targets:
  lxc:
    config:
    - type: all
      content: |-
        lxc.arch = {{ image.architecture_personality }}
        lxc.mount.entry = {{ image.description }} home/user/export none bind,create=dir

Then when I start the image with LXC, the directory passed in image.description is mounted as /home/user/export.

Now I realize this is not ideal. The reason I do it this way is because distrobuilder doesn’t let me pick any name in –options, I have to pick one of the existing names and abuse it. The other alternative would have been to wrap it in a script and generate a new YAML file each time, which I think isn’t any better, but may be necessary if I have to pass more arguments.

My questions:

  • Is what I’m doing reasonable? I don’t mean using image.description, that’s clearly madness, I mean the goal of parameterizing the image this way.
  • Is there a better way?

We could add a user.XYZ set of keys similar to what we have everywhere in Incus.
So you could pass --options user.foo=bar and then can use {{ user.foo }} in templates.

That would be awesome.

Feel free to file a feature request at Sign in to GitHub · GitHub