community.vmware.vmware_resource_pool 模块 – 向 vCenter 添加/删除资源池

注意

此模块是 community.vmware 集合 (版本 5.2.0) 的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.vmware

要在 playbook 中使用它,请指定:community.vmware.vmware_resource_pool

概要

  • 此模块可用于向/从 vCenter 添加/删除资源池

参数

参数

注释

集群

字符串

要配置资源池的集群名称。

如果未指定 esxi_hostnameparent_resource_pool,则此参数是必需的。

clusteresxi_hostnameparent_resource_pool 参数是互斥的。

cpu_allocation_shares

整数

分配的 CPU 份额数。

仅当 cpu_shares=custom 时才设置此值。

默认值: 4000

cpu_expandable_reservations

布尔值

在具有可扩展预留的资源池中,资源池的预留可以超出指定值。

选择

  • false

  • true ←(默认值)

cpu_limit

整数

即使有可用资源,虚拟机/资源池的利用率也不会超过此限制。

默认值 -1 表示无限制。

默认值: -1

cpu_reservation

整数

保证虚拟机或资源池可用的资源量。

默认值: 0

cpu_shares

字符串

在资源争用时使用内存份额。

选择

  • “高”

  • “自定义”

  • “低”

  • “正常” ←(默认值)

数据中心

字符串 / 必需

数据中心的名称。

esxi_hostname

字符串

要配置资源池的主机名称。

主机不得是集群的成员。

如果未指定 clusterparent_resource_pool,则此参数是必需的。

clusteresxi_hostnameparent_resource_pool 参数是互斥的。

主机名

字符串

vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。

如果任务中未指定该值,则将改为使用环境变量 VMWARE_HOST 的值。

mem_allocation_shares

整数

分配的内存份额数。

仅当 mem_shares=custom 时才设置此值。

默认值: 163840

mem_expandable_reservations

布尔值

在具有可扩展预留的资源池中,资源池的预留可以超出指定值。

选择

  • false

  • true ←(默认值)

mem_limit

整数

即使有可用资源,虚拟机/资源池的利用率也不会超过此限制。

默认值 -1 表示无限制。

默认值: -1

mem_reservation

整数

保证虚拟机或资源池可用的资源量。

默认值: 0

mem_shares

字符串

在资源争用时使用内存份额。

选择

  • “高”

  • “自定义”

  • “低”

  • “正常” ←(默认值)

parent_resource_pool

字符串

父资源池的名称。

如果未指定 clusteresxi_hostname,则此参数是必需的。

clusteresxi_hostnameparent_resource_pool 参数是互斥的。

密码

别名:pass, pwd

字符串

vSphere vCenter 或 ESXi 服务器的密码。

如果任务中未指定该值,则将改为使用环境变量 VMWARE_PASSWORD 的值。

端口

整数

vSphere vCenter 或 ESXi 服务器的端口号。

如果任务中未指定该值,则将使用环境变量 VMWARE_PORT 的值。

默认值: 443

proxy_host

字符串

将接收所有 HTTPS 请求并转发它们的代理地址。

格式为主机名或 IP 地址。

如果任务中未指定该值,则将使用环境变量 VMWARE_PROXY_HOST 的值。

proxy_port

整数

将接收所有 HTTPS 请求并转发它们的 HTTP 代理端口。

如果任务中未指定该值,则将使用环境变量 VMWARE_PROXY_PORT 的值。

resource_pool

字符串 / 必需

要管理的资源池名称。

state

字符串

添加或删除资源池

选择

  • "present" ← (默认)

  • "absent"

username

别名: admin, user

字符串

vSphere vCenter 或 ESXi 服务器的用户名。

如果任务中未指定该值,则将使用环境变量 VMWARE_USER 的值。

validate_certs

布尔值

允许在 SSL 证书无效时进行连接。当证书不受信任时,设置为 false

如果任务中未指定该值,则将使用环境变量 VMWARE_VALIDATE_CERTS 的值。

选择

  • false

  • true ←(默认值)

注释

注意

  • 所有模块都需要 API 写入权限,因此不支持免费的 ESXi 许可证。

  • 所有变量和 VMware 对象名称都区分大小写。

示例

- name: Add resource pool to vCenter
  community.vmware.vmware_resource_pool:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: '{{ datacenter_name }}'
    cluster: '{{ cluster_name }}'
    resource_pool: '{{ resource_pool_name }}'
    mem_shares: normal
    mem_limit: -1
    mem_reservation: 0
    mem_expandable_reservations: true
    cpu_shares: normal
    cpu_limit: -1
    cpu_reservation: 0
    cpu_expandable_reservations: true
    state: present
  delegate_to: localhost

返回值

通用返回值记录在此处,以下是此模块特有的字段

描述

instance

字典

关于新资源池的元数据

返回: 总是

示例: "None"

resource_pool_config

字典

关于资源池的配置数据,版本 1.4.0 添加

返回: 总是

示例: {"_vimtype": "vim.ResourceConfigSpec", "changeVersion": null, "cpuAllocation": {"_vimtype": "vim.ResourceAllocationInfo", "expandableReservation": true, "limit": -1, "overheadLimit": null, "reservation": 0, "shares": {"_vimtype": "vim.SharesInfo", "level": "normal", "shares": 4000}}, "entity": "vim.ResourcePool:resgroup-1108", "lastModified": null, "memoryAllocation": {"_vimtype": "vim.ResourceAllocationInfo", "expandableReservation": true, "limit": -1, "overheadLimit": null, "reservation": 0, "shares": {"_vimtype": "vim.SharesInfo", "level": "high", "shares": 327680}}, "name": "test_pr1", "scaleDescendantsShares": null}

作者

  • Davis Phillips (@dav1x)