community.vmware.vmware_category 模块 – 管理 VMware 类别
注意
此模块是 community.vmware 集合(版本 5.2.0)的一部分。
如果您使用的是 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.vmware。您需要进一步的要求才能使用此模块,请参阅要求了解详细信息。
要在 Playbook 中使用它,请指定:community.vmware.vmware_category。
概要
- 此模块可用于创建/删除/更新 VMware 类别。 
- 标记功能在 vSphere 6 版本中引入,因此此模块不支持 vSphere 的早期版本。 
要求
执行此模块的主机需要满足以下要求。
- vSphere 自动化 SDK 
参数
| 参数 | 注释 | 
|---|---|
| 可以与给定类别关联的对象类型列表。 选项 
 | |
| 类别基数。 更新现有类别时,将忽略此参数。 
 
 选项 
 | |
| 要管理的类别的名称。 | |
| vSphere vCenter 服务器的主机名或 IP 地址。 如果未在任务中指定该值,则将改用环境变量  | |
| 现有类别的新名称。 此值在更新现有类别时使用。 | |
| vSphere vCenter 服务器的密码。 如果任务中未指定该值,则将使用环境变量  | |
| 连接协议。 选项 
 | |
| 接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。 如果任务中未指定该值,则将使用环境变量  | |
| 类别的状态。 如果设置为  如果设置为  如果设置为  如果设置为  更新类别的过程仅允许更改名称和描述。 选项 
 | |
| vSphere vCenter 服务器的用户名。 如果任务中未指定该值,则将使用环境变量  | |
| 允许在 SSL 证书无效时进行连接。 当证书不受信任时,设置为  如果任务中未指定该值,则将使用环境变量  选项 
 | 
备注
注意
- 所有模块都需要 API 写入权限,因此在免费的 ESXi 许可证上不受支持。 
- 所有变量和 VMware 对象名称都区分大小写。 
示例
- name: Create a category
  community.vmware.vmware_category:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    category_name: Sample_Cat_0001
    category_description: Sample Description
    category_cardinality: 'multiple'
    state: present
- name: Rename category
  community.vmware.vmware_category:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    category_name: Sample_Category_0001
    new_category_name: Sample_Category_0002
    state: present
- name: Update category description
  community.vmware.vmware_category:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    category_name: Sample_Category_0001
    category_description: Some fancy description
    state: present
- name: Delete category
  community.vmware.vmware_category:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    category_name: Sample_Category_0002
    state: absent
- name: Create category with 2 associable object types
  community.vmware.vmware_category:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    category_name: 'Sample_Category_0003'
    category_description: 'sample description'
    associable_object_types:
    - Datastore
    - Cluster
    state: present
返回值
通用返回值记录在此处:此处,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 类别元数据字典 返回: 成功时 示例:  | 
