I’ve written a profile for my LXD server that allows me to simply spin up a container and have it pre provisioned with .NET 6 SDK and a couple of build tools, via the use of the profile option EG:
This all works beautifully, in fact it works much better than Ansible which is great.
However there is one thing that I’ve NOT been able to work out, and that’s how to dynamically change parts of the profile.
If you look on my GitHub gist for example, you’ll see that at line 24 I add a user called shawty, with full passwordless sudo and rsa key login.
However, I’d like to change this name (Ultimately these containers will be generated from a web interface by a development team for running experimental .NET code).
My research has gotten me nowhere with figuring out if this is possible.
I would ideally love to be able to do something like:
You are dynamically generating the cloud init, and injecting the vars when you “cat” the YML into the profile right?
Problem is, I’m not doing that.
I have the profile already added to LXD, and so am just using the -p parameter with lxc launch to activate it.
I was hoping I could just add the var substitution’s in the profile once it’s added to LXD, then LXD would just put the correct values in itself at launch time, is this possible?
@cemzafer yep, I see that, but the data I’m wanting to populate is not “cloud-init” data, it’s actual profile options that are outside the cloud-init section.
I probably could perform the operations I wanted by abusing cloud-init, and I may have to do that eventually.
Either that, or create the profile for LXD dynamically in a not too dissimilar way, apply it to a launch, then delete that profile afterwards.
Still would prefer to not have to resort to such hammer & walnut tactics though just to change a couple of tiny bits, would have absolutely hoped that cloud-init could have had some var substitution of some kind built into it.
Right now I’m toying with the idea of using the C# LXD connector library I’ve gotten from NuGet, and using that instead of trying to call out to the console and lot’s of behind the scenes shell scripts.