community.general.profitbricks 模块 – 创建、销毁、启动、停止和重启 ProfitBricks 虚拟机

注意

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

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

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

要在剧本中使用它,请指定:community.general.profitbricks

概要

  • 创建、销毁、更新、启动、停止和重启 ProfitBricks 虚拟机。创建虚拟机时,可以选择等待其运行后再返回。此模块依赖于 profitbricks >= 1.0.0

需求

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

  • profitbricks

参数

参数

注释

assign_public_ip

布尔值

这会将机器分配到公共 LAN。如果不存在具有公共互联网访问权限的 LAN,则会创建一个。

选项

  • false ← (默认)

  • true

auto_increment

布尔值

是否为创建的虚拟机名称递增一个数字。

选项

  • false

  • true ← (默认)

bus

字符串

卷的总线类型。

选项

  • "IDE"

  • "VIRTIO" ← (默认)

cores

整数

分配给虚拟机的 CPU 核心数。

默认值: 2

count

整数

要创建的虚拟机数量。

默认值: 1

cpu_family

字符串

分配给虚拟机的 CPU 系列类型。

选项

  • "AMD_OPTERON" ← (默认)

  • "INTEL_XEON"

datacenter

字符串

在此处配置此虚拟机的机房。

disk_type

字符串

要分配的磁盘类型。

选项

  • "SSD"

  • "HDD" ← (默认)

image

字符串

创建虚拟机的系统映像 ID,例如 a3eae284-a2fe-11e4-b187-5f1f641608c8。

image_password

字符串

为管理员用户设置的密码。

instance_ids

列表 / 元素=字符串

实例 ID 列表,目前仅在 state='absent' 时用于移除实例。

默认值: []

lan

整数

要将服务器添加到其中的 LAN 的 ID。

默认值: 1

location

字符串

机房位置。仅当您要创建机房时才使用,否则忽略此值。

选项

  • "us/las" ← (默认)

  • "de/fra"

  • "de/fkb"

name

字符串

虚拟机的名称。

ram

整数

分配给虚拟机的内存量。

默认值: 2048

remove_boot_volume

布尔值

移除您要销毁的虚拟机的 bootVolume。

选项

  • false

  • true ← (默认)

ssh_keys

列表 / 元素=字符串

允许访问虚拟机的公共 SSH 密钥。

默认值: []

state

字符串

创建或终止实例

可用的选项为:runningstoppedabsentpresent

默认值: "present"

subscription_password

字符串

ProfitBricks 密码。覆盖 PB_PASSWORD 环境变量。

subscription_user

字符串

ProfitBricks 用户名。覆盖 PB_SUBSCRIPTION_ID 环境变量。

volume_size

整数

引导卷的大小(以 GB 为单位)。

默认值: 10

wait

布尔值

等待实例处于“运行”状态后再返回

选项

  • false

  • true ← (默认)

wait_timeout

整数

wait 超时之前的时间(以秒为单位)

默认值: 600

属性

属性

支持

描述

check_mode

支持:不支持

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

diff_mode

支持:不支持

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

示例

# Note: These examples do not set authentication details, see the AWS Guide for details.

# Provisioning example
- name: Create three servers and enumerate their names
  community.general.profitbricks:
    datacenter: Tardis One
    name: web%02d.stackpointcloud.com
    cores: 4
    ram: 2048
    volume_size: 50
    cpu_family: INTEL_XEON
    image: a3eae284-a2fe-11e4-b187-5f1f641608c8
    location: us/las
    count: 3
    assign_public_ip: true

- name: Remove virtual machines
  community.general.profitbricks:
    datacenter: Tardis One
    instance_ids:
      - 'web001.stackpointcloud.com'
      - 'web002.stackpointcloud.com'
      - 'web003.stackpointcloud.com'
    wait_timeout: 500
    state: absent

- name: Start virtual machines
  community.general.profitbricks:
    datacenter: Tardis One
    instance_ids:
      - 'web001.stackpointcloud.com'
      - 'web002.stackpointcloud.com'
      - 'web003.stackpointcloud.com'
    wait_timeout: 500
    state: running

- name: Stop virtual machines
  community.general.profitbricks:
    datacenter: Tardis One
    instance_ids:
      - 'web001.stackpointcloud.com'
      - 'web002.stackpointcloud.com'
      - 'web003.stackpointcloud.com'
    wait_timeout: 500
    state: stopped

作者

  • Matt Baldwin (@baldwinSPC)