community.general.oneandone_server 模块 – 创建、销毁、启动、停止和重启 1&1 Host 服务器
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。
要在 playbook 中使用它,请指定:community.general.oneandone_server。
概要
- 创建、销毁、更新、启动、停止和重启 1&1 Host 服务器。创建服务器时,可以选择等待服务器运行后再返回。 
要求
以下要求是在执行此模块的主机上需要的。
- 1and1 
参数
| 参数 | 注释 | 
|---|---|
| 自定义 API URL。覆盖 ONEANDONE_API_URL 环境变量。 | |
| 服务器的操作系统名称或 ID。仅在状态为 'present' 时才需要。 | |
| 1&1 提供的 API 认证令牌。覆盖 ONEANDONE_AUTH_TOKEN 环境变量。 | |
| 一次创建多个服务器时,是否通过在主机名后附加计数来区分主机名,或者在主机名字符串中存在 %02d 或 %03d 时替换计数。 选项 
 | |
| 每个处理器的核心数。必须与 vcore、ram 和 hdds 参数一起提供。 | |
| 要创建的服务器数量。 默认值:  | |
| 数据中心位置。 选项 
 | |
| 服务器的描述。 | |
| 防火墙策略名称或 ID。 | |
| 服务器的实例大小名称或 ID。仅在 'present' 状态下需要,并且与 vcore、cores_per_processor、ram 和 hdds 参数互斥。 可用选项: | |
| 具有嵌套的“size”和“is_main”属性的硬盘列表。必须与 vcore、cores_per_processor 和 ram 参数一起提供。 | |
| 服务器的主机名或 ID。仅在状态为 'present' 时使用。 | |
| 负载均衡器名称或 ID。 | |
| 监控策略名称或 ID。 | |
| 专用网络名称或 ID。 | |
| RAM 内存量。必须与 vcore、cores_per_processor 和 hdds 参数一起提供。 | |
| 服务器标识符(ID 或主机名)。除“运行”和“present”状态外,所有状态都需要。 | |
| 要构建的服务器类型。 选项 
 | |
| 用户的公共 SSH 密钥(内容,而非路径)。 | |
| 定义服务器的状态以创建、删除、启动或停止它。 选项 
 | |
| 处理器总数。必须与cores_per_processor、ram和hdds参数一起提供。 | |
| 等待服务器进入“运行”状态后再返回。也用于删除操作(如果不想等待每个服务器删除完毕后再执行其他任务,则设置为“false”。) 选项 
 | |
| 使用wait_for方法时等待的秒数。 默认:  | |
| 等待超时时间(秒) 默认:  | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持: 完全支持 | 可以在 | |
| 支持: 不支持 | 在差异模式下,将返回有关已更改内容(或可能需要在 | 
示例
- name: Create three servers and enumerate their names
  community.general.oneandone_server:
    auth_token: oneandone_private_api_key
    hostname: node%02d
    fixed_instance_size: XL
    datacenter: US
    appliance: C5A349786169F140BCBC335675014C08
    auto_increment: true
    count: 3
- name: Create three servers, passing in an ssh_key
  community.general.oneandone_server:
    auth_token: oneandone_private_api_key
    hostname: node%02d
    vcore: 2
    cores_per_processor: 4
    ram: 8.0
    hdds:
      - size: 50
        is_main: false
    datacenter: ES
    appliance: C5A349786169F140BCBC335675014C08
    count: 3
    wait: true
    wait_timeout: 600
    wait_interval: 10
    ssh_key: SSH_PUBLIC_KEY
- name: Removing server
  community.general.oneandone_server:
    auth_token: oneandone_private_api_key
    state: absent
    server: 'node01'
- name: Starting server
  community.general.oneandone_server:
    auth_token: oneandone_private_api_key
    state: running
    server: 'node01'
- name: Stopping server
  community.general.oneandone_server:
    auth_token: oneandone_private_api_key
    state: stopped
    server: 'node01'
返回值
常见的返回值已在此处记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 关于每个已处理服务器的信息 返回:始终返回 示例:  | 
