community.digitalocean.digital_ocean_firewall_info 模块 – 收集 DigitalOcean 防火墙信息

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.digitalocean。 您需要进一步的要求才能使用此模块,有关详细信息,请参见 要求

要在剧本中使用它,请指定: community.digitalocean.digital_ocean_firewall_info

概要

  • 此模块可用于收集有关 DigitalOcean 防火墙的信息。

  • 在 Ansible 2.9 之前,此模块被称为 digital_ocean_firewall_facts。 用法没有改变。

别名:digital_ocean_firewall_facts

要求

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

  • python >= 2.6

参数

参数

注释

baseurl

字符串

DigitalOcean API 基本 URL。

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

name

字符串

防火墙规则名称,可用于识别和引用特定的防火墙规则。

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 firewalls
  community.digitalocean.digital_ocean_firewall_info:
    oauth_token: "{{ oauth_token }}"

- name: Gather information about a specific firewall by name
  community.digitalocean.digital_ocean_firewall_info:
    oauth_token: "{{ oauth_token }}"
    name: "firewall_name"

- name: Gather information from a firewall rule
  community.digitalocean.digital_ocean_firewall_info:
    name: SSH
  register: resp_out

- set_fact:
    firewall_id: "{{ resp_out.data.id }}"

- debug:
    msg: "{{ firewall_id }}"

返回值

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

描述

data

列表 / elements=字典

DigitalOcean 防火墙信息

返回值:成功

示例: [{"created_at": "2018-01-15T07:04:25Z", "droplet_ids": [87426985], "id": "435tbg678-1db53-32b6-t543-28322569t252", "inbound_rules": [{"ports": "9100", "protocol": "tcp", "sources": {"addresses": ["1.1.1.1"]}}], "name": "metrics", "outbound_rules": [], "pending_changes": [], "status": "succeeded", "tags": []}]

作者

  • Anthony Bond (@BondAnthony)