managing devices for lxc containers

Hi,

is there a way to add more than one device to a container from a variable?

I’d like to have something like this defined:

lxc_containers:

  • name: c1
    devices:
  • name: eth0
    type: nic
  • name: data
    type: disk

and then have a task like:

  • name: create containers
    lxd_container:
    name: “{{item.name}}”
    state: started

    devices: “{{item.devices}}”

    with_items: “{{lxd_containers}”"

right now this seems impossible as you have to spell out in the task each device. Am I misunderstanding the module? is there a way around it?

thanks,

Spike

That looks like it should work, {{item.devices}} should be expanded
before the module reads it, and that is already a list,

Though, looking at the code definition of the module, it seems wrong
and it takes a dictionary, not a list. Seem to need a 'dictionary of
device type with a list of devices'. Looks like the following should
work:

lxc_containers:
  - name: c1
    devices:
      eth0:
        name: eth0
        type: nic
      data:
        path: /data
        type: disk