community.digitalocean.digital_ocean_droplet_info 模块 – 收集 DigitalOcean Droplet 的信息

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.digitalocean

要在 playbook 中使用它,请指定:community.digitalocean.digital_ocean_droplet_info

community.digitalocean 1.4.0 中的新功能

概要

  • 此模块可用于收集有关 Droplet 的信息。

参数

参数

注释

baseurl

字符串

DigitalOcean API 基本 URL。

默认值: "https://api.digitalocean.com/v2"

id

字符串

可用于识别和引用 droplet 的 Droplet ID。

name

字符串

可用于识别和引用 droplet 的 Droplet 名称。

oauth_token

别名:api_token

字符串

DigitalOcean OAuth 令牌。

还有几个其他环境变量可用于提供此值。

例如,- DO_API_TOKENDO_API_KEYDO_OAUTH_TOKENOAUTH_TOKEN

timeout

整数

用于轮询 DigitalOcean API 的超时时间(以秒为单位)。

默认值: 30

validate_certs

布尔值

如果设置为 no,则不会验证 SSL 证书。

这应该仅在个人控制的使用自签名证书的站点上设置为 no

选择

  • false

  • true ← (默认)

示例

- name: Gather information about all droplets
  community.digitalocean.digital_ocean_droplet_info:
    oauth_token: "{{ oauth_token }}"

- name: Gather information about a specific droplet by name
  community.digitalocean.digital_ocean_droplet_info:
    oauth_token: "{{ oauth_token }}"
    name: my-droplet-name

- name: Gather information about a specific droplet by id
  community.digitalocean.digital_ocean_droplet_info:
    oauth_token: "{{ oauth_token }}"
    id: abc-123-d45

- name: Get information about all droplets to loop through
  community.digitalocean.digital_ocean_droplet_info:
    oauth_token: "{{ oauth_token }}"
  register: droplets

- name: Get number of droplets
  set_fact:
    droplet_count: "{{ droplets.data | length }}"

返回值

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

描述

数据

列表 / elements=字典

DigitalOcean droplet 信息

返回: 成功

示例: [{"backup_ids": [], "created_at": "2021-04-07T00:44:53Z", "disk": 25, "features": ["private_networking"], "id": 123456789, "image": {"created_at": "2020-10-20T08:49:55Z", "description": "Ubuntu 18.04 x86 镜像", "distribution": "Ubuntu", "id": 987654321, "min_disk_size": 15, "name": "18.04 (LTS) x64", "public": false, "regions": [], "size_gigabytes": 0.34, "slug": null, "status": "已停用", "tags": [], "type": "base"}, "kernel": null, "locked": false, "memory": 1024, "name": "my-droplet-01", "networks": {"v4": [{"gateway": "", "ip_address": "1.2.3.4", "netmask": "255.255.240.0", "type": "private"}, {"gateway": "5.6.7.8", "ip_address": "4.3.2.1", "netmask": "255.255.240.0", "type": "public"}], "v6": []}, "next_backup_window": null, "region": {"available": true, "features": ["backups", "ipv6", "metadata", "install_agent", "storage", "image_transfer"], "name": "纽约 1", "sizes": ["s-1vcpu-1gb", "s-1vcpu-1gb-intel", "s-1vcpu-2gb", "s-1vcpu-2gb-intel", "s-2vcpu-2gb", "s-2vcpu-2gb-intel", "s-2vcpu-4gb", "s-2vcpu-4gb-intel", "s-4vcpu-8gb", "c-2", "c2-2vcpu-4gb", "s-4vcpu-8gb-intel", "g-2vcpu-8gb", "gd-2vcpu-8gb", "s-8vcpu-16gb", "m-2vcpu-16gb", "c-4", "c2-4vcpu-8gb", "s-8vcpu-16gb-intel", "m3-2vcpu-16gb", "g-4vcpu-16gb", "so-2vcpu-16gb", "m6-2vcpu-16gb", "gd-4vcpu-16gb", "so1_5-2vcpu-16gb", "m-4vcpu-32gb", "c-8", "c2-8vcpu-16gb", "m3-4vcpu-32gb", "g-8vcpu-32gb", "so-4vcpu-32gb", "m6-4vcpu-32gb", "gd-8vcpu-32gb", "so1_5-4vcpu-32gb", "m-8vcpu-64gb", "c-16", "c2-16vcpu-32gb", "m3-8vcpu-64gb", "g-16vcpu-64gb", "so-8vcpu-64gb", "m6-8vcpu-64gb", "gd-16vcpu-64gb", "so1_5-8vcpu-64gb", "m-16vcpu-128gb", "c-32", "c2-32vcpu-64gb", "m3-16vcpu-128gb", "m-24vcpu-192gb", "g-32vcpu-128gb", "so-16vcpu-128gb", "m6-16vcpu-128gb", "gd-32vcpu-128gb", "m3-24vcpu-192gb", "g-40vcpu-160gb", "so1_5-16vcpu-128gb", "m-32vcpu-256gb", "gd-40vcpu-160gb", "so-24vcpu-192gb", "m6-24vcpu-192gb", "m3-32vcpu-256gb", "so1_5-24vcpu-192gb", "so-32vcpu-256gb", "m6-32vcpu-256gb", "so1_5-32vcpu-256gb"], "slug": "nyc1"}, "size": {"available": true, "description": "基本型", "disk": 25, "memory": 1024, "price_hourly": 0.00744, "price_monthly": 5.0, "regions": ["ams2", "ams3", "blr1", "fra1", "lon1", "nyc1", "nyc2", "nyc3", "sfo1", "sfo3", "sgp1", "tor1"], "slug": "s-1vcpu-1gb", "transfer": 1.0, "vcpus": 1}, "size_slug": "s-1vcpu-1gb", "snapshot_ids": [], "status": "active", "tags": ["tag1"], "vcpus": 1, "volume_ids": [], "vpc_uuid": "123-abc-567a"}]

作者

  • Tyler Auerbeck (@tylerauerbeck)