community.general.manageiq_tenant 模块 – 管理 ManageIQ 中的租户

注意

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

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

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

要在 playbook 中使用它,请指定:community.general.manageiq_tenant

概要

  • manageiq_tenant 模块支持在 ManageIQ 中添加、更新和删除租户。

要求

执行此模块的主机需要以下要求。

参数

参数

注释

description

字符串 / 必需

租户描述。

manageiq_connection

字典

ManageIQ 连接配置信息。

ca_cert

别名:ca_bundle_path

字符串

CA 捆绑文件或包含证书的目录的路径。

password

字符串

ManageIQ 密码。如果设置了 MIQ_PASSWORD 环境变量。否则,如果没有传递令牌,则为必填项。

token

字符串

ManageIQ 令牌。如果设置了 MIQ_TOKEN 环境变量。否则,如果没有传递用户名或密码,则为必填项。

url

字符串

ManageIQ 环境 URL。如果设置了 MIQ_URL 环境变量。否则,必须传递它。

username

字符串

ManageIQ 用户名。如果设置了 MIQ_USERNAME 环境变量。否则,如果没有传递令牌,则为必填项。

validate_certs

别名:verify_ssl

布尔值

是否应验证 HTTPS 请求的 SSL 证书。

选择

  • false

  • true ←(默认)

name

字符串 / 必需

租户名称。

parent

字符串

父租户的名称。如果未提供且未提供 parent_id,则使用根租户。

parent_id

整数

父租户的 ID。如果未提供,则使用根租户。

当提供 parent_id 时,其优先级高于 parent

quotas

字典

租户配额。

所有参数区分大小写。

有效属性为

  • cpu_allocated(整数):使用 null 删除配额。

  • mem_allocated(GB):使用 null 删除配额。

  • storage_allocated(GB):使用 null 删除配额。

  • vms_allocated(整数):使用 null 删除配额。

  • templates_allocated(整数):使用 null 删除配额。

默认值: {}

state

字符串

absent - 租户不应存在,present - 租户应存在。

选择

  • "absent"

  • "present" ←(默认)

属性

属性

支持

描述

check_mode

支持:

可以在 check_mode 中运行,并返回已更改状态预测,而无需修改目标。

diff_mode

支持:

在差异模式下,将返回有关已更改(或可能需要在 check_mode 中更改)的详细信息。

示例

- name: Update the root tenant in ManageIQ
  community.general.manageiq_tenant:
    name: 'My Company'
    description: 'My company name'
    manageiq_connection:
      url: 'http://127.0.0.1:3000'
      username: 'admin'
      password: 'smartvm'
      validate_certs: false  # only do this when you trust the network!

- name: Create a tenant in ManageIQ
  community.general.manageiq_tenant:
    name: 'Dep1'
    description: 'Manufacturing department'
    parent_id: 1
    manageiq_connection:
      url: 'http://127.0.0.1:3000'
      username: 'admin'
      password: 'smartvm'
      validate_certs: false  # only do this when you trust the network!

- name: Delete a tenant in ManageIQ
  community.general.manageiq_tenant:
    state: 'absent'
    name: 'Dep1'
    parent_id: 1
    manageiq_connection:
      url: 'http://127.0.0.1:3000'
      username: 'admin'
      password: 'smartvm'
      validate_certs: false  # only do this when you trust the network!

- name: Set tenant quota for cpu_allocated, mem_allocated, remove quota for vms_allocated
  community.general.manageiq_tenant:
    name: 'Dep1'
    parent_id: 1
    quotas:
      - cpu_allocated: 100
      - mem_allocated: 50
      - vms_allocated: null
    manageiq_connection:
      url: 'http://127.0.0.1:3000'
      username: 'admin'
      password: 'smartvm'
      validate_certs: false  # only do this when you trust the network!


- name: Delete a tenant in ManageIQ using a token
  community.general.manageiq_tenant:
    state: 'absent'
    name: 'Dep1'
    parent_id: 1
    manageiq_connection:
      url: 'http://127.0.0.1:3000'
      token: 'sometoken'
      validate_certs: false  # only do this when you trust the network!

返回值

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

描述

tenant

复杂

租户。

返回:成功

description

字符串

租户描述

返回:成功

id

整数

租户 ID

返回:成功

name

字符串

租户名称

返回:成功

parent_id

整数

父租户的 ID

返回:成功

quotas

列表 / 元素=字符串

租户配额列表

返回:成功

示例: {"cpu_allocated": 100, "mem_allocated": 50}

作者

  • Evert Mulder (@evertmulder)