some time ago I've created ansible playbook for provisioning of new VMs to proxmox environment in my homelab via ansible. The catch is that after reinstalling my proxmox nodes last week, ansible playbook responsible for cloning of my debian template stopped working for some reason.
My playbook looks like this:
- name: 010-cloning
hosts: "{{ default_PVE }}"
user: root
gather_facts: false
vars:
PVE_node: ""
VM_name: ""
VM_template: ""
PV_user: ""
PV_password: ""
default_PVE: ""
tasks:
- name: Cloning VM from "{{ VM_template }}" with name "{{ VM_name }}"
proxmox_kvm:
api_user : "{{ PV_user }}"
api_password: "{{ PV_password }}"
api_host : "{{ PVE_node }}"
clone: "{{ VM_template }}"
name : "{{ VM_name }}"
node : "{{ default_PVE }}"
For some unknown reason I'm getting this error:
TASK [Cloning VM from "debian-11-template" with name "validationrun"] *****************************************************************************************************************************************************************************************************************
fatal: [prox1]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "No VM with name validationrun found"}
Where prox1 is my proxmox node, debian-11-template is my template and validationrun is name of the new VM. I've checked official ansible documentation for proxmox module and I've tried the very example of VM cloning, but with the same error - https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html#examples
I've tried to run playbook with verbose parameter, but I've got basically the same error as I've already mentioned (I've hidden sensitive content):
<XXX.XXX.XXX.XXX> (1, b'\r\n{"failed": true, "msg": "No VM with name validationrun found", "invocation": {"module_args": {"api_user": "XXX", "api_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "api_host": "prox1", "clone": "debian-11-template", "name": "validationrun", "node": "prox1", "validate_certs": false, "full": true, "state": "present", "timeout": 30, "update": false, "proxmox_default_behavior": "no_defaults", "api_token_id": null, "api_token_secret": null, "acpi": null, "agent": null, "args": null, "autostart": null, "balloon": null, "bios": null, "boot": null, "bootdisk": null, "cicustom": null, "cipassword": null, "citype": null, "ciuser": null, "cores": null, "cpu": null, "cpulimit": null, "cpuunits": null, "delete": null, "description": null, "digest": null, "efidisk0": null, "force": null, "format": null, "freeze": null, "hostpci": null, "hotplug": null, "hugepages": null, "ide": null, "ipconfig": null, "keyboard": null, "kvm": null, "localtime": null, "lock": null, "machine": null, "memory": null, "migrate_downtime": null, "migrate_speed": null, "nameservers": null, "net": null, "newid": null, "numa": null, "numa_enabled": null, "onboot": null, "ostype": null, "parallel": null, "pool": null, "protection": null, "reboot": null, "revert": null, "sata": null, "scsi": null, "scsihw": null, "serial": null, "searchdomains": null, "shares": null, "skiplock": null, "smbios": null, "snapname": null, "sockets": null, "sshkeys": null, "startdate": null, "startup": null, "storage": null, "tablet": null, "tags": null, "target": null, "tdf": null, "template": null, "vcpus": null, "vga": null, "virtio": null, "vmid": null, "watchdog": null}}}\r\n', b'Shared connection to XXX.XXX.XXX.XXX closed.\r\n')
Did somebody encountered similar issue or do you know how to fix it? I've been trying to find solution for couple of days without success.
This seems to be a bug in the Proxmox_kvm Ansible Module. I have the same issue with the same code. I found this bugreport: https://github.com/ansible-collections/community.general/issues/4278, fixes are already merged but not released yet.
In the meantime I fixed this by installing the Ansible community.general collection following this manual: https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#installing-a-collection-from-a-git-repository
To checkout the latest commit of the Collection, run:
ansible-galaxy collection install git+https://github.com/ansible-collections/community.general.git,main
Afterwards the VM creation works as expected.