Repository: ansible-collections/community.general

Issue:
proxmox_kvm linked clone fails because of format parameter
<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release and devel branch are affected too -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
Original issue here: https://github.com/ansible/ansible/issues/67048
creating linked clone with full: no using proxmox_kvm fails because the parameter format: qcow2 is forced set by proxmox_kvm

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
<!--- Write the short name of the module, plugin, task or feature below, use your best guess if unsure -->
proxmox_kvm

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```
ansible 2.10.1
  config file = /home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg
  configured module search path = ['/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/lab/library', '/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/library', '/usr/share/ansible']
  ansible python module location = /home/lrzasik/dreamlab/dreamlabrepos/cysoc/ve/lib/python3.6/site-packages/ansible
  executable location = /home/lrzasik/dreamlab/dreamlabrepos/cysoc/ve/bin/ansible
  python version = 3.6.9 (default, Jul 17 2020, 12:50:27) [GCC 8.4.0]
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```
ANSIBLE_PIPELINING(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=1800s
DEFAULT_ACTION_PLUGIN_PATH(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = ['/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/plugins/actions']
DEFAULT_CALLBACK_PLUGIN_PATH(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = ['/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/plugins/callback']
DEFAULT_CALLBACK_WHITELIST(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = ['profile_tasks', 'timer']
DEFAULT_FORKS(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = 100
DEFAULT_GATHERING(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = ['/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/localhost']
DEFAULT_MODULE_PATH(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = ['/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/lab/library', '/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/library',
DEFAULT_ROLES_PATH(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = ['/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/lab/roles']
DEFAULT_VAULT_PASSWORD_FILE(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = /home/lrzasik/ansible-vaults/v_cysoc.txt
DISPLAY_SKIPPED_HOSTS(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/lrzasik/dreamlab/dreamlabrepos/cysoc/deploy/ansible.cfg) = False

```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->


##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

<!--- Paste example playbooks or commands between quotes below -->
```
- name: clone vm
  proxmox_kvm:
    api_host: "{{ hypervisor_ip }}"
    api_password: "{{ pass }}"
    api_user: "{{ user }}"
    node: "{{ proxmox_node }}"
    clone: "{{ clone }}"
    name: "{{ inventory_hostname }}"
    full: no
  delegate_to: "{{ hypervisor_ip }}"
```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
Task succeeds and creates a linked clone.

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->
The task fails with:
<!--- Paste verbatim command output between quotes -->
```
"Unable to clone vm cysoc-test-first-vm-1 from vmid 30000=500 Internal Server Error: parameter 'format' not allowed for linked clones - {\"data\":null}"
```



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

If these files are inaccurate, 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/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Aversiste @helldorado @joshainglis @karmab
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Related: https://github.com/ansible-collections/community.general/pull/850

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
@@ -120,9 +120,10 @@
     description:
       - Target drive's backing file's data format.
       - Used only with clone
+      - Use I(format=unspecified) and I(full=false) for a linked clone.
     type: str
     default: qcow2
-    choices: [ "cloop", "cow", "qcow", "qcow2", "qed", "raw", "vmdk" ]
+    choices: [ "cloop", "cow", "qcow", "qcow2", "qed", "raw", "vmdk", "unspecified" ]
   freeze:
     description:
       - Specify if PVE should freeze CPU at startup (use 'c' monitor command to start execution).
@@ -472,6 +473,22 @@
     format: qcow2
     timeout: 500
 
+- name: >
+    Create linked clone VM with only source VM name.
+    The VM source is spynal.
+    The target VM name is zavala
+  community.general.proxmox_kvm:
+    api_user: root@pam
+    api_password: secret
+    api_host: helldorado
+    clone: spynal
+    name: zavala
+    node: sabrewulf
+    storage: VMs
+    full: no
+    format: unspecified
+    timeout: 500
+
 - name: Clone VM with source vmid and target newid and raw format
   community.general.proxmox_kvm:
     api_user: root@pam
@@ -865,7 +882,7 @@ def main():
             description=dict(type='str'),
             digest=dict(type='str'),
             force=dict(type='bool', default=False),
-            format=dict(type='str', default='qcow2', choices=['cloop', 'cow', 'qcow', 'qcow2', 'qed', 'raw', 'vmdk']),
+            format=dict(type='str', default='qcow2', choices=['cloop', 'cow', 'qcow', 'qcow2', 'qed', 'raw', 'vmdk', 'unspecified']),
             freeze=dict(type='bool'),
             full=dict(type='bool', default=True),
             hostpci=dict(type='dict'),
@@ -945,6 +962,9 @@ def main():
     vmid = module.params['vmid']
     validate_certs = module.params['validate_certs']
 
+    if module.params['format'] == 'unspecified':
+        module.params['format'] = None
+
     # If password not set get it from PROXMOX_PASSWORD env
     if not api_password:
         try:


Test patch: