vmware.vmware_rest.vcenter_resourcepool module – Manage vCenter resource pools.

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_resourcepool.

New in vmware.vmware_rest 5.0.0

Synopsis

  • Create, update, and delete VMware vCenter resource pools.

  • A resource pool is a logical abstraction for flexible management of CPU and memory resources within a cluster or host. Resource pools can be nested to create a hierarchy for fine-grained resource allocation.

  • Use this module to provision new resource pools, adjust CPU and memory allocations, or remove existing resource pools from the vCenter inventory.

Parameters

Parameter

Comments

cpu_allocation

dictionary

Resource allocation for CPU.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, use the default CPU allocation specification.

expandable_reservation

boolean

In a resource pool with an expandable reservation, the reservation can grow beyond the specified value, if the parent resource pool has unreserved resources. A non-expandable reservation is called a fixed reservation.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, *Vcenter.ResourcePool.ResourceAllocationCreateSpec.expandable_reservation* will be set to true.

Choices:

  • false

  • true

limit

integer

The utilization of a resource pool will not exceed this limit, even if there are available resources. This is typically used to ensure a consistent performance of resource pools independent of available resources. If set to -1, then there is no fixed limit on resource usage (only bounded by available resources and shares). Units are MB for memory, and MHz for CPU.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, *Vcenter.ResourcePool.ResourceAllocationCreateSpec.limit* will be set to -1.

reservation

integer

Amount of resource that is guaranteed available to a resource pool. Reserved resources are not wasted if they are not used. If the utilization is less than the reservation, the resources can be utilized by other running virtual machines. Units are MB for memory, and MHz for CPU.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, *Vcenter.ResourcePool.ResourceAllocationCreateSpec.reservation* will be set to 0.

shares

dictionary

Shares are used in case of resource contention.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, *Vcenter.ResourcePool.ResourceAllocationCreateSpec.shares* will be set to ‘*Vcenter.ResourcePool.SharesInfo.Level.NORMAL*’.

level

string / required

The allocation level. It maps to a pre-determined set of numeric values for shares. If the shares value does not map to a predefined size, then the level is set as CUSTOM.

LOW - For CPU Shares = 500 * number of virtual CPUs. For Memory Shares = 5 * virtual machine memory size in MB.

NORMAL - For CPU Shares = 1000 * number of virtual CPUs. For Memory Shares = 10 * virtual machine memory size in MB.

HIGH - For CPU Shares = 2000 * number of virtual CPUs. For Memory Shares = 20 * virtual machine memory size in MB.

CUSTOM - If set, in case there is resource contention the server uses the shares value to determine the resource allocation.

For more information see *Vcenter.ResourcePool.SharesInfo.Level*.

This property was added in __vSphere API 7.0.0.0__.

Choices:

  • "LOW"

  • "NORMAL"

  • "HIGH"

  • "CUSTOM"

shares

integer

When *Vcenter.ResourcePool.SharesInfo.level* is set to CUSTOM, it is the number of shares allocated. Otherwise, this value is ignored.

There is no unit for this value. It is a relative measure based on the settings for other resource pools.

This property was added in __vSphere API 7.0.0.0__.

This property is optional and it is only relevant when the value of level is *Vcenter.ResourcePool.SharesInfo.Level.CUSTOM*.

memory_allocation

dictionary

Resource allocation for memory.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, use the default memory allocation specification.

expandable_reservation

boolean

In a resource pool with an expandable reservation, the reservation can grow beyond the specified value, if the parent resource pool has unreserved resources. A non-expandable reservation is called a fixed reservation.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, *Vcenter.ResourcePool.ResourceAllocationCreateSpec.expandable_reservation* will be set to true.

Choices:

  • false

  • true

limit

integer

The utilization of a resource pool will not exceed this limit, even if there are available resources. This is typically used to ensure a consistent performance of resource pools independent of available resources. If set to -1, then there is no fixed limit on resource usage (only bounded by available resources and shares). Units are MB for memory, and MHz for CPU.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, *Vcenter.ResourcePool.ResourceAllocationCreateSpec.limit* will be set to -1.

reservation

integer

Amount of resource that is guaranteed available to a resource pool. Reserved resources are not wasted if they are not used. If the utilization is less than the reservation, the resources can be utilized by other running virtual machines. Units are MB for memory, and MHz for CPU.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, *Vcenter.ResourcePool.ResourceAllocationCreateSpec.reservation* will be set to 0.

shares

dictionary

Shares are used in case of resource contention.

This property was added in __vSphere API 7.0.0.0__.

If missing or ‘null’ or empty, *Vcenter.ResourcePool.ResourceAllocationCreateSpec.shares* will be set to ‘*Vcenter.ResourcePool.SharesInfo.Level.NORMAL*’.

level

string / required

The allocation level. It maps to a pre-determined set of numeric values for shares. If the shares value does not map to a predefined size, then the level is set as CUSTOM.

LOW - For CPU Shares = 500 * number of virtual CPUs. For Memory Shares = 5 * virtual machine memory size in MB.

NORMAL - For CPU Shares = 1000 * number of virtual CPUs. For Memory Shares = 10 * virtual machine memory size in MB.

HIGH - For CPU Shares = 2000 * number of virtual CPUs. For Memory Shares = 20 * virtual machine memory size in MB.

CUSTOM - If set, in case there is resource contention the server uses the shares value to determine the resource allocation.

For more information see *Vcenter.ResourcePool.SharesInfo.Level*.

This property was added in __vSphere API 7.0.0.0__.

Choices:

  • "LOW"

  • "NORMAL"

  • "HIGH"

  • "CUSTOM"

shares

integer

When *Vcenter.ResourcePool.SharesInfo.level* is set to CUSTOM, it is the number of shares allocated. Otherwise, this value is ignored.

There is no unit for this value. It is a relative measure based on the settings for other resource pools.

This property was added in __vSphere API 7.0.0.0__.

This property is optional and it is only relevant when the value of level is *Vcenter.ResourcePool.SharesInfo.Level.CUSTOM*.

name

string

Name of the resource pool.

This property was added in __vSphere API 7.0.0.0__.

parent

string

The parent resource pool under which to create this resource pool.

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

This property was added in __vSphere API 7.0.0.0__.

resource_pool

string

Identifier of the resource pool to manage.

Must be an identifier (MOID) for a ResourcePool resource.

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 create or update the resource.

Use absent to delete the resource.

Choices:

  • "present" ← (default)

  • "absent"

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)

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: Create a basic resource pool
  vmware.vmware_rest.vcenter_resourcepool:
    name: my_resource_pool
    parent: resgroup-1001
    state: present
  register: my_resource_pool

- name: Create a resource pool with CPU and memory limits
  vmware.vmware_rest.vcenter_resourcepool:
    name: limited_pool
    parent: resgroup-1001
    cpu_allocation:
      reservation: 2000
      limit: 8000
      expandable_reservation: false
      shares:
        level: CUSTOM
        shares: 4000
    memory_allocation:
      reservation: 1024
      limit: 4096
      expandable_reservation: true
      shares:
        level: HIGH
    state: present

- name: Update an existing resource pool
  vmware.vmware_rest.vcenter_resourcepool:
    resource_pool: '{{ my_resource_pool.id }}'
    name: renamed_pool
    cpu_allocation:
      limit: 16000
    state: present

- name: Delete a resource pool
  vmware.vmware_rest.vcenter_resourcepool:
    resource_pool: '{{ my_resource_pool.id }}'
    state: absent

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 resource pool.

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

Sample: "resgroup-1009"

value

any

The raw API response body from the vCenter operation.

Returned: On success

Sample: {"name": "my-resource-pool"}

Authors

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