community.general.proxmox_kvm (8.5.0) — module

Management of Qemu(KVM) Virtual Machines in Proxmox VE cluster

Authors: Abdoul Bah (@helldorado) <bahabdoul at gmail.com>

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Allows you to create/delete/stop Qemu(KVM) Virtual Machines in Proxmox VE cluster.

Since community.general 4.0.0 on, there are no more default values, see O(proxmox_default_behavior).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new VM with minimal options
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a VM from archive (backup)
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    archive: backup-storage:backup/vm/140/2023-03-08T06:41:23Z
    name: spynal
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new VM with minimal options and given vmid
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    vmid: 100
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new VM with two network interface options
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    net:
      net0: 'virtio,bridge=vmbr1,rate=200'
      net1: 'e1000,bridge=vmbr2'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new VM with one network interface, three virto hard disk, 4 cores, and 2 vcpus
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    net:
      net0: 'virtio,bridge=vmbr1,rate=200'
    virtio:
      virtio0: 'VMs_LVM:10'
      virtio1: 'VMs:2,format=qcow2'
      virtio2: 'VMs:5,format=raw'
    cores: 4
    vcpus: 2
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: >
    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
    format: qcow2
    timeout: 500
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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: false
    format: unspecified
    timeout: 500
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Clone VM with source vmid and target newid and raw format
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    clone: arbitrary_name
    vmid: 108
    newid: 152
    name: zavala
    node: sabrewulf
    storage: LVM_STO
    format: raw
    timeout: 300
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new VM and lock it for snapshot
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    lock: snapshot
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new VM and set protection to disable the remove VM and remove disk operations
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    protection: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Start VM
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    state: started
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Stop VM
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    state: stopped
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Stop VM with force
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    state: stopped
    force: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Restart VM
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    state: restarted
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert VM to template
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    state: template
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert VM to template (stop VM if running)
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    state: template
    force: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove VM
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get VM current state
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    state: current
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update VM configuration
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    cores: 8
    memory: 16384
    update: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update VM configuration (incl. unsafe options)
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    cores: 8
    memory: 16384
    net:
        net0: virtio,bridge=vmbr1
    update: true
    update_unsafe: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete QEMU parameters
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    delete: 'args,template,cpulimit'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Revert a pending change
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf
    revert: 'template,cpulimit'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Migrate VM on second node
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    name: spynal
    node: sabrewulf-2
    migrate: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add hookscript to existing VM
  community.general.proxmox_kvm:
    api_user: root@pam
    api_password: secret
    api_host: helldorado
    vmid: 999
    node: sabrewulf
    hookscript: local:snippets/hookscript.pl
    update: true

Inputs

    
cpu:
    description:
    - Specify emulated CPU type.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(kvm64).
    type: str

ide:
    description:
    - A hash/dictionary of volume used as IDE hard disk or CD-ROM. O(ide='{"key":"value",
      "key":"value"}').
    - "Keys allowed are - C(ide[n]) where 0 \u2264 n \u2264 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.
    - 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.
    type: dict

kvm:
    description:
    - Enable/disable KVM hardware virtualization.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(true).
    type: bool

net:
    description:
    - A hash/dictionary of network interfaces for the VM. O(net='{"key":"value", "key":"value"}').
    - "Keys allowed are - C(net[n]) where 0 \u2264 n \u2264 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.
    type: dict

tdf:
    description:
    - Enables/disables time drift fix.
    type: bool

vga:
    choices:
    - std
    - cirrus
    - vmware
    - qxl
    - serial0
    - serial1
    - serial2
    - serial3
    - qxl2
    - qxl3
    - qxl4
    description:
    - Select VGA type. If you want to use high resolution modes (>= 1280x1024x16) then
      you should use option 'std' or 'vmware'.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(std).
    type: str

acpi:
    description:
    - Specify if ACPI should be enabled/disabled.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(true).
    type: bool

args:
    description:
    - Pass arbitrary arguments to kvm.
    - This option is for experts only!
    - If O(proxmox_default_behavior) is set to V(compatibility), this option has a default
      of V(-serial unix:/var/run/qemu-server/<vmid>.serial,server,nowait).
    type: str

bios:
    choices:
    - seabios
    - ovmf
    description:
    - Specify the BIOS implementation.
    type: str

boot:
    description:
    - Specify the boot order -> boot on floppy V(a), hard disk V(c), CD-ROM V(d), or network
      V(n).
    - For newer versions of Proxmox VE, use a boot order like V(order=scsi0;net0;hostpci0).
    - You can combine to set order.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(cnd).
    type: str

full:
    default: true
    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

lock:
    choices:
    - migrate
    - backup
    - snapshot
    - rollback
    description:
    - Lock/unlock the VM.
    type: str

name:
    description:
    - Specifies the VM name. Name could be non-unique across the cluster.
    - Required only for O(state=present).
    - With O(state=present) if O(vmid) not provided and VM with name exists in the cluster
      then no changes will be made.
    type: str

node:
    description:
    - Proxmox VE node on which to operate.
    - Only required for O(state=present).
    - For every other states it will be autodiscovered.
    type: str

numa:
    description:
    - A hash/dictionaries of NUMA topology. O(numa='{"key":"value", "key":"value"}').
    - "Keys allowed are - C(numa[n]) where 0 \u2264 n \u2264 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.
    type: dict

pool:
    description:
    - Add the new VM to the specified pool.
    type: str

sata:
    description:
    - A hash/dictionary of volume used as sata hard disk or CD-ROM. O(sata='{"key":"value",
      "key":"value"}').
    - "Keys allowed are - C(sata[n]) where 0 \u2264 n \u2264 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.
    - 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.
    type: dict

scsi:
    description:
    - A hash/dictionary of volume used as SCSI hard disk or CD-ROM. O(scsi='{"key":"value",
      "key":"value"}').
    - "Keys allowed are - C(scsi[n]) where 0 \u2264 n \u2264 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.
    - 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.
    type: dict

tags:
    description:
    - List of tags to apply to the VM instance.
    - Tags must start with V([a-z0-9_]) followed by zero or more of the following characters
      V([a-z0-9_-+.]).
    - Tags are only available in Proxmox 6+.
    elements: str
    type: list
    version_added: 2.3.0
    version_added_collection: community.general

vmid:
    description:
    - Specifies the instance ID.
    - If not set the next available ID will be fetched from ProxmoxAPI.
    type: int

agent:
    description:
    - Specify if the QEMU Guest Agent should be enabled/disabled.
    - Since community.general 5.5.0, this can also be a string instead of a boolean. This
      allows to specify values such as V(enabled=1,fstrim_cloned_disks=1).
    type: str

clone:
    description:
    - Name of VM to be cloned. If O(vmid) is set, O(clone) can take an arbitrary value
      but is required for initiating the clone.
    type: str

cores:
    description:
    - Specify number of cores per socket.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(1).
    type: int

force:
    description:
    - Allow to force stop VM.
    - Can be used with states V(stopped), V(restarted), and V(absent).
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(false).
    type: bool

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.
    type: int

state:
    choices:
    - present
    - started
    - absent
    - stopped
    - restarted
    - current
    - template
    default: present
    description:
    - Indicates desired state of the instance.
    - If V(current), the current state of the VM will be fetched. You can access it with
      C(results.status)
    - V(template) was added in community.general 8.1.0.
    type: str

vcpus:
    description:
    - Sets number of hotplugged vcpus.
    type: int

citype:
    choices:
    - nocloud
    - configdrive2
    description:
    - 'cloud-init: Specifies the cloud-init configuration format.'
    - The default depends on the configured operating system type (V(ostype)).
    - We use the V(nocloud) format for Linux, and V(configdrive2) for Windows.
    type: str
    version_added: 1.3.0
    version_added_collection: community.general

ciuser:
    description:
    - 'cloud-init: username of default user to create.'
    type: str
    version_added: 1.3.0
    version_added_collection: community.general

delete:
    description:
    - Specify a list of settings you want to delete.
    type: str

digest:
    description:
    - Specify if to prevent changes if current configuration file has different SHA1 digest.
    - This can be used to prevent concurrent modifications.
    type: str

format:
    choices:
    - cloop
    - cow
    - qcow
    - qcow2
    - qed
    - raw
    - vmdk
    - unspecified
    description:
    - Target drive's backing file's data format.
    - Used only with clone
    - Use O(format=unspecified) and O(full=false) for a linked clone.
    - 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.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(qcow2). If O(proxmox_default_behavior) is set to V(no_defaults),
      not specifying this option is equivalent to setting it to V(unspecified).
    type: str

freeze:
    description:
    - Specify if PVE should freeze CPU at startup (use 'c' monitor command to start execution).
    type: bool

memory:
    description:
    - Memory size in MB for instance.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(512).
    type: int

onboot:
    description:
    - Specifies whether a VM will be started during system bootup.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(true).
    type: bool

ostype:
    choices:
    - other
    - wxp
    - w2k
    - w2k3
    - w2k8
    - wvista
    - win7
    - win8
    - win10
    - win11
    - l24
    - l26
    - solaris
    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.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(l26).
    type: str

reboot:
    description:
    - Allow reboot. If set to V(true), the VM exit on reboot.
    type: bool

revert:
    description:
    - Revert a pending change.
    type: str

scsihw:
    choices:
    - lsi
    - lsi53c810
    - virtio-scsi-pci
    - virtio-scsi-single
    - megasas
    - pvscsi
    description:
    - Specifies the SCSI controller model.
    type: str

serial:
    description:
    - A hash/dictionary of serial device to create inside the VM. V('{"key":"value", "key":"value"}').
    - "Keys allowed are - serial[n](str; required) where 0 \u2264 n \u2264 3."
    - Values allowed are - V((/dev/.+|socket\)).
    - /!\ If you pass through a host serial device, it is no longer possible to migrate
      such machines - use with special care.
    type: dict

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.
    type: int

smbios:
    description:
    - Specifies SMBIOS type 1 fields.
    - 'Comma separated, Base64 encoded (optional) SMBIOS properties:'
    - V([base64=<1|0>] [,family=<Base64 encoded string>])
    - V([,manufacturer=<Base64 encoded string>])
    - V([,product=<Base64 encoded string>])
    - V([,serial=<Base64 encoded string>])
    - V([,sku=<Base64 encoded string>])
    - V([,uuid=<UUID>])
    - V([,version=<Base64 encoded string>])
    type: str

tablet:
    description:
    - Enables/disables the USB tablet device.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(false).
    type: bool

target:
    description:
    - Target node. Only allowed if the original VM is on shared storage.
    - Used only with clone
    type: str

update:
    default: false
    description:
    - If V(true), the VM will be updated with new value.
    - Because of the operations of the API and security reasons, I have disabled the update
      of the following parameters O(net), O(virtio), O(ide), O(sata), O(scsi). Per example
      updating O(net) update the MAC address and C(virtio) create always new disk... This
      security feature can be disabled by setting the O(update_unsafe) to V(true).
    - Update of O(pool) is disabled. It needs an additional API endpoint not covered by
      this module.
    type: bool

virtio:
    description:
    - A hash/dictionary of volume used as VIRTIO hard disk. O(virtio='{"key":"value",
      "key":"value"}').
    - "Keys allowed are - C(virtio[n]) where 0 \u2264 n \u2264 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.
    - 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.
    type: dict

archive:
    description:
    - Specify a path to an archive to restore (instead of creating or cloning a VM).
    type: str
    version_added: 6.5.0
    version_added_collection: community.general

balloon:
    description:
    - Specify the amount of RAM for the VM in MB.
    - Using zero disables the balloon driver.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(0).
    type: int

hostpci:
    description:
    - Specify a hash/dictionary of map host pci devices into guest. O(hostpci='{"key":"value",
      "key":"value"}').
    - "Keys allowed are - C(hostpci[n]) where 0 \u2264 n \u2264 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) C(default=0) Choose the PCI-express bus (needs the q35 machine model).
    - C(rombar=boolean) C(default=1) Specify whether or not the device's ROM will be visible
      in the guest's memory map.
    - C(x-vga=boolean) C(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.
    type: dict

hotplug:
    description:
    - Selectively enable hotplug features.
    - This is a comma separated list of hotplug features V(network), V(disk), V(cpu),
      V(memory), and V(usb).
    - Value 0 disables hotplug completely and value 1 is an alias for the default V(network,disk,usb).
    type: str

machine:
    description:
    - Specifies the Qemu machine type.
    - Type => V((pc|pc(-i440fx\)?-\\d+\\.\\d+(\\.pxe\)?|q35|pc-q35-\\d+\\.\\d+(\\.pxe\)?\)).
    type: str

migrate:
    default: false
    description:
    - Migrate the VM to O(node) if it is on another node.
    type: bool
    version_added: 7.0.0
    version_added_collection: community.general

sockets:
    description:
    - Sets the number of CPU sockets. (1 - N).
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(1).
    type: int

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
    version_added_collection: community.general

startup:
    description:
    - Startup and shutdown behavior. V([[order=]\\d+] [,up=\\d+] [,down=\\d+]).
    - Order is a non-negative number defining the general startup order.
    - Shutdown in done with reverse ordering.
    type: str

storage:
    description:
    - Target storage for full clone.
    type: str

timeout:
    default: 30
    description:
    - Timeout for operations.
    - When used with O(state=stopped) the option sets a graceful timeout for VM stop after
      which a VM will be forcefully stopped.
    type: int

api_host:
    description:
    - Specify the target host of the Proxmox VE cluster.
    required: true
    type: str

api_user:
    description:
    - Specify the user to authenticate with.
    required: true
    type: str

bootdisk:
    description:
    - Enable booting from specified disk. Format V((ide|sata|scsi|virtio\)\\d+).
    type: str

cicustom:
    description:
    - 'cloud-init: Specify custom files to replace the automatically generated ones at
      start.'
    type: str
    version_added: 1.3.0
    version_added_collection: community.general

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
    type: int

cpuunits:
    description:
    - Specify CPU weight for a VM.
    - You can disable fair-scheduler configuration by setting this to 0
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(1000).
    type: int

efidisk0:
    description:
    - Specify a hash/dictionary of EFI disk options.
    - Requires O(bios=ovmf) to be set to be able to use it.
    suboptions:
      efitype:
        choices:
        - 2m
        - 4m
        description:
        - V(efitype) indicates the size of the EFI disk.
        - V(2m) will allow for a 2MB EFI disk, which will be enough to persist boot order
          and new boot entries.
        - V(4m) will allow for a 4MB EFI disk, which will additionally allow to store
          EFI keys in order to enable Secure Boot
        type: str
      format:
        description:
        - V(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
      pre_enrolled_keys:
        description:
        - V(pre_enrolled_keys) indicates whether EFI keys for Secure Boot should be enrolled
          V(1) in the VM firmware upon creation or not (0).
        - If set to V(1), Secure Boot will also be enabled by default when the VM is created.
        type: bool
      storage:
        description:
        - V(storage) is the storage identifier where to create the disk.
        type: str
    type: dict
    version_added: 4.5.0
    version_added_collection: community.general

ipconfig:
    description:
    - 'cloud-init: Set the IP configuration.'
    - A hash/dictionary of network ip configurations. O(ipconfig='{"key":"value", "key":"value"}').
    - "Keys allowed are - C(ipconfig[n]) where 0 \u2264 n \u2264 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
    version_added_collection: community.general

keyboard:
    description:
    - Sets the keyboard layout for VNC server.
    type: str

parallel:
    description:
    - A hash/dictionary of map host parallel devices. O(parallel='{"key":"value", "key":"value"}').
    - "Keys allowed are - (parallel[n]) where 0 \u2264 n \u2264 2."
    - Values allowed are - C("/dev/parport\d+|/dev/usb/lp\d+").
    type: dict

skiplock:
    description:
    - Ignore locks
    - Only root is allowed to use this option.
    type: bool

snapname:
    description:
    - The name of the snapshot. Used only with clone.
    type: str

template:
    description:
    - Enables/disables the template.
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(false).
    type: bool

watchdog:
    description:
    - Creates a virtual hardware watchdog device.
    type: str

autostart:
    description:
    - Specify if the VM should be automatically restarted after crash (currently ignored
      in PVE API).
    - This option has no default unless O(proxmox_default_behavior) is set to V(compatibility);
      then the default is V(false).
    type: bool

hugepages:
    choices:
    - any
    - '2'
    - '1024'
    description:
    - Enable/disable hugepages memory.
    type: str

localtime:
    description:
    - Sets the real time clock to local time.
    - This is enabled by default if ostype indicates a Microsoft OS.
    type: bool

startdate:
    description:
    - Sets the initial date of the real time clock.
    - Valid format for date are V('now') or V('2016-09-25T16:01:21') or V('2016-09-25').
    type: str

tpmstate0:
    description:
    - A hash/dictionary of options for the Trusted Platform Module disk.
    - A TPM state disk is required for Windows 11 installations.
    suboptions:
      storage:
        description:
        - O(tpmstate0.storage) is the storage identifier where to create the disk.
        required: true
        type: str
      version:
        choices:
        - '1.2'
        - '2.0'
        default: '2.0'
        description:
        - The TPM version to use.
        type: str
    type: dict
    version_added: 7.1.0
    version_added_collection: community.general

cipassword:
    description:
    - 'cloud-init: password of default user to create.'
    type: str
    version_added: 1.3.0
    version_added_collection: community.general

hookscript:
    description:
    - Script that will be executed during various steps in the containers lifetime.
    type: str
    version_added: 8.1.0
    version_added_collection: community.general

protection:
    description:
    - Enable/disable the protection flag of the VM. This will enable/disable the remove
      VM and remove disk operations.
    type: bool

description:
    description:
    - Specify the description for the VM. Only used on the configuration web interface.
    - This is saved as comment inside the configuration file.
    type: str

nameservers:
    description:
    - 'cloud-init: DNS server IP address(es).'
    - If unset, PVE host settings are used.
    elements: str
    type: list
    version_added: 1.3.0
    version_added_collection: community.general

api_password:
    description:
    - Specify the password to authenticate with.
    - You can use E(PROXMOX_PASSWORD) environment variable.
    type: str

api_token_id:
    description:
    - Specify the token ID.
    - Requires C(proxmoxer>=1.1.0) to work.
    type: str
    version_added: 1.3.0
    version_added_collection: community.general

numa_enabled:
    description:
    - Enables NUMA.
    type: bool

migrate_speed:
    description:
    - Sets maximum speed (in MB/s) for migrations.
    - A value of 0 is no limit.
    type: int

searchdomains:
    description:
    - 'cloud-init: Sets DNS search domain(s).'
    - If unset, PVE host settings are used.
    elements: str
    type: list
    version_added: 1.3.0
    version_added_collection: community.general

update_unsafe:
    default: false
    description:
    - If V(true), do not enforce limitations on parameters O(net), O(virtio), O(ide),
      O(sata), O(scsi), O(efidisk0), and O(tpmstate0). Use this option with caution because
      an improper configuration might result in a permanent loss of data (e.g. disk recreated).
    type: bool
    version_added: 8.4.0
    version_added_collection: community.general

validate_certs:
    default: false
    description:
    - If V(false), SSL certificates will not be validated.
    - This should only be used on personally controlled sites using self-signed certificates.
    type: bool

api_token_secret:
    description:
    - Specify the token secret.
    - Requires C(proxmoxer>=1.1.0) to work.
    type: str
    version_added: 1.3.0
    version_added_collection: community.general

migrate_downtime:
    description:
    - Sets maximum tolerated downtime (in seconds) for migrations.
    type: int

proxmox_default_behavior:
    choices:
    - compatibility
    - no_defaults
    default: no_defaults
    description:
    - 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 V(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
      V(no_defaults), which makes sure these options have no defaults. - This affects
      the O(acpi), O(autostart), O(balloon), O(boot), O(cores), O(cpu), O(cpuunits), O(force),
      O(format), O(kvm), O(memory), O(onboot), O(ostype), O(sockets), O(tablet), O(template),
      and O(vga) options. - This option is deprecated and will be removed in community.general
      10.0.0.
    type: str
    version_added: 1.3.0
    version_added_collection: community.general

Outputs

msg:
  description: A short message
  returned: always
  sample: VM kropta with vmid = 110 is running
  type: str
status:
  description: The current virtual machine status.
  returned: success, not clone, not absent, not update
  sample: running
  type: str
vmid:
  description: The VM vmid.
  returned: success
  sample: 115
  type: int

See also