I have been meaning to start using LXD (and now Incus) for a while, and had a use case today. Here’s the journey I took:
- I need a clean system running Docker for creating example documentation. Looks like I can create an LXC container for this: How to run Docker inside LXD containers | Ubuntu
- Since I haven’t used LXD for anything yet, let’s install
incus on an Arch Linux server I have.
- In my Ansible playbooks, I’ll update
- I installed Incus but forgot to uninstall LXD, so some things went to one and others to the other. Uninstall
- For some reason the Incus network I created exists in
incus network ls but can’t be referenced or
incus network rm’d or
incus network inspect’d (404 from the API.) I’ll just create a new one for now.
lxd_container gives a 404 Not Found error for the endpoint
I suspect that this error is due to the rename to “instances” with containers and VMs being sub-types. Unfortunately, I need to get work done, so I decided to switch back to LXD in the meantime. It turns out this is not tenable either as the image server has restricted access to my distro of choice (Arch Linux): Important notice for LXD users (image server)
Is there an Ansible plugin that is suitable for use with Incus? Is there a reason not to leave the
/1.0/containers endpoint for backwards compatibility? How are users expected to work around this issue?
Thanks in advance.
Yeah, that API endpoint is incorrect even for current LXD (though still functional), it should be changed to
/1.0/instances. You should be able to do that locally pretty easily or ask the Ansible maintainer to sort it out.
I’ve never actually used that particular Ansible plugin, I prefer the idea of using Terraform to create my instances, storage volumes, … and then using the Ansible Incus connection plugin to deploy stuff into those instances, keeping the two things separate if that makes sense.
That API has been completely untested for years on the LXD side, so it felt like keeping it around would just make thing worse. It’s unfortunate that some tools are breaking as a result of it, but it’s also been convenient to find which tools are still using the deprecated APIs and get them updated as even for LXD, they’re not using something that’s really supported these days.
Thanks for the response! I’m working on getting Terraform setup. Unfortunately, this means adding yet another tool to my deployment environment.
It looks like the Terraform module doesn’t support SSH authentication for communicating with the Unix socket, so in addition to the operational complexity of supporting yet another auth flow, I am also increasing surface area by opening another port on this box. (The latter bit is mitigated by the fact that I have a private, encrypted overlay network I can bind to…)
I understand the reasoning behind using Terraform for creating infrastructure, and the provisioning with Ansible - however for a simple topology like I have (one or two “pet” servers running Incus - not a bunch of “cattle” in AWS), it would’ve been nice to just keep it all in Ansible.
Regardless - thanks for your work on Incus and keeping all the hard work that went into LXD firmly in the community’s hands!
If you have some familiarity with Python, I’d recommend looking at that lxd_container Ansible module, the change to make it use the instance API instead of container should be rather trivial.
Looks like just changing that to always be
self.api_endpoint = '/1.0/instances' should do the trick.
Hey, thanks again for the reply, and the pointer.
Indeed, overriding the instance variable and setting it to
/1.0/instances seems to work to create a container. The only issue now is that I believe this only support containers since the endpoint serves both containers and VMs but there is no explicit “instance type” parameter being sent.
I found this doc, but it doesn’t clear define the endpoints you can call or their parameters: incus/doc/rest-api.md at main · lxc/incus · GitHub
Can you offer a pointer as to what param the endpoint accepts to define the instance type?
edit: I found these docs, but I’m still a bit confused: Main API specification - Incus documentation - is it determined by the source?
Once I have this working, I’ll see if I can post a PR to fix the issue I created here: Support Incus in lxd_container module · Issue #7853 · ansible-collections/community.general · GitHub
Thanks for your help!
That’d be great!
You actually want to set
"type": "container" or
instance_type is rather confusingly something entirely unrelated (it’s about using AWS/GCP/Azure instance type names to set resource limits).