From e3e66a57ecfe56d99287f1c2c1b381a8931e53c3 Mon Sep 17 00:00:00 2001 From: lukaszrzasik Date: Sat, 10 Oct 2020 10:53:09 +0200 Subject: [PATCH] proxmox_kvm: allow setting format to null (None) (#1028) * Allow setting format to null (None) * Use string instead of None for consistency * Add changelog * Update changelogs/fragments/1028-proxmox-kvm-linked-clone.yml Co-authored-by: Felix Fontein * Update plugins/modules/cloud/misc/proxmox_kvm.py Co-authored-by: Felix Fontein * Substitute 'unspecified' format with None Co-authored-by: Lukasz Rzasik Co-authored-by: Felix Fontein --- .../1028-proxmox-kvm-linked-clone.yml | 3 +++ plugins/modules/cloud/misc/proxmox_kvm.py | 24 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/1028-proxmox-kvm-linked-clone.yml diff --git a/changelogs/fragments/1028-proxmox-kvm-linked-clone.yml b/changelogs/fragments/1028-proxmox-kvm-linked-clone.yml new file mode 100644 index 0000000000..f85b5f5f87 --- /dev/null +++ b/changelogs/fragments/1028-proxmox-kvm-linked-clone.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - proxmox_kvm - fix issue causing linked clones not being create by allowing ``format=unspecified`` (https://github.com/ansible-collections/community.general/issues/1027). diff --git a/plugins/modules/cloud/misc/proxmox_kvm.py b/plugins/modules/cloud/misc/proxmox_kvm.py index 7a7070715d..7d1cc3d779 100644 --- a/plugins/modules/cloud/misc/proxmox_kvm.py +++ b/plugins/modules/cloud/misc/proxmox_kvm.py @@ -120,9 +120,10 @@ options: 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 @@ EXAMPLES = ''' 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: