community.vmware.vmware_content_library_manager 模块 – 创建、更新和删除 VMware 内容库

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.vmware。您需要更多要求才能使用此模块,请参阅 要求 以了解详细信息。

要在剧本中使用它,请指定:community.vmware.vmware_content_library_manager

概要

  • 用于管理 VMware 内容库的模块

  • 内容库功能是在 vSphere 6.0 版本中引入的,因此此模块不支持 vSphere 的早期版本。

要求

在执行此模块的主机上需要满足以下要求。

  • vSphere 自动化 SDK

参数

参数

注释

datastore_name

别名: datastore

字符串

用于创建支持内容库的数据存储的名称。

如果 state=present,则这是必需的。

state=absent 时,此参数将被忽略。

目前仅支持数据存储支持的创建。

hostname

字符串

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

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

library_description

字符串

内容库描述。

仅当 state=present 时,此项才是必需的。

state=absent 时,此参数将被忽略。

更新内容库的过程只允许更改描述。

library_name

字符串 / 必需

要管理的 VMware 内容库的名称。

library_type

字符串

内容库类型。

仅当 state=resent 时,此项才是必需的。

state=absent 时,此参数将被忽略。

选项

  • "local" ← (默认)

  • "subscribed"

password

别名:pass, pwd

字符串

vSphere vCenter 服务器的密码。

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

port

整数

vSphere vCenter 的端口号。

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

默认值: 443

protocol

字符串

连接的协议。

选项

  • "http"

  • "https" ← (默认)

proxy_host

字符串

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

格式是主机名或 IP。

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

proxy_port

整数

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

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

ssl_thumbprint

字符串

要订阅的订阅内容库的 SHA1 SSL 指纹。

如果 library_type=subscribed 且库是 https,则这是必需的。

state=absent 时,此参数将被忽略。

可以使用 openssl 提取信息,如下例所示: echo | openssl s_client -connect test-library.com:443 |& openssl x509 -fingerprint -noout

默认值: ""

state

字符串

内容库的状态。

如果设置为 present 且内容库不存在,则会创建内容库。

如果设置为 present 且内容库存在,则会更新内容库。

如果设置为 absent 且内容库存在,则会删除内容库。

如果设置为 absent 且内容库不存在,则不执行任何操作。

选项

  • "present" ← (默认)

  • "absent"

subscription_url

字符串

要订阅的内容库的 URL。

如果 library_type=subscribed,则这是必需的。

state=absent 时,此参数将被忽略。

默认值: ""

update_on_demand

布尔值

是否按需下载所有内容。

如果设置为 true,则将按需下载所有内容。

如果设置为 false,则将提前下载内容。

如果 library_type=subscribed,则这是必需的。

state=absent 时,此参数将被忽略。

选项

  • false ← (默认)

  • true

username

别名:admin, user

字符串

vSphere vCenter 服务器的用户名。

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

validate_certs

布尔值

允许在 SSL 证书无效时进行连接。

当证书不受信任时,设置为 false

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

选项

  • false

  • true ← (默认)

注意

注意

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

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

示例

- name: Create Local Content Library
  community.vmware.vmware_content_library_manager:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    library_name: test-content-lib
    library_description: 'Library with Datastore Backing'
    library_type: local
    datastore_name: datastore
    state: present
  delegate_to: localhost

- name: Create Subscribed Content Library
  community.vmware.vmware_content_library_manager:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    library_name: test-content-lib
    library_description: 'Subscribed Library with Datastore Backing'
    library_type: subscribed
    datastore_name: datastore
    subscription_url: 'https://library.url'
    ssl_thumbprint: 'aa:bb:cc:dd:ee:ff:gg:hh:ii:jj:kk:ll:mm:nn:oo:pp:qq:rr:ss:tt'
    update_on_demand: true
    state: present
  delegate_to: localhost

- name: Update Content Library
  community.vmware.vmware_content_library_manager:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    library_name: test-content-lib
    library_description: 'Library with Datastore Backing'
    state: present
  delegate_to: localhost

- name: Delete Content Library
  community.vmware.vmware_content_library_manager:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    library_name: test-content-lib
    state: absent
  delegate_to: localhost

返回值

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

描述

content_library_info

字典

库创建成功和库 ID

返回值:成功时

示例: {"library_description": "测试 描述", "library_id": "d0b92fa9-7039-4f29-8e9c-0debfcb22b72", "library_type": "LOCAL", "msg": "内容 'demo-local-lib-4' 已创建。"}

作者

  • Pavan Bidkar (@pgbidkar)