Concurrent cloning from LXC template using terraform provider

perfust

New Member
Dec 6, 2024
5
0
1
Vienna
Hi all,

I am trying to clone multiple instance of one of my LXC templates using Terraform (Telmate Provider) (as I am always doing with VMs) but with the containers, I am getting this lock issue as PVE is not capable to clone multiple containers from the same template at once. It throws the error as soon as my counter is more than one, and I would need 15 for my use-case. This is the first time I am trying to use the counter with LXCs but it doesn't seem reasonable that this feature wouldn't be provided. I am sure that users don't create 50 LCXs one by one by hand or by shell commands?! Or do they?

I have tried multiple different LXC templates, but they all seem to have the same issue. Linked cloning/Full cloning also didn't make any difference.

Error Output:
Code:
Error: error cloning LXC container: 500 CT is locked (disk), error status:  (params: {"full":false,"hostname":"lxcdockerdev-1","newid":1301,"node":"proxvm13","target":"proxvm13","vmid":"8121"})
│
│   with module.dockerdev-[1].proxmox_lxc.lxc,
│   on modules/lxc/main.tf line 1, in resource "proxmox_lxc" "lxc":
│    1: resource "proxmox_lxc" "lxc" {

I am happy to hear any thought/inputs/experiences from the rich community.

Thank You very much in advance. Have a great weekend.
 
Last edited:
I'm getting the same issue via ansible when cloning multiple over the API.

failed: [localhost] (item={'id': 207, 'ip': '10.0.2.107'}) => {"ansible_loop_var": "container", "cache_control": "max-age=0", "changed": false, "connection": "close", "container": {"id": 207, "ip": "10.0.2.107"}, "content_length": "13", "content_type": "application/json;charset=UTF-8", "date": "Wed, 12 Feb 2025 21:29:52 GMT", "elapsed": 0, "expires": "Wed, 12 Feb 2025 21:29:52 GMT", "json": {"data": null}, "msg": "Status code was 500 and not [200]: HTTP Error 500: CT is locked (disk)", "pragma": "no-cache", "redirected": false, "server": "pve-api-daemon/3.0", "status": 500, "url": "https://127.0.0.1:8006/api2/json/nodes/pve/lxc/110/clone"}
 
After reading I just do 50 clones of rocky9.4 by 2 shell loops on nfs shared from lxc and all are able to work fine, I don't start them all as you could hopefully understand. Don't know why terraform or any other super-duper-cloud tools are needed therefor ... but to each it's own tool ... :)
1739402398300.png
 
Last edited:
@waltar The thing is that shell loops create the containers one by one - and that's fine but takes long and it basically kills the point of automation/IaC. I can also create n LXCs and VMs without using parallelism. I don't want to give a lecture on advantages of using TF or any IaC for that matter, You can/should look that up yourself. At the end of the day and after a long research: Proxmox still doesn't support concurrent cloning of LXC templates and there is no way around it. Parallel=1 and that's that.
 
It just take seconds for a clone and you just wanted 15 ... so what want you to be in parallel be faster ?!? We don't need other tools as our shells, that's it.