community.general.one_vnet 模块 – 管理 OpenNebula 虚拟网络

注意

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

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

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

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

community.general 9.4.0 中的新增功能

概要

  • 管理 OpenNebula 中的虚拟网络。

要求

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

  • pyone

参数

参数

注释

api_password

别名:api_token

字符串

用于 XMLRPC 身份验证的密码或令牌。

如果未指定,则使用 ONE_PASSWORD 环境变量的值(如果有)。

api_url

别名:api_endpoint

字符串

XMLRPC 服务器的 ENDPOINT URL。

如果未指定,则使用 ONE_URL 环境变量的值(如果有)。

api_username

字符串

用于 XMLRPC 身份验证的用户名。

如果未指定,则使用 ONE_USERNAME 环境变量的值(如果有)。

id

整数

您要管理的网络的 id

如果未设置,则将使用给定的 name 创建一个新网络。

name

字符串

您要管理的网络的 name。如果不存在具有给定名称的网络,将创建该网络,否则将由此模块管理。

state

字符串

present - 用于管理网络的状态。

absent - 删除网络。

选择

  • "present" ← (默认)

  • "absent"

template

字符串

包含网络模板内容的字符串。

validate_certs

布尔值

是否验证 TLS/SSL 证书。

如果使用 PYTHONHTTPSVERIFY 环境变量,则忽略此参数。

选择

  • false

  • true ← (默认)

wait_timeout

整数

在超时之前等待达到所需状态的时间(以秒为单位)。

默认: 300

属性

属性

支持

描述

check_mode

支持: 部分

请注意,即使网络实际上不会更改,检查模式对于现有网络始终返回 changed=true

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

diff_mode

支持:

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

示例

- name: Make sure the network is present by ID
  community.general.one_vnet:
    id: 0
    state: present
  register: result

- name: Make sure the network is present by name
  community.general.one_vnet:
    name: opennebula-bridge
    state: present
  register: result

- name: Create a new or update an existing network
  community.general.one_vnet:
    name: bridge-network
    template: |
      VN_MAD  = "bridge"
      BRIDGE  = "br0"
      BRIDGE_TYPE  = "linux"
      AR=[
        TYPE  = "IP4",
        IP    = 192.0.2.50,
        SIZE  = "20"
      ]
      DNS     = 192.0.2.1
      GATEWAY = 192.0.2.1

- name: Delete the network by ID
  community.general.one_vnet:
    id: 0
    state: absent

返回值

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

描述

ar_pool

列表 / 元素=字符串

网络的 ar_pool 列表。

返回:state=present

示例: [{"ar_id": 0, "ip": "192.0.2.1", "mac": "6c:1e:46:01:cd:d1", "size": 20, "type": "IP4"}, {"allocated": 0, "ar_id": 1, "ip": "198.51.100.1", "mac": "5d:9b:c0:9e:f6:e5", "size": 20, "type": "IP4"}]

网桥

字符串

网络的网桥接口。

返回:state=present

示例: "br0"

bridge_type

字符串

网络的网桥类型。

返回:state=present

示例: "linux"

集群

列表 / 元素=字符串

网络的集群。

返回:state=present

示例: [0, 100]

group_id

整数

网络的分组 ID。

返回:state=present

示例: 1

group_name

字符串

网络的分组名称。

返回:state=present

示例: "one-users"

id

整数

网络 ID。

返回:state=present

示例: 153

name

字符串

网络名称。

返回:state=present

示例: "app1"

outer_vlan_id

整数

网络的外部 VLAN 标签。

返回:state=present

示例: 1000

owner_id

整数

网络的所有者 ID。

返回:state=present

示例: 143

owner_name

字符串

网络的所有者名称。

返回:state=present

示例: "ansible-test"

parent_network_id

整数

网络的父网络 ID。

返回:state=present

示例: 1

权限

字典

网络的权限。

返回:state=present

示例: {"group_a": 0, "group_m": 0, "group_u": 0, "other_a": 0, "other_m": 0, "other_u": 0, "owner_a": 0, "owner_m": 0, "owner_u": 1}

group_a

字符串

网络的分组 ADMIN 权限。

返回: 成功

示例: "0"

group_m

字符串

网络的分组 MANAGE 权限。

返回: 成功

示例: "0"

group_u

字符串

网络的分组 USAGE 权限。

返回: 成功

示例: "0"

other_a

字符串

网络的其他用户 ADMIN 权限

返回: 成功

示例: "0"

other_m

字符串

网络的其他用户 MANAGE 权限。

返回: 成功

示例: "0"

other_u

字符串

网络的其他用户 USAGE 权限。

返回: 成功

示例: "0"

owner_a

字符串

网络的所有者 ADMIN 权限。

返回: 成功

示例: "0"

owner_m

字符串

网络的所有者 MANAGE 权限。

返回: 成功

示例: "0"

owner_u

字符串

网络的所有者 USAGE 权限。

返回: 成功

示例: "1"

phydev

字符串

网络的物理设备 (NIC)。

返回:state=present

示例: "eth0"

template

字典

已解析的网络模板。

返回:state=present

示例: {"BRIDGE": "onebr.1000", "BRIDGE_TYPE": "linux", "DESCRIPTION": "sampletext", "PHYDEV": "eth0", "SECURITY_GROUPS": 0, "VLAN_ID": 1000, "VN_MAD": "802.1Q"}

user_id

整数

网络的用户名称。

返回:state=present

示例: 1

user_name

字符串

网络的用户 ID。

返回:state=present

示例: "oneadmin"

vlan_id

整数

网络的 VLAN 标签。

返回:state=present

示例: 1000

vn_mad

字符串

网络的 VN_MAD。

返回:state=present

示例: "bridge"

vrouters

列表 / 元素=字符串

网络的虚拟路由器 ID 列表。

返回:state=present

示例: [0, 1]

作者

  • Alexander Bakanovskii (@abakanovskii)