hetzner.hcloud.volume 模块 – 在 Hetzner Cloud 上创建和管理块卷。
注意
此模块是 hetzner.hcloud 集合 (版本 4.2.2) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install hetzner.hcloud。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。
要在 playbook 中使用它,请指定:hetzner.hcloud.volume。
概要
- 在 Hetzner Cloud 上创建、更新和附加/分离块卷。 
别名:hcloud_volume
要求
执行此模块的主机需要以下要求。
- python-dateutil >= 2.7.5 
- requests >=2.20 
参数
| 参数 | 注释 | 
|---|---|
| Hetzner Cloud 的 API 端点。 您还可以使用  默认值:  | |
| Hetzner Cloud 的 API 令牌。 您还可以使用  | |
| 自动挂载卷。 选项 
 | |
| 保护卷不被删除。 选项 
 | |
| 创建时自动格式化卷 仅当卷不存在时才能使用。 选项 
 | |
| 要管理的 Hetzner Cloud 块卷的 ID。 如果没有给出卷 *name*,则需要。 | |
| 用户定义的键值对。 | |
| Hetzner Cloud 卷的位置。 如果没有给出 *server* 且卷不存在,则需要。 | |
| 要管理的 Hetzner Cloud 块卷的名称。 如果没有给出卷 *id* 或卷不存在,则需要。 | |
| 应将卷分配到的服务器名称。 如果没有给出 *location* 且卷不存在,则需要。 | |
| 块卷的大小(以 GB 为单位)。 如果卷尚不存在,则需要。 | |
| 卷的状态。 选项 
 | 
另请参见
另请参见
- Hetzner Cloud API 文档
- Hetzner Cloud API 的完整参考。 
示例
- name: Create a Volume
  hetzner.hcloud.volume:
    name: my-volume
    location: fsn1
    size: 100
    state: present
- name: Create a Volume and format it with ext4
  hetzner.hcloud.volume:
    name: my-volume
    location: fsn
    format: ext4
    size: 100
    state: present
- name: Mount a existing Volume and automount
  hetzner.hcloud.volume:
    name: my-volume
    server: my-server
    automount: true
    state: present
- name: Mount a existing Volume and automount
  hetzner.hcloud.volume:
    name: my-volume
    server: my-server
    automount: true
    state: present
- name: Ensure the Volume is absent (remove if needed)
  hetzner.hcloud.volume:
    name: my-volume
    state: absent
返回值
常用的返回值已在此处记录 此处,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 块卷 返回:始终 | |
| 如果卷受保护不被删除,则为 True 返回:始终 示例:  | |
| 卷的 ID 返回:始终 示例:  | |
| 用户定义的标签(键值对) 返回:始终 示例:  | |
| 包含卷的设备的路径。 返回:始终 示例:  | |
| 卷所在的位置名称 返回:始终 示例:  | |
| 卷的名称 返回:始终 示例:  | |
| 卷附加到的服务器名称 返回:始终 示例:  | |
| 卷的大小(以 GB 为单位) 返回:始终 示例:  | 
