Repository: ansible-collections/community.general

Issue:
proxmox: Unable to create VM 
### Summary

When creating a VM on proxmox using the proxmox_kvm module in version 4.5.0, I am getting an error: "No VM with name <VM_NAME> found"

This does not happen with version 4.4.0

### Issue Type

Bug Report

### Component Name

community.general.proxmox_kvm

### Ansible Version

2.11.x


### Community.general Version

4.5.0

### Configuration

_No response_

### OS / Environment

AWX 19.4.0

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
---
- name: Create VM
  hosts: localhost
  gather_facts: False
  vars:
    node_name: serverone
  tasks:
    - name: "Create VM '{{ vm_name }}' on node '{{ node_name }}'"  # <----- It fails here
      community.general.proxmox_kvm:
        api_host: "{{ proxmox_host }}"
        api_user: "{{ proxmox_username }}"
        api_password: "{{ proxmox_password }}"
        clone: "{{ clone_source_template }}"
        name: "{{ vm_name }}"
        node: "{{ node_name }}"
        format: unspecified
        full: False
      register: vm_creation

    - name: Wait 5 seconds
      wait_for:
        timeout: 5
      when: not vm_creation.failed and vm_creation.changed

    - name: "Configure network for VM '{{ vm_name }}'"
      community.general.proxmox_nic:
        api_host: "{{ proxmox_host }}"
        api_user: "{{ proxmox_username }}"
        api_password: "{{ proxmox_password }}"
        name: "{{ vm_name }}"
        interface: net0
        bridge: "{{ bridge_name }}"
        firewall: False
        state: present


    - name: "Start VM '{{ vm_name }}'"
      community.general.proxmox_kvm:
        api_host: "{{ proxmox_host }}"
        api_user: "{{ proxmox_username }}"
        api_password: "{{ proxmox_password }}"
        name: "{{ vm_name }}"
        node: "{{ node_name }}"
        state: started
```


### Expected Results

A VM should be created. It fails.

### Actual Results

```json
{
  "msg": "No VM with name test123 found",
  "invocation": {
    "module_args": {
      "api_host": "REDACTED",
      "api_user": "REDACTED",
      "api_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "clone": "template-debian11",
      "name": "test123",
      "node": "REDACTED",
      "format": null,
      "full": false,
      "validate_certs": false,
      "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,
      "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
    }
  },
  "_ansible_no_log": false,
  "changed": false
}
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/cloud/misc/proxmox_kvm.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/misc/proxmox_kvm.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Ajpantuso @Thulium-Drake @helldorado @joshainglis @karmab @tleguern
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
I have the very same problem using proxmox_kvm to clone a vm using version 4.5.0.

Thank you for any help!
@reitermarkus could this be caused by #4029?
I think I found the error, see https://github.com/ansible-collections/community.general/pull/4287.
There is also another error when cloning VM. The fix in #4287 fixes half of it, but there is also another issue with the `get_vm` call. Added a PR that to fix:
https://github.com/ansible-collections/community.general/pull/4306

Resolving patch:
diff --git a/plugins/modules/cloud/misc/proxmox_kvm.py b/plugins/modules/cloud/misc/proxmox_kvm.py
--- a/plugins/modules/cloud/misc/proxmox_kvm.py
+++ b/plugins/modules/cloud/misc/proxmox_kvm.py
@@ -1210,7 +1210,7 @@ def main():
             module.exit_json(changed=False, vmid=existing_vmid, msg="VM with name <%s> already exists" % name)
 
         # Ensure the choosen VM id doesn't already exist when cloning
-        if proxmox.get_vm(newid, ignore_errors=True):
+        if proxmox.get_vm(newid, ignore_missing=True):
             module.exit_json(changed=False, vmid=vmid, msg="vmid %s with VM name %s already exists" % (newid, name))
 
     if delete is not None:


Test patch: