[SOLVED] API-created VM template doesn't support linked clones

fadeway

New Member
Oct 30, 2024
9
1
3
I am trying to upload a disk image to proxmox, make a template VM from it via the API, then clone the template and inject some customization via cloud-init. Sadly if I set the `template: true` option, the resulting template is broken and no longer supports linked clones. Specifically I am getting variations of the error:

"fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to clone vm cloud-init-test from vmid 999900=500 Internal Server Error: Linked clone feature is not supported for drive 'sata0'", "vmid": 999900}"

Linked clones do work if I omit `template: true` option and then do the template conversion in the proxmox GUI. Perhaps the API implementation is failing to convert the disks properly?

Here is the Ansible task I am using to make the template:


Code:
  - name: Create the template VM
      ansible.builtin.uri:
        url: "https://{{ api_host }}:8006/api2/json/nodes/{{ node }}/qemu"
        method: POST
        headers:
          Authorization: "{{ proxmox_auth_cookie }}"
        body:
          vmid: "{{ vm_id }}"
          name: "{{ vm_name }}"
          storage: "{{ vm_storage }}"
          cores: 6
          cpu: 'x86-64-v2-AES'
          memory: 16384
          bios: 'ovmf'
          sata0: "{{ vm_storage }}:0,import-from={{ upload_storage }}:{{ remote_image_dir }}/virtual-wt-1.vmdk"
          ide2: "{{ vm_storage }}:cloudinit"
          efidisk0: "{{ vm_storage }}:1" # 0 to allow import-from
          net0: "vmxnet3,bridge=Test,link_down=1"
          net1: "vmxnet3,bridge=Test,link_down=1"
          net2: "vmxnet3,bridge=Test,link_down=1"
          net3: "vmxnet3,bridge=Test,link_down=1"
          net4: "vmxnet3,bridge=Test,link_down=1"
          net5: "vmxnet3,bridge=vmbr31"
          net6: "e1000e,bridge=Test"
          net7: "vmxnet3,bridge=Test,link_down=1"
          pool: 'EimfsTest-Deployments'
          #template: true   <- Buggy
        body_format: json
        status_code: 200

I guess the workaround would be to deploy non-template as in the code above, figure out the task ID, wait for the deploy to finish, then do a separate API call to convert to template?
 
Last edited:
Thanks dcsapak, I will extend my logic to do the conversion separately with that call.
 
I can confirm that posting a non-template VM and then converting it to a template in a separate call works. I can create linked clones from the resulting template. Whether my original playbook which was doing it in one step exposes a bug in the API, I leave to the proxmox developers to decide.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!