2020-03-09 10:11:07 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
2022-02-07 06:21:24 +01:00
|
|
|
#
|
2020-03-09 10:11:07 +01:00
|
|
|
# Copyright: (c) 2016, Abdoul Bah (@helldorado) <bahabdoul at gmail.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
|
|
|
module: proxmox_kvm
|
|
|
|
short_description: Management of Qemu(KVM) Virtual Machines in Proxmox VE cluster.
|
|
|
|
description:
|
|
|
|
- Allows you to create/delete/stop Qemu(KVM) Virtual Machines in Proxmox VE cluster.
|
2021-10-12 13:56:15 +02:00
|
|
|
- Since community.general 4.0.0 on, there are no more default values, see I(proxmox_default_behavior).
|
2020-03-09 10:11:07 +01:00
|
|
|
author: "Abdoul Bah (@helldorado) <bahabdoul at gmail.com>"
|
|
|
|
options:
|
|
|
|
acpi:
|
|
|
|
description:
|
|
|
|
- Specify if ACPI should be enabled/disabled.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(yes).
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
|
|
|
agent:
|
|
|
|
description:
|
|
|
|
- Specify if the QEMU Guest Agent should be enabled/disabled.
|
|
|
|
type: bool
|
|
|
|
args:
|
|
|
|
description:
|
|
|
|
- Pass arbitrary arguments to kvm.
|
|
|
|
- This option is for experts only!
|
2021-10-12 13:56:15 +02:00
|
|
|
- If I(proxmox_default_behavior) is set to C(compatiblity), this option has a default of
|
|
|
|
C(-serial unix:/var/run/qemu-server/<vmid>.serial,server,nowait).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
autostart:
|
|
|
|
description:
|
|
|
|
- Specify if the VM should be automatically restarted after crash (currently ignored in PVE API).
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(no).
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
|
|
|
balloon:
|
|
|
|
description:
|
|
|
|
- Specify the amount of RAM for the VM in MB.
|
|
|
|
- Using zero disables the balloon driver.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(0).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
bios:
|
|
|
|
description:
|
|
|
|
- Specify the BIOS implementation.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
choices: ['seabios', 'ovmf']
|
|
|
|
boot:
|
|
|
|
description:
|
|
|
|
- Specify the boot order -> boot on floppy C(a), hard disk C(c), CD-ROM C(d), or network C(n).
|
|
|
|
- You can combine to set order.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(cnd).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
bootdisk:
|
|
|
|
description:
|
|
|
|
- Enable booting from specified disk. C((ide|sata|scsi|virtio)\d+)
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-11-24 20:32:25 +01:00
|
|
|
cicustom:
|
|
|
|
description:
|
|
|
|
- 'cloud-init: Specify custom files to replace the automatically generated ones at start.'
|
|
|
|
type: str
|
|
|
|
version_added: 1.3.0
|
|
|
|
cipassword:
|
|
|
|
description:
|
|
|
|
- 'cloud-init: password of default user to create.'
|
|
|
|
type: str
|
|
|
|
version_added: 1.3.0
|
|
|
|
citype:
|
|
|
|
description:
|
|
|
|
- 'cloud-init: Specifies the cloud-init configuration format.'
|
|
|
|
- The default depends on the configured operating system type (C(ostype)).
|
|
|
|
- We use the C(nocloud) format for Linux, and C(configdrive2) for Windows.
|
|
|
|
type: str
|
|
|
|
choices: ['nocloud', 'configdrive2']
|
|
|
|
version_added: 1.3.0
|
|
|
|
ciuser:
|
|
|
|
description:
|
|
|
|
- 'cloud-init: username of default user to create.'
|
|
|
|
type: str
|
|
|
|
version_added: 1.3.0
|
2020-03-09 10:11:07 +01:00
|
|
|
clone:
|
|
|
|
description:
|
|
|
|
- Name of VM to be cloned. If C(vmid) is setted, C(clone) can take arbitrary value but required for initiating the clone.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
cores:
|
|
|
|
description:
|
|
|
|
- Specify number of cores per socket.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(1).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
cpu:
|
|
|
|
description:
|
|
|
|
- Specify emulated CPU type.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(kvm64).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
cpulimit:
|
|
|
|
description:
|
|
|
|
- Specify if CPU usage will be limited. Value 0 indicates no CPU limit.
|
|
|
|
- If the computer has 2 CPUs, it has total of '2' CPU time
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
cpuunits:
|
|
|
|
description:
|
|
|
|
- Specify CPU weight for a VM.
|
|
|
|
- You can disable fair-scheduler configuration by setting this to 0
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(1000).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
delete:
|
|
|
|
description:
|
|
|
|
- Specify a list of settings you want to delete.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Specify the description for the VM. Only used on the configuration web interface.
|
|
|
|
- This is saved as comment inside the configuration file.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
digest:
|
|
|
|
description:
|
|
|
|
- Specify if to prevent changes if current configuration file has different SHA1 digest.
|
|
|
|
- This can be used to prevent concurrent modifications.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2022-02-16 22:32:57 +01:00
|
|
|
efidisk0:
|
|
|
|
description:
|
|
|
|
- Specify a hash/dictionary of EFI disk options.
|
|
|
|
- Requires I(bios=ovmf) to be set to be able to use it.
|
|
|
|
type: dict
|
|
|
|
suboptions:
|
|
|
|
storage:
|
|
|
|
description:
|
|
|
|
- C(storage) is the storage identifier where to create the disk.
|
|
|
|
type: str
|
|
|
|
format:
|
|
|
|
description:
|
|
|
|
- C(format) is the drive's backing file's data format. Please refer to the Proxmox VE Administrator Guide,
|
|
|
|
section Proxmox VE Storage (see U(https://pve.proxmox.com/pve-docs/chapter-pvesm.html) for the latest
|
|
|
|
version, tables 3 to 14) to find out format supported by the provided storage backend.
|
|
|
|
type: str
|
|
|
|
efitype:
|
|
|
|
description:
|
|
|
|
- C(efitype) indicates the size of the EFI disk.
|
|
|
|
- C(2m) will allow for a 2MB EFI disk, which will be enough to persist boot order and new boot entries.
|
|
|
|
- C(4m) will allow for a 4MB EFI disk, which will additionally allow to store EFI keys in order to enable
|
|
|
|
Secure Boot
|
|
|
|
type: str
|
|
|
|
choices:
|
|
|
|
- 2m
|
|
|
|
- 4m
|
|
|
|
pre_enrolled_keys:
|
|
|
|
description:
|
|
|
|
- C(pre_enrolled_keys) indicates whether EFI keys for Secure Boot should be enrolled C(1) in the VM firmware
|
|
|
|
upon creation or not (0).
|
|
|
|
- If set to C(1), Secure Boot will also be enabled by default when the VM is created.
|
|
|
|
type: bool
|
|
|
|
version_added: 4.5.0
|
2020-03-09 10:11:07 +01:00
|
|
|
force:
|
|
|
|
description:
|
|
|
|
- Allow to force stop VM.
|
2020-09-07 22:07:40 +02:00
|
|
|
- Can be used with states C(stopped), C(restarted) and C(absent).
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(no).
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
|
|
|
format:
|
|
|
|
description:
|
|
|
|
- Target drive's backing file's data format.
|
|
|
|
- Used only with clone
|
2020-10-10 10:53:09 +02:00
|
|
|
- Use I(format=unspecified) and I(full=false) for a linked clone.
|
2022-02-12 09:22:03 +01:00
|
|
|
- Please refer to the Proxmox VE Administrator Guide, section Proxmox VE Storage (see
|
|
|
|
U(https://pve.proxmox.com/pve-docs/chapter-pvesm.html) for the latest version, tables 3 to 14) to find out format
|
|
|
|
supported by the provided storage backend.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(qcow2).
|
|
|
|
If I(proxmox_default_behavior) is set to C(no_defaults), not specifying this option is equivalent to setting it to C(unspecified).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-10-10 10:53:09 +02:00
|
|
|
choices: [ "cloop", "cow", "qcow", "qcow2", "qed", "raw", "vmdk", "unspecified" ]
|
2020-03-09 10:11:07 +01:00
|
|
|
freeze:
|
|
|
|
description:
|
|
|
|
- Specify if PVE should freeze CPU at startup (use 'c' monitor command to start execution).
|
|
|
|
type: bool
|
|
|
|
full:
|
|
|
|
description:
|
|
|
|
- Create a full copy of all disk. This is always done when you clone a normal VM.
|
|
|
|
- For VM templates, we try to create a linked clone by default.
|
|
|
|
- Used only with clone
|
|
|
|
type: bool
|
|
|
|
default: 'yes'
|
|
|
|
hostpci:
|
|
|
|
description:
|
|
|
|
- Specify a hash/dictionary of map host pci devices into guest. C(hostpci='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - C(hostpci[n]) where 0 ≤ n ≤ N.
|
|
|
|
- Values allowed are - C("host="HOSTPCIID[;HOSTPCIID2...]",pcie="1|0",rombar="1|0",x-vga="1|0"").
|
|
|
|
- The C(host) parameter is Host PCI device pass through. HOSTPCIID syntax is C(bus:dev.func) (hexadecimal numbers).
|
|
|
|
- C(pcie=boolean) I(default=0) Choose the PCI-express bus (needs the q35 machine model).
|
|
|
|
- C(rombar=boolean) I(default=1) Specify whether or not the device's ROM will be visible in the guest's memory map.
|
|
|
|
- C(x-vga=boolean) I(default=0) Enable vfio-vga device support.
|
|
|
|
- /!\ This option allows direct access to host hardware. So it is no longer possible to migrate such machines - use with special care.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
hotplug:
|
|
|
|
description:
|
|
|
|
- Selectively enable hotplug features.
|
|
|
|
- This is a comma separated list of hotplug features C('network', 'disk', 'cpu', 'memory' and 'usb').
|
|
|
|
- Value 0 disables hotplug completely and value 1 is an alias for the default C('network,disk,usb').
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
hugepages:
|
|
|
|
description:
|
|
|
|
- Enable/disable hugepages memory.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
choices: ['any', '2', '1024']
|
|
|
|
ide:
|
|
|
|
description:
|
|
|
|
- A hash/dictionary of volume used as IDE hard disk or CD-ROM. C(ide='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - C(ide[n]) where 0 ≤ n ≤ 3.
|
|
|
|
- Values allowed are - C("storage:size,format=value").
|
|
|
|
- C(storage) is the storage identifier where to create the disk.
|
|
|
|
- C(size) is the size of the disk in GB.
|
2022-02-12 09:22:03 +01:00
|
|
|
- C(format) is the drive's backing file's data format. C(qcow2|raw|subvol). Please refer to the Proxmox VE
|
|
|
|
Administrator Guide, section Proxmox VE Storage (see U(https://pve.proxmox.com/pve-docs/chapter-pvesm.html) for
|
|
|
|
the latest version, tables 3 to 14) to find out format supported by the provided storage backend.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-11-24 20:32:25 +01:00
|
|
|
ipconfig:
|
|
|
|
description:
|
|
|
|
- 'cloud-init: Set the IP configuration.'
|
|
|
|
- A hash/dictionary of network ip configurations. C(ipconfig='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - C(ipconfig[n]) where 0 ≤ n ≤ network interfaces.
|
|
|
|
- Values allowed are - C("[gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]").
|
|
|
|
- 'cloud-init: Specify IP addresses and gateways for the corresponding interface.'
|
|
|
|
- IP addresses use CIDR notation, gateways are optional but they should be in the same subnet of specified IP address.
|
|
|
|
- The special string 'dhcp' can be used for IP addresses to use DHCP, in which case no explicit gateway should be provided.
|
|
|
|
- For IPv6 the special string 'auto' can be used to use stateless autoconfiguration.
|
|
|
|
- If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to using dhcp on IPv4.
|
|
|
|
type: dict
|
|
|
|
version_added: 1.3.0
|
2020-03-09 10:11:07 +01:00
|
|
|
keyboard:
|
|
|
|
description:
|
|
|
|
- Sets the keyboard layout for VNC server.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
kvm:
|
|
|
|
description:
|
|
|
|
- Enable/disable KVM hardware virtualization.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(yes).
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
|
|
|
localtime:
|
|
|
|
description:
|
|
|
|
- Sets the real time clock to local time.
|
|
|
|
- This is enabled by default if ostype indicates a Microsoft OS.
|
|
|
|
type: bool
|
|
|
|
lock:
|
|
|
|
description:
|
|
|
|
- Lock/unlock the VM.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
choices: ['migrate', 'backup', 'snapshot', 'rollback']
|
|
|
|
machine:
|
|
|
|
description:
|
|
|
|
- Specifies the Qemu machine type.
|
|
|
|
- type => C((pc|pc(-i440fx)?-\d+\.\d+(\.pxe)?|q35|pc-q35-\d+\.\d+(\.pxe)?))
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
memory:
|
|
|
|
description:
|
|
|
|
- Memory size in MB for instance.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(512).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
migrate_downtime:
|
|
|
|
description:
|
|
|
|
- Sets maximum tolerated downtime (in seconds) for migrations.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
migrate_speed:
|
|
|
|
description:
|
|
|
|
- Sets maximum speed (in MB/s) for migrations.
|
|
|
|
- A value of 0 is no limit.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
name:
|
|
|
|
description:
|
|
|
|
- Specifies the VM name. Only used on the configuration web interface.
|
|
|
|
- Required only for C(state=present).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-11-24 20:32:25 +01:00
|
|
|
nameservers:
|
|
|
|
description:
|
|
|
|
- 'cloud-init: DNS server IP address(es).'
|
|
|
|
- If unset, PVE host settings are used.
|
|
|
|
type: list
|
|
|
|
elements: str
|
|
|
|
version_added: 1.3.0
|
2020-03-09 10:11:07 +01:00
|
|
|
net:
|
|
|
|
description:
|
|
|
|
- A hash/dictionary of network interfaces for the VM. C(net='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - C(net[n]) where 0 ≤ n ≤ N.
|
|
|
|
- Values allowed are - C("model="XX:XX:XX:XX:XX:XX",bridge="value",rate="value",tag="value",firewall="1|0",trunks="vlanid"").
|
|
|
|
- Model is one of C(e1000 e1000-82540em e1000-82544gc e1000-82545em i82551 i82557b i82559er ne2k_isa ne2k_pci pcnet rtl8139 virtio vmxnet3).
|
|
|
|
- C(XX:XX:XX:XX:XX:XX) should be an unique MAC address. This is automatically generated if not specified.
|
|
|
|
- The C(bridge) parameter can be used to automatically add the interface to a bridge device. The Proxmox VE standard bridge is called 'vmbr0'.
|
|
|
|
- Option C(rate) is used to limit traffic bandwidth from and to this interface. It is specified as floating point number, unit is 'Megabytes per second'.
|
|
|
|
- If you specify no bridge, we create a kvm 'user' (NATed) network device, which provides DHCP and DNS services.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
newid:
|
|
|
|
description:
|
|
|
|
- VMID for the clone. Used only with clone.
|
|
|
|
- If newid is not set, the next available VM ID will be fetched from ProxmoxAPI.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
numa:
|
|
|
|
description:
|
|
|
|
- A hash/dictionaries of NUMA topology. C(numa='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - C(numa[n]) where 0 ≤ n ≤ N.
|
|
|
|
- Values allowed are - C("cpu="<id[-id];...>",hostnodes="<id[-id];...>",memory="number",policy="(bind|interleave|preferred)"").
|
|
|
|
- C(cpus) CPUs accessing this NUMA node.
|
|
|
|
- C(hostnodes) Host NUMA nodes to use.
|
|
|
|
- C(memory) Amount of memory this NUMA node provides.
|
|
|
|
- C(policy) NUMA allocation policy.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-11-23 09:22:30 +01:00
|
|
|
numa_enabled:
|
|
|
|
description:
|
|
|
|
- Enables NUMA.
|
|
|
|
type: bool
|
2020-03-09 10:11:07 +01:00
|
|
|
onboot:
|
|
|
|
description:
|
|
|
|
- Specifies whether a VM will be started during system bootup.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(yes).
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
|
|
|
ostype:
|
|
|
|
description:
|
|
|
|
- Specifies guest operating system. This is used to enable special optimization/features for specific operating systems.
|
|
|
|
- The l26 is Linux 2.6/3.X Kernel.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(l26).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2022-02-12 17:44:20 +01:00
|
|
|
choices: ['other', 'wxp', 'w2k', 'w2k3', 'w2k8', 'wvista', 'win7', 'win8', 'win10', 'win11', 'l24', 'l26', 'solaris']
|
2020-03-09 10:11:07 +01:00
|
|
|
parallel:
|
|
|
|
description:
|
|
|
|
- A hash/dictionary of map host parallel devices. C(parallel='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - (parallel[n]) where 0 ≤ n ≤ 2.
|
|
|
|
- Values allowed are - C("/dev/parport\d+|/dev/usb/lp\d+").
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
protection:
|
|
|
|
description:
|
|
|
|
- Enable/disable the protection flag of the VM. This will enable/disable the remove VM and remove disk operations.
|
|
|
|
type: bool
|
|
|
|
reboot:
|
|
|
|
description:
|
|
|
|
- Allow reboot. If set to C(yes), the VM exit on reboot.
|
|
|
|
type: bool
|
|
|
|
revert:
|
|
|
|
description:
|
|
|
|
- Revert a pending change.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
sata:
|
|
|
|
description:
|
|
|
|
- A hash/dictionary of volume used as sata hard disk or CD-ROM. C(sata='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - C(sata[n]) where 0 ≤ n ≤ 5.
|
|
|
|
- Values allowed are - C("storage:size,format=value").
|
|
|
|
- C(storage) is the storage identifier where to create the disk.
|
|
|
|
- C(size) is the size of the disk in GB.
|
2022-02-12 09:22:03 +01:00
|
|
|
- C(format) is the drive's backing file's data format. C(qcow2|raw|subvol). Please refer to the Proxmox VE
|
|
|
|
Administrator Guide, section Proxmox VE Storage (see U(https://pve.proxmox.com/pve-docs/chapter-pvesm.html) for
|
|
|
|
the latest version, tables 3 to 14) to find out format supported by the provided storage backend.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
scsi:
|
|
|
|
description:
|
|
|
|
- A hash/dictionary of volume used as SCSI hard disk or CD-ROM. C(scsi='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - C(sata[n]) where 0 ≤ n ≤ 13.
|
|
|
|
- Values allowed are - C("storage:size,format=value").
|
|
|
|
- C(storage) is the storage identifier where to create the disk.
|
|
|
|
- C(size) is the size of the disk in GB.
|
2022-02-12 09:22:03 +01:00
|
|
|
- C(format) is the drive's backing file's data format. C(qcow2|raw|subvol). Please refer to the Proxmox VE
|
|
|
|
Administrator Guide, section Proxmox VE Storage (see U(https://pve.proxmox.com/pve-docs/chapter-pvesm.html) for
|
|
|
|
the latest version, tables 3 to 14) to find out format supported by the provided storage backend.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
scsihw:
|
|
|
|
description:
|
|
|
|
- Specifies the SCSI controller model.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
choices: ['lsi', 'lsi53c810', 'virtio-scsi-pci', 'virtio-scsi-single', 'megasas', 'pvscsi']
|
2020-11-24 20:32:25 +01:00
|
|
|
searchdomains:
|
|
|
|
description:
|
|
|
|
- 'cloud-init: Sets DNS search domain(s).'
|
|
|
|
- If unset, PVE host settings are used.
|
|
|
|
type: list
|
|
|
|
elements: str
|
|
|
|
version_added: 1.3.0
|
2020-03-09 10:11:07 +01:00
|
|
|
serial:
|
|
|
|
description:
|
|
|
|
- A hash/dictionary of serial device to create inside the VM. C('{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - serial[n](str; required) where 0 ≤ n ≤ 3.
|
|
|
|
- Values allowed are - C((/dev/.+|socket)).
|
|
|
|
- /!\ If you pass through a host serial device, it is no longer possible to migrate such machines - use with special care.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
shares:
|
|
|
|
description:
|
|
|
|
- Rets amount of memory shares for auto-ballooning. (0 - 50000).
|
|
|
|
- The larger the number is, the more memory this VM gets.
|
|
|
|
- The number is relative to weights of all other running VMs.
|
|
|
|
- Using 0 disables auto-ballooning, this means no limit.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
skiplock:
|
|
|
|
description:
|
|
|
|
- Ignore locks
|
|
|
|
- Only root is allowed to use this option.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: bool
|
2020-03-09 10:11:07 +01:00
|
|
|
smbios:
|
|
|
|
description:
|
|
|
|
- Specifies SMBIOS type 1 fields.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
snapname:
|
|
|
|
description:
|
|
|
|
- The name of the snapshot. Used only with clone.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
sockets:
|
|
|
|
description:
|
|
|
|
- Sets the number of CPU sockets. (1 - N).
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(1).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-11-24 20:32:25 +01:00
|
|
|
sshkeys:
|
|
|
|
description:
|
|
|
|
- 'cloud-init: SSH key to assign to the default user. NOT TESTED with multiple keys but a multi-line value should work.'
|
|
|
|
type: str
|
|
|
|
version_added: 1.3.0
|
2020-03-09 10:11:07 +01:00
|
|
|
startdate:
|
|
|
|
description:
|
|
|
|
- Sets the initial date of the real time clock.
|
|
|
|
- Valid format for date are C('now') or C('2016-09-25T16:01:21') or C('2016-09-25').
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
startup:
|
|
|
|
description:
|
|
|
|
- Startup and shutdown behavior. C([[order=]\d+] [,up=\d+] [,down=\d+]).
|
|
|
|
- Order is a non-negative number defining the general startup order.
|
|
|
|
- Shutdown in done with reverse ordering.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
state:
|
|
|
|
description:
|
|
|
|
- Indicates desired state of the instance.
|
|
|
|
- If C(current), the current state of the VM will be fetched. You can access it with C(results.status)
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
choices: ['present', 'started', 'absent', 'stopped', 'restarted','current']
|
|
|
|
default: present
|
|
|
|
storage:
|
|
|
|
description:
|
|
|
|
- Target storage for full clone.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
tablet:
|
|
|
|
description:
|
|
|
|
- Enables/disables the USB tablet device.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(no).
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
2021-03-15 13:39:23 +01:00
|
|
|
tags:
|
|
|
|
description:
|
|
|
|
- List of tags to apply to the VM instance.
|
|
|
|
- Tags must start with C([a-z0-9_]) followed by zero or more of the following characters C([a-z0-9_-+.]).
|
|
|
|
- Tags are only available in Proxmox 6+.
|
|
|
|
type: list
|
|
|
|
elements: str
|
|
|
|
version_added: 2.3.0
|
2020-03-09 10:11:07 +01:00
|
|
|
target:
|
|
|
|
description:
|
|
|
|
- Target node. Only allowed if the original VM is on shared storage.
|
|
|
|
- Used only with clone
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
tdf:
|
|
|
|
description:
|
|
|
|
- Enables/disables time drift fix.
|
|
|
|
type: bool
|
|
|
|
template:
|
|
|
|
description:
|
|
|
|
- Enables/disables the template.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(no).
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
|
|
|
timeout:
|
|
|
|
description:
|
|
|
|
- Timeout for operations.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
default: 30
|
|
|
|
update:
|
|
|
|
description:
|
|
|
|
- If C(yes), the VM will be updated with new value.
|
|
|
|
- Cause of the operations of the API and security reasons, I have disabled the update of the following parameters
|
|
|
|
- C(net, virtio, ide, sata, scsi). Per example updating C(net) update the MAC address and C(virtio) create always new disk...
|
2020-11-14 11:52:01 +01:00
|
|
|
- Update of C(pool) is disabled. It needs an additional API endpoint not covered by this module.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
vcpus:
|
|
|
|
description:
|
|
|
|
- Sets number of hotplugged vcpus.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: int
|
2020-03-09 10:11:07 +01:00
|
|
|
vga:
|
|
|
|
description:
|
|
|
|
- Select VGA type. If you want to use high resolution modes (>= 1280x1024x16) then you should use option 'std' or 'vmware'.
|
2021-10-12 13:56:15 +02:00
|
|
|
- This option has no default unless I(proxmox_default_behavior) is set to C(compatiblity); then the default is C(std).
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
choices: ['std', 'cirrus', 'vmware', 'qxl', 'serial0', 'serial1', 'serial2', 'serial3', 'qxl2', 'qxl3', 'qxl4']
|
|
|
|
virtio:
|
|
|
|
description:
|
|
|
|
- A hash/dictionary of volume used as VIRTIO hard disk. C(virtio='{"key":"value", "key":"value"}').
|
|
|
|
- Keys allowed are - C(virto[n]) where 0 ≤ n ≤ 15.
|
|
|
|
- Values allowed are - C("storage:size,format=value").
|
|
|
|
- C(storage) is the storage identifier where to create the disk.
|
|
|
|
- C(size) is the size of the disk in GB.
|
2022-02-12 09:22:03 +01:00
|
|
|
- C(format) is the drive's backing file's data format. C(qcow2|raw|subvol). Please refer to the Proxmox VE
|
|
|
|
Administrator Guide, section Proxmox VE Storage (see U(https://pve.proxmox.com/pve-docs/chapter-pvesm.html)
|
|
|
|
for the latest version, tables 3 to 14) to find out format supported by the provided storage backend.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
watchdog:
|
|
|
|
description:
|
|
|
|
- Creates a virtual hardware watchdog device.
|
2020-09-01 13:44:04 +02:00
|
|
|
type: str
|
2020-10-30 13:15:25 +01:00
|
|
|
proxmox_default_behavior:
|
|
|
|
description:
|
2021-10-12 13:56:15 +02:00
|
|
|
- As of community.general 4.0.0, various options no longer have default values.
|
|
|
|
These default values caused problems when users expected different behavior from Proxmox
|
|
|
|
by default or filled options which caused problems when set.
|
|
|
|
- The value C(compatibility) (default before community.general 4.0.0) will ensure that the default values
|
|
|
|
are used when the values are not explicitly specified by the user. The new default is C(no_defaults),
|
|
|
|
which makes sure these options have no defaults.
|
2020-10-30 13:15:25 +01:00
|
|
|
- This affects the I(acpi), I(autostart), I(balloon), I(boot), I(cores), I(cpu),
|
|
|
|
I(cpuunits), I(force), I(format), I(kvm), I(memory), I(onboot), I(ostype), I(sockets),
|
|
|
|
I(tablet), I(template), I(vga), options.
|
|
|
|
type: str
|
2021-10-12 13:56:15 +02:00
|
|
|
default: no_defaults
|
2020-10-30 13:15:25 +01:00
|
|
|
choices:
|
|
|
|
- compatibility
|
|
|
|
- no_defaults
|
|
|
|
version_added: "1.3.0"
|
2020-12-02 16:08:07 +01:00
|
|
|
extends_documentation_fragment:
|
|
|
|
- community.general.proxmox.documentation
|
|
|
|
- community.general.proxmox.selection
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Create new VM with minimal options
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Create new VM with minimal options and given vmid
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
vmid: 100
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Create new VM with two network interface options
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
2020-11-24 20:32:25 +01:00
|
|
|
net:
|
|
|
|
net0: 'virtio,bridge=vmbr1,rate=200'
|
|
|
|
net1: 'e1000,bridge=vmbr2'
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Create new VM with one network interface, three virto hard disk, 4 cores, and 2 vcpus
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
2020-11-24 20:32:25 +01:00
|
|
|
net:
|
|
|
|
net0: 'virtio,bridge=vmbr1,rate=200'
|
|
|
|
virtio:
|
|
|
|
virtio0: 'VMs_LVM:10'
|
|
|
|
virtio1: 'VMs:2,format=qcow2'
|
|
|
|
virtio2: 'VMs:5,format=raw'
|
2020-05-15 12:13:45 +02:00
|
|
|
cores: 4
|
|
|
|
vcpus: 2
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-02-16 22:32:57 +01:00
|
|
|
- name: Create VM with 1 10GB SATA disk and an EFI disk, with Secure Boot disabled by default
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
api_user: root@pam
|
|
|
|
api_password: secret
|
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
sata:
|
|
|
|
sata0: 'VMs_LVM:10,format=raw'
|
|
|
|
bios: ovmf
|
|
|
|
efidisk0:
|
|
|
|
storage: VMs_LVM_thin
|
|
|
|
format: raw
|
|
|
|
efitype: 4m
|
|
|
|
pre_enrolled_keys: False
|
|
|
|
|
|
|
|
- name: Create VM with 1 10GB SATA disk and an EFI disk, with Secure Boot enabled by default
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
api_user: root@pam
|
|
|
|
api_password: secret
|
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
sata:
|
|
|
|
sata0: 'VMs_LVM:10,format=raw'
|
|
|
|
bios: ovmf
|
|
|
|
efidisk0:
|
|
|
|
storage: VMs_LVM
|
|
|
|
format: raw
|
|
|
|
efitype: 4m
|
|
|
|
pre_enrolled_keys: 1
|
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: >
|
|
|
|
Clone VM with only source VM name.
|
|
|
|
The VM source is spynal.
|
|
|
|
The target VM name is zavala
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
clone: spynal
|
|
|
|
name: zavala
|
|
|
|
node: sabrewulf
|
|
|
|
storage: VMs
|
|
|
|
format: qcow2
|
|
|
|
timeout: 500
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-10-10 10:53:09 +02:00
|
|
|
- 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
|
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Clone VM with source vmid and target newid and raw format
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
clone: arbitrary_name
|
|
|
|
vmid: 108
|
|
|
|
newid: 152
|
|
|
|
name: zavala
|
|
|
|
node: sabrewulf
|
|
|
|
storage: LVM_STO
|
|
|
|
format: raw
|
|
|
|
timeout: 300
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-11-24 20:32:25 +01:00
|
|
|
- name: Create new VM and lock it for snapshot
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
lock: snapshot
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Create new VM and set protection to disable the remove VM and remove disk operations
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
protection: yes
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-11-24 20:32:25 +01:00
|
|
|
- name: Create new VM using cloud-init with a username and password
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
node: sabrewulf
|
|
|
|
api_user: root@pam
|
|
|
|
api_password: secret
|
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
ide:
|
|
|
|
ide2: 'local:cloudinit,format=qcow2'
|
|
|
|
ciuser: mylinuxuser
|
|
|
|
cipassword: supersecret
|
|
|
|
searchdomains: 'mydomain.internal'
|
|
|
|
nameservers: 1.1.1.1
|
|
|
|
net:
|
|
|
|
net0: 'virtio,bridge=vmbr1,tag=77'
|
|
|
|
ipconfig:
|
|
|
|
ipconfig0: 'ip=192.168.1.1/24,gw=192.168.1.1'
|
|
|
|
|
|
|
|
- name: Create new VM using Cloud-Init with an ssh key
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
node: sabrewulf
|
|
|
|
api_user: root@pam
|
|
|
|
api_password: secret
|
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
ide:
|
|
|
|
ide2: 'local:cloudinit,format=qcow2'
|
|
|
|
sshkeys: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILJkVm98B71lD5XHfihwcYHE9TVpsJmK1vR1JcaU82L+'
|
|
|
|
searchdomains: 'mydomain.internal'
|
|
|
|
nameservers:
|
|
|
|
- '1.1.1.1'
|
|
|
|
- '8.8.8.8'
|
|
|
|
net:
|
|
|
|
net0: 'virtio,bridge=vmbr1,tag=77'
|
|
|
|
ipconfig:
|
|
|
|
ipconfig0: 'ip=192.168.1.1/24'
|
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Start VM
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
state: started
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Stop VM
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
state: stopped
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Stop VM with force
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
state: stopped
|
|
|
|
force: yes
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Restart VM
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
state: restarted
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Remove VM
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
state: absent
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Get VM current state
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
state: current
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Update VM configuration
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
cores: 8
|
|
|
|
memory: 16384
|
|
|
|
update: yes
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Delete QEMU parameters
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
delete: 'args,template,cpulimit'
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-05-15 12:13:45 +02:00
|
|
|
- name: Revert a pending change
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.proxmox_kvm:
|
2020-05-15 12:13:45 +02:00
|
|
|
api_user: root@pam
|
2020-03-09 10:11:07 +01:00
|
|
|
api_password: secret
|
2020-05-15 12:13:45 +02:00
|
|
|
api_host: helldorado
|
|
|
|
name: spynal
|
|
|
|
node: sabrewulf
|
|
|
|
revert: 'template,cpulimit'
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
vmid:
|
2021-02-17 21:25:05 +01:00
|
|
|
description: The VM vmid.
|
|
|
|
returned: success
|
|
|
|
type: int
|
|
|
|
sample: 115
|
2020-03-09 10:11:07 +01:00
|
|
|
status:
|
2021-02-17 21:25:05 +01:00
|
|
|
description: The current virtual machine status.
|
|
|
|
returned: success, not clone, not absent, not update
|
|
|
|
type: str
|
|
|
|
sample: running
|
|
|
|
msg:
|
|
|
|
description: A short message
|
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
sample: "VM kropta with vmid = 110 is running"
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
import re
|
|
|
|
import time
|
|
|
|
import traceback
|
2020-11-24 20:32:25 +01:00
|
|
|
from ansible.module_utils.six.moves.urllib.parse import quote
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2021-12-24 18:34:48 +01:00
|
|
|
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
2022-02-07 06:21:24 +01:00
|
|
|
from ansible_collections.community.general.plugins.module_utils.proxmox import (proxmox_auth_argument_spec, ProxmoxAnsible)
|
2021-12-24 18:34:48 +01:00
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
2021-06-26 23:59:11 +02:00
|
|
|
from ansible.module_utils.common.text.converters import to_native
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
2021-06-20 12:42:19 +02:00
|
|
|
def parse_mac(netstr):
|
|
|
|
return re.search('=(.*?),', netstr).group(1)
|
|
|
|
|
|
|
|
|
|
|
|
def parse_dev(devstr):
|
|
|
|
return re.search('(.*?)(,|$)', devstr).group(1)
|
|
|
|
|
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
class ProxmoxKvmAnsible(ProxmoxAnsible):
|
|
|
|
def get_vminfo(self, node, vmid, **kwargs):
|
|
|
|
global results
|
|
|
|
results = {}
|
|
|
|
mac = {}
|
|
|
|
devices = {}
|
|
|
|
try:
|
|
|
|
vm = self.proxmox_api.nodes(node).qemu(vmid).config.get()
|
|
|
|
except Exception as e:
|
|
|
|
self.module.fail_json(msg='Getting information for VM with vmid = %s failed with exception: %s' % (vmid, e))
|
|
|
|
|
|
|
|
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
|
|
|
|
kwargs = dict((k, v) for k, v in kwargs.items() if v is not None)
|
|
|
|
|
|
|
|
# Convert all dict in kwargs to elements.
|
|
|
|
# For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n]
|
|
|
|
for k in list(kwargs.keys()):
|
|
|
|
if isinstance(kwargs[k], dict):
|
|
|
|
kwargs.update(kwargs[k])
|
|
|
|
del kwargs[k]
|
|
|
|
|
|
|
|
# Split information by type
|
|
|
|
re_net = re.compile(r'net[0-9]')
|
2022-02-16 22:32:57 +01:00
|
|
|
re_dev = re.compile(r'(virtio|ide|scsi|sata|efidisk)[0-9]')
|
2022-02-07 06:21:24 +01:00
|
|
|
for k in kwargs.keys():
|
|
|
|
if re_net.match(k):
|
|
|
|
mac[k] = parse_mac(vm[k])
|
|
|
|
elif re_dev.match(k):
|
|
|
|
devices[k] = parse_dev(vm[k])
|
|
|
|
|
|
|
|
results['mac'] = mac
|
|
|
|
results['devices'] = devices
|
|
|
|
results['vmid'] = int(vmid)
|
|
|
|
|
|
|
|
def settings(self, vmid, node, **kwargs):
|
|
|
|
proxmox_node = self.proxmox_api.nodes(node)
|
|
|
|
|
|
|
|
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
|
|
|
|
kwargs = dict((k, v) for k, v in kwargs.items() if v is not None)
|
|
|
|
|
|
|
|
return proxmox_node.qemu(vmid).config.set(**kwargs) is None
|
|
|
|
|
|
|
|
def wait_for_task(self, node, taskid):
|
|
|
|
timeout = self.module.params['timeout']
|
|
|
|
|
|
|
|
while timeout:
|
|
|
|
task = self.proxmox_api.nodes(node).tasks(taskid).status.get()
|
|
|
|
if task['status'] == 'stopped' and task['exitstatus'] == 'OK':
|
|
|
|
# Wait an extra second as the API can be a ahead of the hypervisor
|
|
|
|
time.sleep(1)
|
|
|
|
return True
|
|
|
|
timeout = timeout - 1
|
|
|
|
if timeout == 0:
|
|
|
|
break
|
2020-09-08 13:11:37 +02:00
|
|
|
time.sleep(1)
|
|
|
|
return False
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
def create_vm(self, vmid, newid, node, name, memory, cpu, cores, sockets, update, **kwargs):
|
|
|
|
# Available only in PVE 4
|
|
|
|
only_v4 = ['force', 'protection', 'skiplock']
|
|
|
|
only_v6 = ['ciuser', 'cipassword', 'sshkeys', 'ipconfig', 'tags']
|
|
|
|
|
|
|
|
# valide clone parameters
|
|
|
|
valid_clone_params = ['format', 'full', 'pool', 'snapname', 'storage', 'target']
|
|
|
|
clone_params = {}
|
|
|
|
# Default args for vm. Note: -args option is for experts only. It allows you to pass arbitrary arguments to kvm.
|
|
|
|
vm_args = "-serial unix:/var/run/qemu-server/{0}.serial,server,nowait".format(vmid)
|
|
|
|
|
|
|
|
proxmox_node = self.proxmox_api.nodes(node)
|
|
|
|
|
|
|
|
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
|
|
|
|
kwargs = dict((k, v) for k, v in kwargs.items() if v is not None)
|
|
|
|
kwargs.update(dict([k, int(v)] for k, v in kwargs.items() if isinstance(v, bool)))
|
|
|
|
|
|
|
|
version = self.version()
|
|
|
|
pve_major_version = 3 if version < LooseVersion('4.0') else version.version[0]
|
|
|
|
|
|
|
|
# The features work only on PVE 4+
|
|
|
|
if pve_major_version < 4:
|
|
|
|
for p in only_v4:
|
|
|
|
if p in kwargs:
|
|
|
|
del kwargs[p]
|
|
|
|
|
|
|
|
# The features work only on PVE 6
|
|
|
|
if pve_major_version < 6:
|
|
|
|
for p in only_v6:
|
|
|
|
if p in kwargs:
|
|
|
|
del kwargs[p]
|
|
|
|
|
|
|
|
# 'sshkeys' param expects an urlencoded string
|
|
|
|
if 'sshkeys' in kwargs:
|
|
|
|
urlencoded_ssh_keys = quote(kwargs['sshkeys'], safe='')
|
|
|
|
kwargs['sshkeys'] = str(urlencoded_ssh_keys)
|
|
|
|
|
2022-02-16 22:32:57 +01:00
|
|
|
# If update, don't update disk (virtio, efidisk0, ide, sata, scsi) and network interface
|
2022-02-07 06:21:24 +01:00
|
|
|
# pool parameter not supported by qemu/<vmid>/config endpoint on "update" (PVE 6.2) - only with "create"
|
|
|
|
if update:
|
|
|
|
if 'virtio' in kwargs:
|
|
|
|
del kwargs['virtio']
|
|
|
|
if 'sata' in kwargs:
|
|
|
|
del kwargs['sata']
|
|
|
|
if 'scsi' in kwargs:
|
|
|
|
del kwargs['scsi']
|
|
|
|
if 'ide' in kwargs:
|
|
|
|
del kwargs['ide']
|
2022-02-16 22:32:57 +01:00
|
|
|
if 'efidisk0' in kwargs:
|
|
|
|
del kwargs['efidisk0']
|
2022-02-07 06:21:24 +01:00
|
|
|
if 'net' in kwargs:
|
|
|
|
del kwargs['net']
|
|
|
|
if 'force' in kwargs:
|
|
|
|
del kwargs['force']
|
|
|
|
if 'pool' in kwargs:
|
|
|
|
del kwargs['pool']
|
|
|
|
|
2022-02-16 22:32:57 +01:00
|
|
|
# Check that the bios option is set to ovmf if the efidisk0 option is present
|
|
|
|
if 'efidisk0' in kwargs:
|
|
|
|
if ('bios' not in kwargs) or ('ovmf' != kwargs['bios']):
|
|
|
|
self.module.fail_json(msg='efidisk0 cannot be used if bios is not set to ovmf. ')
|
|
|
|
|
|
|
|
# Flatten efidisk0 option to a string so that it's a string which is what Proxmoxer and the API expect
|
|
|
|
if 'efidisk0' in kwargs:
|
|
|
|
efidisk0_str = ''
|
|
|
|
# Regexp to catch underscores in keys name, to replace them after by hypens
|
|
|
|
hyphen_re = re.compile(r'_')
|
|
|
|
# If present, the storage definition should be the first argument
|
|
|
|
if 'storage' in kwargs['efidisk0']:
|
|
|
|
efidisk0_str += kwargs['efidisk0'].get('storage') + ':1,'
|
|
|
|
kwargs['efidisk0'].pop('storage')
|
|
|
|
# Join other elements from the dict as key=value using commas as separator, replacing any underscore in key
|
|
|
|
# by hyphens (needed for pre_enrolled_keys to pre-enrolled-keys)
|
|
|
|
efidisk0_str += ','.join([hyphen_re.sub('-', k) + "=" + str(v) for k, v in kwargs['efidisk0'].items()
|
|
|
|
if 'storage' != k])
|
|
|
|
kwargs['efidisk0'] = efidisk0_str
|
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
# Convert all dict in kwargs to elements.
|
|
|
|
# For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n], ipconfig[n]
|
|
|
|
for k in list(kwargs.keys()):
|
|
|
|
if isinstance(kwargs[k], dict):
|
|
|
|
kwargs.update(kwargs[k])
|
|
|
|
del kwargs[k]
|
|
|
|
|
|
|
|
# Rename numa_enabled to numa. According the API documentation
|
|
|
|
if 'numa_enabled' in kwargs:
|
|
|
|
kwargs['numa'] = kwargs['numa_enabled']
|
|
|
|
del kwargs['numa_enabled']
|
|
|
|
|
|
|
|
# PVE api expects strings for the following params
|
|
|
|
if 'nameservers' in self.module.params:
|
|
|
|
nameservers = self.module.params.pop('nameservers')
|
|
|
|
if nameservers:
|
|
|
|
kwargs['nameserver'] = ' '.join(nameservers)
|
|
|
|
if 'searchdomains' in self.module.params:
|
|
|
|
searchdomains = self.module.params.pop('searchdomains')
|
|
|
|
if searchdomains:
|
|
|
|
kwargs['searchdomain'] = ' '.join(searchdomains)
|
|
|
|
|
|
|
|
# VM tags are expected to be valid and presented as a comma/semi-colon delimited string
|
|
|
|
if 'tags' in kwargs:
|
|
|
|
re_tag = re.compile(r'^[a-z0-9_][a-z0-9_\-\+\.]*$')
|
|
|
|
for tag in kwargs['tags']:
|
|
|
|
if not re_tag.match(tag):
|
|
|
|
self.module.fail_json(msg='%s is not a valid tag' % tag)
|
|
|
|
kwargs['tags'] = ",".join(kwargs['tags'])
|
|
|
|
|
|
|
|
# -args and skiplock require root@pam user - but can not use api tokens
|
|
|
|
if self.module.params['api_user'] == "root@pam" and self.module.params['args'] is None:
|
|
|
|
if not update and self.module.params['proxmox_default_behavior'] == 'compatibility':
|
|
|
|
kwargs['args'] = vm_args
|
|
|
|
elif self.module.params['api_user'] == "root@pam" and self.module.params['args'] is not None:
|
|
|
|
kwargs['args'] = self.module.params['args']
|
|
|
|
elif self.module.params['api_user'] != "root@pam" and self.module.params['args'] is not None:
|
|
|
|
self.module.fail_json(msg='args parameter require root@pam user. ')
|
|
|
|
|
|
|
|
if self.module.params['api_user'] != "root@pam" and self.module.params['skiplock'] is not None:
|
|
|
|
self.module.fail_json(msg='skiplock parameter require root@pam user. ')
|
|
|
|
|
|
|
|
if update:
|
|
|
|
if proxmox_node.qemu(vmid).config.set(name=name, memory=memory, cpu=cpu, cores=cores, sockets=sockets, **kwargs) is None:
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
elif self.module.params['clone'] is not None:
|
|
|
|
for param in valid_clone_params:
|
|
|
|
if self.module.params[param] is not None:
|
|
|
|
clone_params[param] = self.module.params[param]
|
|
|
|
clone_params.update(dict([k, int(v)] for k, v in clone_params.items() if isinstance(v, bool)))
|
|
|
|
taskid = proxmox_node.qemu(vmid).clone.post(newid=newid, name=name, **clone_params)
|
|
|
|
else:
|
|
|
|
taskid = proxmox_node.qemu.create(vmid=vmid, name=name, memory=memory, cpu=cpu, cores=cores, sockets=sockets, **kwargs)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
if not self.wait_for_task(node, taskid):
|
|
|
|
self.module.fail_json(msg='Reached timeout while waiting for creating VM. Last line in task before timeout: %s' %
|
|
|
|
proxmox_node.tasks(taskid).log.get()[:1])
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def start_vm(self, vm):
|
|
|
|
vmid = vm['vmid']
|
|
|
|
proxmox_node = self.proxmox_api.nodes(vm['node'])
|
|
|
|
taskid = proxmox_node.qemu(vmid).status.start.post()
|
|
|
|
if not self.wait_for_task(vm['node'], taskid):
|
|
|
|
self.module.fail_json(msg='Reached timeout while waiting for starting VM. Last line in task before timeout: %s' %
|
|
|
|
proxmox_node.tasks(taskid).log.get()[:1])
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def stop_vm(self, vm, force):
|
|
|
|
vmid = vm['vmid']
|
|
|
|
proxmox_node = self.proxmox_api.nodes(vm['node'])
|
|
|
|
taskid = proxmox_node.qemu(vmid).status.shutdown.post(forceStop=(1 if force else 0))
|
|
|
|
if not self.wait_for_task(vm['node'], taskid):
|
|
|
|
self.module.fail_json(msg='Reached timeout while waiting for stopping VM. Last line in task before timeout: %s' %
|
|
|
|
proxmox_node.tasks(taskid).log.get()[:1])
|
|
|
|
return False
|
|
|
|
return True
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2022-02-07 06:21:24 +01:00
|
|
|
module_args = proxmox_auth_argument_spec()
|
|
|
|
kvm_args = dict(
|
|
|
|
acpi=dict(type='bool'),
|
|
|
|
agent=dict(type='bool'),
|
|
|
|
args=dict(type='str'),
|
|
|
|
autostart=dict(type='bool'),
|
|
|
|
balloon=dict(type='int'),
|
|
|
|
bios=dict(choices=['seabios', 'ovmf']),
|
|
|
|
boot=dict(type='str'),
|
|
|
|
bootdisk=dict(type='str'),
|
|
|
|
cicustom=dict(type='str'),
|
|
|
|
cipassword=dict(type='str', no_log=True),
|
|
|
|
citype=dict(type='str', choices=['nocloud', 'configdrive2']),
|
|
|
|
ciuser=dict(type='str'),
|
|
|
|
clone=dict(type='str'),
|
|
|
|
cores=dict(type='int'),
|
|
|
|
cpu=dict(type='str'),
|
|
|
|
cpulimit=dict(type='int'),
|
|
|
|
cpuunits=dict(type='int'),
|
|
|
|
delete=dict(type='str'),
|
|
|
|
description=dict(type='str'),
|
|
|
|
digest=dict(type='str'),
|
2022-02-16 22:32:57 +01:00
|
|
|
efidisk0=dict(type='dict',
|
|
|
|
options=dict(
|
|
|
|
storage=dict(type='str'),
|
|
|
|
format=dict(type='str'),
|
|
|
|
efitype=dict(type='str', choices=['2m', '4m']),
|
|
|
|
pre_enrolled_keys=dict(type='bool'),
|
|
|
|
)),
|
2022-02-07 06:21:24 +01:00
|
|
|
force=dict(type='bool'),
|
|
|
|
format=dict(type='str', choices=['cloop', 'cow', 'qcow', 'qcow2', 'qed', 'raw', 'vmdk', 'unspecified']),
|
|
|
|
freeze=dict(type='bool'),
|
|
|
|
full=dict(type='bool', default=True),
|
|
|
|
hostpci=dict(type='dict'),
|
|
|
|
hotplug=dict(type='str'),
|
|
|
|
hugepages=dict(choices=['any', '2', '1024']),
|
|
|
|
ide=dict(type='dict'),
|
|
|
|
ipconfig=dict(type='dict'),
|
|
|
|
keyboard=dict(type='str'),
|
|
|
|
kvm=dict(type='bool'),
|
|
|
|
localtime=dict(type='bool'),
|
|
|
|
lock=dict(choices=['migrate', 'backup', 'snapshot', 'rollback']),
|
|
|
|
machine=dict(type='str'),
|
|
|
|
memory=dict(type='int'),
|
|
|
|
migrate_downtime=dict(type='int'),
|
|
|
|
migrate_speed=dict(type='int'),
|
|
|
|
name=dict(type='str'),
|
|
|
|
nameservers=dict(type='list', elements='str'),
|
|
|
|
net=dict(type='dict'),
|
|
|
|
newid=dict(type='int'),
|
|
|
|
node=dict(),
|
|
|
|
numa=dict(type='dict'),
|
|
|
|
numa_enabled=dict(type='bool'),
|
|
|
|
onboot=dict(type='bool'),
|
2022-02-12 17:44:20 +01:00
|
|
|
ostype=dict(choices=['other', 'wxp', 'w2k', 'w2k3', 'w2k8', 'wvista', 'win7', 'win8', 'win10', 'win11', 'l24', 'l26', 'solaris']),
|
2022-02-07 06:21:24 +01:00
|
|
|
parallel=dict(type='dict'),
|
|
|
|
pool=dict(type='str'),
|
|
|
|
protection=dict(type='bool'),
|
|
|
|
reboot=dict(type='bool'),
|
|
|
|
revert=dict(type='str'),
|
|
|
|
sata=dict(type='dict'),
|
|
|
|
scsi=dict(type='dict'),
|
|
|
|
scsihw=dict(choices=['lsi', 'lsi53c810', 'virtio-scsi-pci', 'virtio-scsi-single', 'megasas', 'pvscsi']),
|
|
|
|
serial=dict(type='dict'),
|
|
|
|
searchdomains=dict(type='list', elements='str'),
|
|
|
|
shares=dict(type='int'),
|
|
|
|
skiplock=dict(type='bool'),
|
|
|
|
smbios=dict(type='str'),
|
|
|
|
snapname=dict(type='str'),
|
|
|
|
sockets=dict(type='int'),
|
|
|
|
sshkeys=dict(type='str', no_log=False),
|
|
|
|
startdate=dict(type='str'),
|
|
|
|
startup=dict(),
|
|
|
|
state=dict(default='present', choices=['present', 'absent', 'stopped', 'started', 'restarted', 'current']),
|
|
|
|
storage=dict(type='str'),
|
|
|
|
tablet=dict(type='bool'),
|
|
|
|
tags=dict(type='list', elements='str'),
|
|
|
|
target=dict(type='str'),
|
|
|
|
tdf=dict(type='bool'),
|
|
|
|
template=dict(type='bool'),
|
|
|
|
timeout=dict(type='int', default=30),
|
|
|
|
update=dict(type='bool', default=False),
|
|
|
|
vcpus=dict(type='int'),
|
|
|
|
vga=dict(choices=['std', 'cirrus', 'vmware', 'qxl', 'serial0', 'serial1', 'serial2', 'serial3', 'qxl2', 'qxl3', 'qxl4']),
|
|
|
|
virtio=dict(type='dict'),
|
|
|
|
vmid=dict(type='int'),
|
|
|
|
watchdog=dict(),
|
|
|
|
proxmox_default_behavior=dict(type='str', default='no_defaults', choices=['compatibility', 'no_defaults']),
|
|
|
|
)
|
|
|
|
module_args.update(kvm_args)
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
module = AnsibleModule(
|
2022-02-07 06:21:24 +01:00
|
|
|
argument_spec=module_args,
|
2020-03-09 10:11:07 +01:00
|
|
|
mutually_exclusive=[('delete', 'revert'), ('delete', 'update'), ('revert', 'update'), ('clone', 'update'), ('clone', 'delete'), ('clone', 'revert')],
|
2021-02-12 13:01:52 +01:00
|
|
|
required_together=[('api_token_id', 'api_token_secret')],
|
|
|
|
required_one_of=[('name', 'vmid'), ('api_password', 'api_token_id')],
|
|
|
|
required_if=[('state', 'present', ['node'])],
|
2020-03-09 10:11:07 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
clone = module.params['clone']
|
|
|
|
cpu = module.params['cpu']
|
|
|
|
cores = module.params['cores']
|
|
|
|
delete = module.params['delete']
|
|
|
|
memory = module.params['memory']
|
|
|
|
name = module.params['name']
|
|
|
|
newid = module.params['newid']
|
|
|
|
node = module.params['node']
|
|
|
|
revert = module.params['revert']
|
|
|
|
sockets = module.params['sockets']
|
|
|
|
state = module.params['state']
|
|
|
|
update = bool(module.params['update'])
|
|
|
|
vmid = module.params['vmid']
|
|
|
|
validate_certs = module.params['validate_certs']
|
|
|
|
|
2020-10-30 13:15:25 +01:00
|
|
|
if module.params['proxmox_default_behavior'] == 'compatibility':
|
|
|
|
old_default_values = dict(
|
|
|
|
acpi=True,
|
|
|
|
autostart=False,
|
|
|
|
balloon=0,
|
|
|
|
boot='cnd',
|
|
|
|
cores=1,
|
|
|
|
cpu='kvm64',
|
|
|
|
cpuunits=1000,
|
|
|
|
format='qcow2',
|
|
|
|
kvm=True,
|
|
|
|
memory=512,
|
|
|
|
ostype='l26',
|
|
|
|
sockets=1,
|
|
|
|
tablet=False,
|
|
|
|
template=False,
|
|
|
|
vga='std',
|
|
|
|
)
|
|
|
|
for param, value in old_default_values.items():
|
|
|
|
if module.params[param] is None:
|
|
|
|
module.params[param] = value
|
|
|
|
|
2020-10-10 10:53:09 +02:00
|
|
|
if module.params['format'] == 'unspecified':
|
|
|
|
module.params['format'] = None
|
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
proxmox = ProxmoxKvmAnsible(module)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2020-09-05 00:51:54 +02:00
|
|
|
# If vmid is not defined then retrieve its value from the vm name,
|
|
|
|
# the cloned vm name or retrieve the next free VM id from ProxmoxAPI.
|
2020-03-09 10:11:07 +01:00
|
|
|
if not vmid:
|
2020-09-05 00:51:54 +02:00
|
|
|
if state == 'present' and not update and not clone and not delete and not revert:
|
2020-03-09 10:11:07 +01:00
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
vmid = proxmox.get_nextvmid()
|
2020-11-24 20:32:25 +01:00
|
|
|
except Exception:
|
2020-03-09 10:11:07 +01:00
|
|
|
module.fail_json(msg="Can't get the next vmid for VM {0} automatically. Ensure your cluster state is good".format(name))
|
|
|
|
else:
|
proxmox_kvm: code cleanup (#934)
* proxmox_kvm: remove redundant parameters
The functions start_vm() and stop_vm() receive four common parameters:
module, proxmox, vm and vmid.
The last too are redundant so keep only vm.
I also took the opportunity to remove extra API calls to proxmox.nodes()
by assigning its return value to a variable.
* proxmox_kvm: remove extra calls to status.current
The get_vm() function already returns an array of properties containing
the status so remove extra API calls to retrieve this information.
Example:
[{''netin'': 177232, ''name'': ''test-instance'', ''maxcpu'': 1, ''node'': ''prx-01'', ''disk'': 0, ''template'': 0, ''uptime'': 267, ''cpu'': 0.0410680030805531, ''diskread'': 165294744, ''maxdisk'': 10737418240, ''vmid'': 42, ''status'': ''running'', ''id'': ''qemu/42'', ''maxmem'': 536870912, ''diskwrite'': 18528256, ''netout'': 2918, ''type'': ''qemu'', ''mem'': 160284950}]
* proxmox_kvm: kill VZ_TYPE global variable
It reduces readability without providing much values nowadays.
* proxmox_kvm: simplify vmid generation
Forgotten suggestion from Felix Fontein in PR#811.
* proxmox_kvm: add changelog fragment for PR#934
2020-09-23 15:39:46 +02:00
|
|
|
clone_target = clone or name
|
2022-02-07 06:21:24 +01:00
|
|
|
vmid = proxmox.get_vmid(clone_target, ignore_missing=True, choose_first_if_multiple=True)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
if clone is not None:
|
2020-09-05 00:51:54 +02:00
|
|
|
# If newid is not defined then retrieve the next free id from ProxmoxAPI
|
2020-03-09 10:11:07 +01:00
|
|
|
if not newid:
|
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
newid = proxmox.get_nextvmid()
|
2020-11-24 20:32:25 +01:00
|
|
|
except Exception:
|
2020-03-09 10:11:07 +01:00
|
|
|
module.fail_json(msg="Can't get the next vmid for VM {0} automatically. Ensure your cluster state is good".format(name))
|
2020-09-05 00:51:54 +02:00
|
|
|
|
|
|
|
# Ensure source VM name exists when cloning
|
2022-02-07 06:21:24 +01:00
|
|
|
if not vmid:
|
2020-09-05 00:51:54 +02:00
|
|
|
module.fail_json(msg='VM with name = %s does not exist in cluster' % clone)
|
|
|
|
|
|
|
|
# Ensure source VM id exists when cloning
|
2022-02-07 06:21:24 +01:00
|
|
|
proxmox.get_vm(vmid)
|
2020-09-05 00:51:54 +02:00
|
|
|
|
|
|
|
# Ensure the choosen VM name doesn't already exist when cloning
|
2022-02-07 06:21:24 +01:00
|
|
|
existing_vmid = proxmox.get_vmid(name, choose_first_if_multiple=True)
|
2021-08-27 18:48:32 +02:00
|
|
|
if existing_vmid:
|
2022-02-07 06:21:24 +01:00
|
|
|
module.exit_json(changed=False, vmid=existing_vmid, msg="VM with name <%s> already exists" % name)
|
2020-09-05 00:51:54 +02:00
|
|
|
|
|
|
|
# Ensure the choosen VM id doesn't already exist when cloning
|
2022-02-07 06:21:24 +01:00
|
|
|
if proxmox.get_vm(newid, ignore_errors=True):
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=False, vmid=vmid, msg="vmid %s with VM name %s already exists" % (newid, name))
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
if delete is not None:
|
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
proxmox.settings(vmid, node, delete=delete)
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=True, vmid=vmid, msg="Settings has deleted on VM {0} with vmid {1}".format(name, vmid))
|
2020-03-09 10:11:07 +01:00
|
|
|
except Exception as e:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.fail_json(vmid=vmid, msg='Unable to delete settings on VM {0} with vmid {1}: '.format(name, vmid) + str(e))
|
2020-09-05 00:51:54 +02:00
|
|
|
|
|
|
|
if revert is not None:
|
2020-03-09 10:11:07 +01:00
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
proxmox.settings(vmid, node, revert=revert)
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=True, vmid=vmid, msg="Settings has reverted on VM {0} with vmid {1}".format(name, vmid))
|
2020-03-09 10:11:07 +01:00
|
|
|
except Exception as e:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.fail_json(vmid=vmid, msg='Unable to revert settings on VM {0} with vmid {1}: Maybe is not a pending task... '.format(name, vmid) + str(e))
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
if state == 'present':
|
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
if proxmox.get_vm(vmid, ignore_missing=True) and not (update or clone):
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=False, vmid=vmid, msg="VM with vmid <%s> already exists" % vmid)
|
2022-02-07 06:21:24 +01:00
|
|
|
elif proxmox.get_vmid(name, ignore_missing=True, choose_first_if_multiple=True) and not (update or clone):
|
|
|
|
module.exit_json(changed=False, vmid=proxmox.get_vmid(name, choose_first_if_multiple=True), msg="VM with name <%s> already exists" % name)
|
2020-03-09 10:11:07 +01:00
|
|
|
elif not (node, name):
|
|
|
|
module.fail_json(msg='node, name is mandatory for creating/updating vm')
|
2022-02-07 06:21:24 +01:00
|
|
|
elif not proxmox.get_node(node):
|
2020-03-09 10:11:07 +01:00
|
|
|
module.fail_json(msg="node '%s' does not exist in cluster" % node)
|
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
proxmox.create_vm(vmid, newid, node, name, memory, cpu, cores, sockets, update,
|
|
|
|
acpi=module.params['acpi'],
|
|
|
|
agent=module.params['agent'],
|
|
|
|
autostart=module.params['autostart'],
|
|
|
|
balloon=module.params['balloon'],
|
|
|
|
bios=module.params['bios'],
|
|
|
|
boot=module.params['boot'],
|
|
|
|
bootdisk=module.params['bootdisk'],
|
|
|
|
cicustom=module.params['cicustom'],
|
|
|
|
cipassword=module.params['cipassword'],
|
|
|
|
citype=module.params['citype'],
|
|
|
|
ciuser=module.params['ciuser'],
|
|
|
|
cpulimit=module.params['cpulimit'],
|
|
|
|
cpuunits=module.params['cpuunits'],
|
|
|
|
description=module.params['description'],
|
|
|
|
digest=module.params['digest'],
|
2022-02-16 22:32:57 +01:00
|
|
|
efidisk0=module.params['efidisk0'],
|
2022-02-07 06:21:24 +01:00
|
|
|
force=module.params['force'],
|
|
|
|
freeze=module.params['freeze'],
|
|
|
|
hostpci=module.params['hostpci'],
|
|
|
|
hotplug=module.params['hotplug'],
|
|
|
|
hugepages=module.params['hugepages'],
|
|
|
|
ide=module.params['ide'],
|
|
|
|
ipconfig=module.params['ipconfig'],
|
|
|
|
keyboard=module.params['keyboard'],
|
|
|
|
kvm=module.params['kvm'],
|
|
|
|
localtime=module.params['localtime'],
|
|
|
|
lock=module.params['lock'],
|
|
|
|
machine=module.params['machine'],
|
|
|
|
migrate_downtime=module.params['migrate_downtime'],
|
|
|
|
migrate_speed=module.params['migrate_speed'],
|
|
|
|
net=module.params['net'],
|
|
|
|
numa=module.params['numa'],
|
|
|
|
numa_enabled=module.params['numa_enabled'],
|
|
|
|
onboot=module.params['onboot'],
|
|
|
|
ostype=module.params['ostype'],
|
|
|
|
parallel=module.params['parallel'],
|
|
|
|
pool=module.params['pool'],
|
|
|
|
protection=module.params['protection'],
|
|
|
|
reboot=module.params['reboot'],
|
|
|
|
sata=module.params['sata'],
|
|
|
|
scsi=module.params['scsi'],
|
|
|
|
scsihw=module.params['scsihw'],
|
|
|
|
serial=module.params['serial'],
|
|
|
|
shares=module.params['shares'],
|
|
|
|
skiplock=module.params['skiplock'],
|
|
|
|
smbios1=module.params['smbios'],
|
|
|
|
snapname=module.params['snapname'],
|
|
|
|
sshkeys=module.params['sshkeys'],
|
|
|
|
startdate=module.params['startdate'],
|
|
|
|
startup=module.params['startup'],
|
|
|
|
tablet=module.params['tablet'],
|
|
|
|
tags=module.params['tags'],
|
|
|
|
target=module.params['target'],
|
|
|
|
tdf=module.params['tdf'],
|
|
|
|
template=module.params['template'],
|
|
|
|
vcpus=module.params['vcpus'],
|
|
|
|
vga=module.params['vga'],
|
|
|
|
virtio=module.params['virtio'],
|
|
|
|
watchdog=module.params['watchdog'])
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
if not clone:
|
2022-02-07 06:21:24 +01:00
|
|
|
proxmox.get_vminfo(node, vmid,
|
|
|
|
ide=module.params['ide'],
|
|
|
|
net=module.params['net'],
|
|
|
|
sata=module.params['sata'],
|
|
|
|
scsi=module.params['scsi'],
|
|
|
|
virtio=module.params['virtio'])
|
2020-03-09 10:11:07 +01:00
|
|
|
if update:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=True, vmid=vmid, msg="VM %s with vmid %s updated" % (name, vmid))
|
2020-03-09 10:11:07 +01:00
|
|
|
elif clone is not None:
|
2021-07-26 06:33:01 +02:00
|
|
|
module.exit_json(changed=True, vmid=newid, msg="VM %s with newid %s cloned from vm with vmid %s" % (name, newid, vmid))
|
2020-03-09 10:11:07 +01:00
|
|
|
else:
|
2021-02-25 12:34:53 +01:00
|
|
|
module.exit_json(changed=True, msg="VM %s with vmid %s deployed" % (name, vmid), **results)
|
2020-03-09 10:11:07 +01:00
|
|
|
except Exception as e:
|
|
|
|
if update:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.fail_json(vmid=vmid, msg="Unable to update vm {0} with vmid {1}=".format(name, vmid) + str(e))
|
2020-03-09 10:11:07 +01:00
|
|
|
elif clone is not None:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.fail_json(vmid=vmid, msg="Unable to clone vm {0} from vmid {1}=".format(name, vmid) + str(e))
|
2020-03-09 10:11:07 +01:00
|
|
|
else:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.fail_json(vmid=vmid, msg="creation of qemu VM %s with vmid %s failed with exception=%s" % (name, vmid, e))
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif state == 'started':
|
2021-02-17 21:25:05 +01:00
|
|
|
status = {}
|
2020-03-09 10:11:07 +01:00
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
if not vmid:
|
2020-09-05 00:51:54 +02:00
|
|
|
module.fail_json(msg='VM with name = %s does not exist in cluster' % name)
|
2022-02-07 06:21:24 +01:00
|
|
|
vm = proxmox.get_vm(vmid)
|
|
|
|
status['status'] = vm['status']
|
|
|
|
if vm['status'] == 'running':
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=False, vmid=vmid, msg="VM %s is already running" % vmid, **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
if proxmox.start_vm(vm):
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=True, vmid=vmid, msg="VM %s started" % vmid, **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
except Exception as e:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.fail_json(vmid=vmid, msg="starting of VM %s failed with exception: %s" % (vmid, e), **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif state == 'stopped':
|
2021-02-17 21:25:05 +01:00
|
|
|
status = {}
|
2020-03-09 10:11:07 +01:00
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
if not vmid:
|
2020-09-05 00:51:54 +02:00
|
|
|
module.fail_json(msg='VM with name = %s does not exist in cluster' % name)
|
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
vm = proxmox.get_vm(vmid)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
status['status'] = vm['status']
|
|
|
|
if vm['status'] == 'stopped':
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=False, vmid=vmid, msg="VM %s is already stopped" % vmid, **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
if proxmox.stop_vm(vm, force=module.params['force']):
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=True, vmid=vmid, msg="VM %s is shutting down" % vmid, **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
except Exception as e:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.fail_json(vmid=vmid, msg="stopping of VM %s failed with exception: %s" % (vmid, e), **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif state == 'restarted':
|
2021-02-17 21:25:05 +01:00
|
|
|
status = {}
|
2020-03-09 10:11:07 +01:00
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
if not vmid:
|
2020-09-05 00:51:54 +02:00
|
|
|
module.fail_json(msg='VM with name = %s does not exist in cluster' % name)
|
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
vm = proxmox.get_vm(vmid)
|
|
|
|
status['status'] = vm['status']
|
|
|
|
if vm['status'] == 'stopped':
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=False, vmid=vmid, msg="VM %s is not running" % vmid, **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
if proxmox.stop_vm(vm, force=module.params['force']) and proxmox.start_vm(vm):
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=True, vmid=vmid, msg="VM %s is restarted" % vmid, **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
except Exception as e:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.fail_json(vmid=vmid, msg="restarting of VM %s failed with exception: %s" % (vmid, e), **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif state == 'absent':
|
2021-02-17 21:25:05 +01:00
|
|
|
status = {}
|
2020-03-09 10:11:07 +01:00
|
|
|
try:
|
2022-02-07 06:21:24 +01:00
|
|
|
vm = proxmox.get_vm(vmid, ignore_missing=True)
|
2020-03-09 10:11:07 +01:00
|
|
|
if not vm:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=False, vmid=vmid)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-02-07 06:21:24 +01:00
|
|
|
proxmox_node = proxmox.proxmox_api.nodes(vm['node'])
|
|
|
|
status['status'] = vm['status']
|
|
|
|
if vm['status'] == 'running':
|
2020-09-07 22:07:40 +02:00
|
|
|
if module.params['force']:
|
2022-02-07 06:21:24 +01:00
|
|
|
proxmox.stop_vm(vm, True)
|
2020-09-07 22:07:40 +02:00
|
|
|
else:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=False, vmid=vmid, msg="VM %s is running. Stop it before deletion or use force=yes." % vmid)
|
proxmox_kvm: code cleanup (#934)
* proxmox_kvm: remove redundant parameters
The functions start_vm() and stop_vm() receive four common parameters:
module, proxmox, vm and vmid.
The last too are redundant so keep only vm.
I also took the opportunity to remove extra API calls to proxmox.nodes()
by assigning its return value to a variable.
* proxmox_kvm: remove extra calls to status.current
The get_vm() function already returns an array of properties containing
the status so remove extra API calls to retrieve this information.
Example:
[{''netin'': 177232, ''name'': ''test-instance'', ''maxcpu'': 1, ''node'': ''prx-01'', ''disk'': 0, ''template'': 0, ''uptime'': 267, ''cpu'': 0.0410680030805531, ''diskread'': 165294744, ''maxdisk'': 10737418240, ''vmid'': 42, ''status'': ''running'', ''id'': ''qemu/42'', ''maxmem'': 536870912, ''diskwrite'': 18528256, ''netout'': 2918, ''type'': ''qemu'', ''mem'': 160284950}]
* proxmox_kvm: kill VZ_TYPE global variable
It reduces readability without providing much values nowadays.
* proxmox_kvm: simplify vmid generation
Forgotten suggestion from Felix Fontein in PR#811.
* proxmox_kvm: add changelog fragment for PR#934
2020-09-23 15:39:46 +02:00
|
|
|
taskid = proxmox_node.qemu.delete(vmid)
|
2022-02-07 06:21:24 +01:00
|
|
|
if not proxmox.wait_for_task(vm['node'], taskid):
|
2020-09-08 13:11:37 +02:00
|
|
|
module.fail_json(msg='Reached timeout while waiting for removing VM. Last line in task before timeout: %s' %
|
|
|
|
proxmox_node.tasks(taskid).log.get()[:1])
|
|
|
|
else:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=True, vmid=vmid, msg="VM %s removed" % vmid)
|
2020-03-09 10:11:07 +01:00
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg="deletion of VM %s failed with exception: %s" % (vmid, e))
|
|
|
|
|
|
|
|
elif state == 'current':
|
|
|
|
status = {}
|
2022-02-07 06:21:24 +01:00
|
|
|
if not vmid:
|
2020-09-05 00:51:54 +02:00
|
|
|
module.fail_json(msg='VM with name = %s does not exist in cluster' % name)
|
2022-02-07 06:21:24 +01:00
|
|
|
vm = proxmox.get_vm(vmid)
|
2021-02-17 21:25:05 +01:00
|
|
|
if not name:
|
2022-02-07 06:21:24 +01:00
|
|
|
name = vm['name']
|
|
|
|
current = proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).status.current.get()['status']
|
2020-09-05 00:51:54 +02:00
|
|
|
status['status'] = current
|
|
|
|
if status:
|
2021-02-15 08:27:43 +01:00
|
|
|
module.exit_json(changed=False, vmid=vmid, msg="VM %s with vmid = %s is %s" % (name, vmid, current), **status)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|