community.general
community.general copied to clipboard
proxmox_kvm "Linked clone feature is not supported for drive" when creating template
Summary
Using community.general.proxmox_kvm to create VM, then converting to template, when cloning VM and using "linked clone", get error Linked clone feature is not supported for drive 'scsi0' (500).
This issue was previously reported and presumably fixed, or maybe not fixed, see: [https://github.com/ansible/ansible/issues/44950]
Unfortunately it seems the PR is no longer available to look at.
There is no workaround as using ansible.builtin.command: "qm template {{ item.id }}" instead, it results in qm returning a 25 error code, but running the same qm template 9001 command from the console works.
I have no idea why qm sometimes fails with error 25, see here, here, and here with no solution yet.
Issue Type
Bug Report
Component Name
proxmox_kvm
Ansible Version
$ ansible --version
ansible [core 2.15.2]
config file = None
configured module search path = ['/home/pieter/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
ansible collection location = /home/pieter/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/bin/python3)
jinja version = 3.0.1
libyaml = True
Community.general Version
$ ansible-galaxy collection list community.general
# /home/pieter/.ansible/collections/ansible_collections
Collection Version
----------------- -------
community.general 7.2.1
# /usr/local/lib/python3.9/dist-packages/ansible_collections
Collection Version
----------------- -------
community.general 7.2.0
Configuration
$ ansible-config dump --only-changed
CONFIG_FILE() = None
OS / Environment
Proxmox 7.4-16
Steps to Reproduce
---
# Create Cloud-Init VM templates
# https://pve.proxmox.com/wiki/Cloud-Init_Support
# TODO:
# Fix locked images: sudo qm destroy 9001 --destroy-unreferenced-disks 1 --skiplock 1
# https://forum.proxmox.com/threads/creating-cloud-images-using-ansible-fails-while-the-same-commands-work-in-the-shell.131571/
# https://stackoverflow.com/questions/76816367/creating-cloud-init-images-on-proxmox-using-ansible-shell-command-fails-while-s
# https://www.reddit.com/r/ansible/comments/15gocqj/problem_when_using_ansible_to_configure_cloudinit/
# https://docs.ansible.com/ansible/latest/modules/file_module.html
- name: "Create disk images directory"
file:
path: "{{ item }}"
state: directory
mode: "ugo+rwx"
owner: nobody
group: users
recurse: true
with_items:
- "{{ cloud_init_dir }}"
# Read the host SSH trusted keys into a variable
- name: "Read trusted public SSH keys"
ansible.builtin.slurp:
src: "{{ cloud_init_ssh_keys }}"
register: ssh_keys_encoded
# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_blocks.html
- name: "Create Cloud-Init VM templates"
block:
# Download cloud images
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/get_url_module.html
- name: "Download cloud image"
# Re-create the VM templates when the downloaded image changed
register: download
get_url:
url: "{{ item.url }}"
dest: "{{ item.file }}"
mode: "ugo+rwx"
owner: nobody
group: users
timeout: 120
with_items: "{{ images }}"
# Copy cloud image to disk file, make modifications to copy not original download
- name: "Copy cloud image"
when: download.changed
ansible.builtin.copy:
src: "{{ item.file }}"
dest: "{{ item.disk }}"
mode: "ugo+rwx"
owner: nobody
group: users
with_items: "{{ images }}"
# Resize using qemu-img to avoid need for using qm set after VM is created
- name: "Resize disk image"
when: download.changed
ansible.builtin.command: "qemu-img resize {{ item.disk }} 8G"
with_items: "{{ images }}"
# TODO: Use snippets: https://forum.proxmox.com/threads/combining-custom-cloud-init-with-auto-generated.59008/page-3
# Install guest agent in disk image
- name: "Install guest agent in disk image"
when: download.changed
ansible.builtin.command: "virt-customize -a {{ item.disk }} --install qemu-guest-agent"
with_items: "{{ images }}"
# Destroy the VM, only if a new image was downloaded
# https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html
- name: "Destroy VM"
# when: download.changed
community.general.proxmox_kvm:
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token }}"
api_token_secret: "{{ proxmox_api_secret }}"
api_host: "{{ inventory_hostname }}"
node: "{{ inventory_hostname_short }}"
vmid: "{{ item.id }}"
state: "absent"
with_items: "{{ images }}"
- name: "Create VM"
# when: download.changed
community.general.proxmox_kvm:
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token }}"
api_token_secret: "{{ proxmox_api_secret }}"
api_host: "{{ ansible_host }}"
node: "{{ ansible_hostname }}"
vmid: "{{ item.id }}"
name: "{{ item.name }}"
tags: "{{ item.tags }}"
memory: 4096
cores: 2
net:
net0: "virtio,bridge=vmbr1"
ipconfig:
ipconfig0: "ip=dhcp"
scsihw: "virtio-scsi-pci"
ide:
ide2: "vmdata:cloudinit"
ciuser: "{{ cloud_init_user }}"
cipassword: "{{ cloud_init_password }}"
searchdomains: "{{ cloud_init_domain }}"
sshkeys: "{{ ssh_keys_encoded.content | b64decode | trim }}"
ostype: "l26"
agent: "enabled=1,fstrim_cloned_disks=1"
onboot: false
state: "present"
with_items: "{{ images }}"
# TODO: Import-from does not work as part of create: "Only root can pass arbitrary filesystem paths"
- name: "Import disk to VM"
# when: download.changed
ansible.builtin.command: "qm set {{ item.id }} --scsi0 vmdata:0,import-from={{ item.disk }} --boot order=scsi0"
with_items: "{{ images }}"
# TODO: Update to template does not work: "Linked clone feature is not supported for drive 'scsi0' (500)"
# https://github.com/ansible/ansible/issues/44950
# sudo qm template 9001
- name: "Convert VM to template"
# when: download.changed
community.general.proxmox_kvm:
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token }}"
api_token_secret: "{{ proxmox_api_secret }}"
api_host: "{{ ansible_host }}"
node: "{{ ansible_hostname }}"
vmid: "{{ item.id }}"
template: true
update: true
with_items: "{{ images }}"
# TODO: Error 25
# - name: "Convert VM to template"
# # when: download.changed
# ansible.builtin.command: "qm template {{ item.id }}"
# with_items: "{{ images }}"
vars:
images:
- {
id: "9001",
name: "ubuntu-jammy-template",
tags: [ "ubuntu", "jammy", "cloud-image" ],
file: "{{ cloud_init_dir }}/jammy-server-cloudimg-amd64.img",
disk: "{{ cloud_init_dir }}/jammy-server-cloudimg-amd64-disk.img",
url: "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img",
}
- {
id: "9002",
name: "debian-bookworm-template",
tags: [ "debian", "bookworm", "cloud-image" ],
file: "{{ cloud_init_dir }}/debian-12-genericcloud-amd64.qcow2",
disk: "{{ cloud_init_dir }}/debian-12-genericcloud-amd64-disk.qcow2",
url: "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2",
}
Expected Results
I expect that after converting the VM to a template that I can use cloned disks.
Actual Results
https://gist.github.com/ptr727/cb1f268953703259f4f093514234c764
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
Files identified in the description:
If these files are incorrect, please update the component name section of the description or use the !component bot command.
cc @Ajpantuso @Thulium-Drake @UnderGreen @helldorado @joshainglis @karmab click here for bot help
Just FYI, qm template error 25 went away after updating to PVE 8.0.3, template: true still creates non-link-cloneable disks.
cc @krauthosting click here for bot help
This appears to be a Proxmox issue, disks are not converted to base images when modified.