hetzner.hcloud.subnetwork 模块 – 管理 Hetzner Cloud 上的云子网。
注意
此模块是 hetzner.hcloud 集合(版本 4.2.2)的一部分。
如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install hetzner.hcloud。您需要进一步的要求才能使用此模块,请参阅 要求 以了解详细信息。
要在 playbook 中使用它,请指定:hetzner.hcloud.subnetwork。
概要
- 在 Hetzner Cloud 上创建、更新和删除云子网。 
别名: hcloud_subnetwork
要求
执行此模块的主机需要满足以下要求。
- python-dateutil >= 2.7.5 
- requests >=2.20 
参数
| 参数 | 注释 | 
|---|---|
| Hetzner Cloud 的 API 端点。 您也可以使用  默认值:  | |
| Hetzner Cloud 的 API 令牌。 您也可以使用  | |
| 子网的 IP 范围。 | |
| Hetzner Cloud 网络的名称或 ID。 | |
| 网络区域的名称。 | |
| 子网的状态。 选择 
 | |
| 子网的类型。 选择 
 | |
| 您要与网络耦合的 vSwitch 的 ID。 如果 type == vswitch 则为必填项 | 
另请参阅
另请参阅
- Hetzner Cloud API 文档
- Hetzner Cloud API 的完整参考。 
示例
- name: Create a basic subnetwork
  hetzner.hcloud.subnetwork:
    network: my-network
    ip_range: 10.0.0.0/16
    network_zone: eu-central
    type: cloud
    state: present
- name: Create a basic subnetwork
  hetzner.hcloud.subnetwork:
    network: my-vswitch-network
    ip_range: 10.0.0.0/24
    network_zone: eu-central
    type: vswitch
    vswitch_id: 123
    state: present
- name: Ensure the subnetwork is absent (remove if needed)
  hetzner.hcloud.subnetwork:
    network: my-network
    ip_range: 10.0.0.0/8
    network_zone: eu-central
    type: cloud
    state: absent
返回值
常见的返回值记录在此处,以下是此模块独有的字段
| 键 | 描述 | 
|---|---|
| 网络的子网 返回: 总是 | |
| 子网的网关 返回: 总是 示例:  | |
| 网络的 IP 范围 返回: 总是 示例:  | |
| 网络的名称 返回: 总是 示例:  | |
| 网络区域的名称 返回: 总是 示例:  | |
| 子网的类型 返回: 总是 示例:  | |
| vswitch 的 ID,如果不是 vswitch 类型,则为 null 返回: 总是 示例:  | 
