vmware.vmware_rest.vcenter_vm_hardware module – Manage the virtual hardware settings of a virtual machine.

Note

This module is part of the vmware.vmware_rest collection (version 5.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install vmware.vmware_rest.

To use it in a playbook, specify: vmware.vmware_rest.vcenter_vm_hardware.

New in vmware.vmware_rest 5.0.0

Synopsis

  • Update the virtual hardware configuration of a virtual machine, such as its virtual hardware (compatibility) version and the scheduled hardware upgrade policy.

  • Trigger an on-demand upgrade of the virtual hardware to a newer compatibility version.

  • The virtual machine is identified by its managed object identifier (MOID).

  • This module maps to the vCenter /vcenter/vm/{vm}/hardware REST API.

Parameters

Parameter

Comments

session_timeout

float

Timeout in seconds for the whole operation including connection establishment, request sending, and response.

Default: 300.0

state

string

The desired state of the resource.

Use present to update the virtual hardware settings.

Use upgrade to perform the virtual hardware upgrade action.

Only option present supports idempotence.

Choices:

  • "present" ← (default)

  • "upgrade"

upgrade_policy

string

Scheduled upgrade policy that controls when the virtual hardware is automatically upgraded.

If set to NEVER, the scheduled upgrade version is reset and left unset.

NEVER - Do not upgrade the virtual machine when it is powered on.

AFTER_CLEAN_SHUTDOWN - Run the scheduled upgrade when the virtual machine is powered on after a clean shutdown of the guest operating system.

ALWAYS - Run the scheduled upgrade when the virtual machine is powered on.

If not set, the value is left unchanged.

upgrade_version

string

Target hardware version to be used on the next scheduled virtual hardware upgrade.

If specified, this must be a newer virtual hardware version than the virtual machine’s current hardware version.

VMX_03 - Hardware version 3, first supported in ESXi 2.5.

VMX_04 - Hardware version 4, first supported in ESXi 3.0.

VMX_06 - Hardware version 6, first supported in WS 6.0.

VMX_07 - Hardware version 7, first supported in ESXi 4.0.

VMX_08 - Hardware version 8, first supported in ESXi 5.0.

VMX_09 - Hardware version 9, first supported in ESXi 5.1.

VMX_10 - Hardware version 10, first supported in ESXi 5.5.

VMX_11 - Hardware version 11, first supported in ESXi 6.0.

VMX_12 - Hardware version 12, first supported in Workstation 12.0.

VMX_13 - Hardware version 13, first supported in ESXi 6.5.

VMX_14 - Hardware version 14, first supported in ESXi 6.7. This value was added in vSphere API 6.7.

VMX_15 - Hardware version 15, first supported in ESXi 6.7 Update 2. This value was added in vSphere API 6.7.2.

VMX_16 - Hardware version 16, first supported in Workstation 15.0. This value was added in vSphere API 7.0.0.0.

VMX_17 - Hardware version 17, first supported in ESXi 7.0.0-0. This value was added in vSphere API 7.0.0.0.

VMX_18 - Hardware version 18, first supported in ESXi 7.0 U1. This value was added in vSphere API 7.0.1.0.

VMX_19 - Hardware version 19, first supported in ESXi 7.0 U2. This value was added in vSphere API 7.0.2.0.

VMX_20 - Hardware version 20, first supported in ESXi 8.0.0.1. This value was added in vSphere API 8.0.0.1.

VMX_21 - Hardware version 21, first supported in ESXi 8.0 U2. This value was added in vSphere API 8.0.2.0.

VMX_22 - Hardware version 22, first supported in ESXi 9.0. This value was added in vSphere API 9.0.0.0.

If upgrade_policy=NEVER, this property must not be set. Otherwise, if not set, it defaults to the most recent virtual hardware version supported by the server.

vcenter_hostname

string / required

The hostname or IP address of the vSphere vCenter.

If the value is not specified in the task, the value of environment variable VMWARE_HOST will be used instead.

vcenter_password

string / required

The vSphere vCenter password.

If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.

vcenter_port

integer

The port number of the vSphere vCenter.

If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.

vcenter_rest_log_file

string

Optional path to a log file for HTTP REST interaction.

If the value is not specified in the task, the value of environment variable VMWARE_REST_LOG_FILE will be used instead.

vcenter_username

string / required

The vSphere vCenter username.

If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.

vcenter_validate_certs

boolean

Allows connection when SSL certificates are not valid.

Set to false when certificates are not trusted.

If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.

Choices:

  • false

  • true ← (default)

version

string

Target virtual hardware (compatibility) version to upgrade the virtual machine to.

Only used when state=upgrade.

VMX_03 - Hardware version 3, first supported in ESXi 2.5.

VMX_04 - Hardware version 4, first supported in ESXi 3.0.

VMX_06 - Hardware version 6, first supported in WS 6.0.

VMX_07 - Hardware version 7, first supported in ESXi 4.0.

VMX_08 - Hardware version 8, first supported in ESXi 5.0.

VMX_09 - Hardware version 9, first supported in ESXi 5.1.

VMX_10 - Hardware version 10, first supported in ESXi 5.5.

VMX_11 - Hardware version 11, first supported in ESXi 6.0.

VMX_12 - Hardware version 12, first supported in Workstation 12.0.

VMX_13 - Hardware version 13, first supported in ESXi 6.5.

VMX_14 - Hardware version 14, first supported in ESXi 6.7. This value was added in vSphere API 6.7.

VMX_15 - Hardware version 15, first supported in ESXi 6.7 Update 2. This value was added in vSphere API 6.7.2.

VMX_16 - Hardware version 16, first supported in Workstation 15.0. This value was added in vSphere API 7.0.0.0.

VMX_17 - Hardware version 17, first supported in ESXi 7.0.0-0. This value was added in vSphere API 7.0.0.0.

VMX_18 - Hardware version 18, first supported in ESXi 7.0 U1. This value was added in vSphere API 7.0.1.0.

VMX_19 - Hardware version 19, first supported in ESXi 7.0 U2. This value was added in vSphere API 7.0.2.0.

VMX_20 - Hardware version 20, first supported in ESXi 8.0.0.1. This value was added in vSphere API 8.0.0.1.

VMX_21 - Hardware version 21, first supported in ESXi 8.0 U2. This value was added in vSphere API 8.0.2.0.

VMX_22 - Hardware version 22, first supported in ESXi 9.0. This value was added in vSphere API 9.0.0.0.

If not set, defaults to the most recent virtual hardware version supported by the server.

vm

string / required

Identifier of the virtual machine whose hardware is being managed.

Must be the managed object identifier (MOID) of an existing Vm resource.

Notes

Note

  • Generated from vSphere API spec 9.1.0.

  • Compatible with vSphere API 7.0.3.

  • Compatible with vSphere API 8.0.2.

Examples

- name: Schedule a hardware upgrade after a clean guest shutdown
  vmware.vmware_rest.vcenter_vm_hardware:
    vm: vm-1001
    upgrade_policy: AFTER_CLEAN_SHUTDOWN
    upgrade_version: VMX_21
    state: present

- name: Disable scheduled hardware upgrades
  vmware.vmware_rest.vcenter_vm_hardware:
    vm: vm-1001
    upgrade_policy: NEVER
    state: present

- name: Upgrade the virtual hardware to the latest version supported by the host
  vmware.vmware_rest.vcenter_vm_hardware:
    vm: vm-1001
    state: upgrade

- name: Upgrade the virtual hardware to a specific version
  vmware.vmware_rest.vcenter_vm_hardware:
    vm: vm-1001
    version: VMX_22
    state: upgrade

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

id

string

MOID of the managed virtual machine.

Returned: When state is present, or when a resource is deleted, or when state is set to a supported action.

Sample: "vm-1001"

value

any

The raw API response body from the vCenter operation.

Returned: On success

Sample: {"upgrade_policy": "NEVER", "upgrade_status": "READY", "version": "VMX_19"}

Authors

  • Ansible Eco Content Team (@eco-ansible-content)