Hi! Rank beginner here.
Trying to write a little script to reproducably do
I expected lxd to be easy to install and uninstall.
Not so!
I kept running into odd, broken situations, and areas where I needed
to know more than I expected about the underlying tools, and
had to do crazy things like add retry loops and delays
and even reboots!
Evidently lxd (not unlike other systems I’ve seen) is a bit of a leaky
abstraction.
My immediate suggestion would be to separate the part that does the set up of LXD and the tear-down.
It is a more generic task that of configuring LXD, so such a script would be useful elsewhere as well.
In addition, you can use a preseed file when you set up LXD and also a profile for the guiapps containers.
See https://blog.simos.info/a-closer-look-at-chrome-os-using-lxd-to-run-linux-gui-apps-project-crostini/ and specifically the link with the preseed content that they use for the Chromebooks.
In addition, when you set up ZFS or BTRFS for the storage backend (instead of dir) you get much faster container management. That would make it easy when you want to extend with some GUI program like VirtualBox clone.
I agree that a generic one would be useful, but I’m still trying to debug my special case one. I am currently using btrfs, and ran into rough edges there, too.
You didn’t mention your environment, Host OS, Container OS, SNAP LXD or repository LXD (and lxd --version) etc.
Also, as I’ve not had any real problems installing/uninstalling/reinstalling could you describe some of the “odd, broken situations” you encountered (if you remember).