How to autoprovision additional disks using profiles or Ansible in a cluster?

Good morning Ahmad

I didn’t get LXD to do it automatically, but it was fine via Ansible and using variables in the inventory for instance groups. I cheated and used:

  • the shell module to issue lxc storage volume create for standard filesystem and block types
  • the zfs module to create the separate custom dataset hierarchy as not to interfere with LXD’s, and zvols for block types where service that was going to use it didn’t like ZFS, e.g. Docker

but I suppose we could use the API as well. The thing with this method is that we need to know which host to deploy the storage and instance to beforehand, which for us is not an issue so another inventory variable. Or I suppose you could get it auto-allocated (init only) and then track down which host it’s on and store in a variable, provision and attach additional storage, then start the instance.

LXD 5.11 now has this which makes this easier for block volume requirements:
LXD 5.11 has been released
whereas before there were a few extra steps to get into the block volume and align permissions before attaching to the instance.

1 Like