vmware.vmware_rest.vcenter_resourcepool module – Creates a resource pool.

Note

This module is part of the vmware.vmware_rest collection (version 2.2.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 version 0.3.0: of vmware.vmware_rest

Synopsis

  • Creates a resource pool.

Requirements

The below requirements are needed on the host that executes this module.

  • vSphere 7.0.2 or greater

  • python >= 3.6

  • aiohttp

Parameters

Parameter

Comments

cpu_allocation

dictionary

Resource allocation for CPU.

Valid attributes are:

  • reservation (int): 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 fo memory, and MHz for CPU. ([‘present’])

  • expandable_reservation (bool): 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. ([‘present’])

  • limit (int): 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. ([‘present’])

  • shares (dict): Shares are used in case of resource contention. ([‘present’])

    • Accepted keys:

      • level (string): The level defines the possible values for the allocation level.

Accepted value for this field:

  • CUSTOM

  • HIGH

  • LOW

  • NORMAL

  • shares (integer): When {@link #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.

memory_allocation

dictionary

Resource allocation for CPU.

Valid attributes are:

  • reservation (int): 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 fo memory, and MHz for CPU. ([‘present’])

  • expandable_reservation (bool): 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. ([‘present’])

  • limit (int): 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. ([‘present’])

  • shares (dict): Shares are used in case of resource contention. ([‘present’])

    • Accepted keys:

      • level (string): The level defines the possible values for the allocation level.

Accepted value for this field:

  • CUSTOM

  • HIGH

  • LOW

  • NORMAL

  • shares (integer): When {@link #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.

name

string

Name of the resource pool. Required with state=[‘present’]

parent

string

Parent of the created resource pool. Required with state=[‘present’]

resource_pool

string

Identifier of the resource pool to be deleted. Required with state=[‘absent’, ‘present’]

session_timeout

float

added in 2.1.0 of vmware.vmware_rest

Timeout settings for client session.

The maximal number of seconds for the whole operation including connection establishment, request sending and response.

The default value is 300s.

state

string

Choices:

  • absent

  • present ← (default)

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_rest_log_file

string

You can use this optional parameter to set the location of a log file.

This file will be used to record the HTTP REST interaction.

The file will be stored on the host that run the module.

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:

  • no

  • yes ← (default)

Notes

Note

  • Tested on vSphere 7.0.2

Examples

- name: Get the existing resource pools
  vmware.vmware_rest.vcenter_resourcepool_info:
  register: resource_pools

- name: Create an Ad hoc resource pool
  vmware.vmware_rest.vcenter_resourcepool:
    name: my_resource_pool
    parent: '{{ resource_pools.value[0].resource_pool }}'
    cpu_allocation:
      expandable_reservation: true
      limit: 40
      reservation: 0
      shares:
        level: NORMAL
    memory_allocation:
      expandable_reservation: false
      limit: 2000
      reservation: 0
      shares:
        level: NORMAL
  register: my_resource_pool

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

- name: Create a generic resource pool
  vmware.vmware_rest.vcenter_resourcepool:
    name: my_resource_pool
    parent: '{{ resource_pools.value[0].resource_pool }}'
  register: my_resource_pool

- name: Modify a resource pool
  vmware.vmware_rest.vcenter_resourcepool:
    resource_pool: '{{ my_resource_pool.id }}'
    cpu_allocation:
      expandable_reservation: true
      limit: -1
      reservation: 0
      shares:
        level: NORMAL
    memory_allocation:
      expandable_reservation: false
      limit: 1000
      reservation: 0
      shares:
        level: NORMAL

Return Values

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

Key

Description

id

string

moid of the resource

Returned: On success

Sample: “resgroup-1143”

value

dictionary

Create a generic resource pool

Returned: On success

Sample: {“cpu_allocation”: {“expandable_reservation”: 1, “limit”: -1, “reservation”: 0, “shares”: {“level”: “NORMAL”}}, “memory_allocation”: {“expandable_reservation”: 1, “limit”: -1, “reservation”: 0, “shares”: {“level”: “NORMAL”}}, “name”: “my_resource_pool”, “resource_pools”: []}

Authors

  • Ansible Cloud Team (@ansible-collections)