community.general.dnsmadeeasy 模块 – 与 dnsmadeeasy.com(DNS 托管服务)接口

注意

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

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

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

要在 playbook 中使用它,请指定:community.general.dnsmadeeasy

概要

要求

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

  • hashlib

  • hmac

参数

参数

注释

account_key

字符串 / 必需

帐户 API 密钥。

account_secret

字符串 / 必需

帐户密钥。

autoFailover

布尔值

如果为 true,则在故障转移后手动回退到主 IP 地址。

如果为 false,则在故障转移后自动回退到主 IP 地址。

选择

  • false ←(默认)

  • true

contactList

字符串

监视器将通知的联系人列表的名称或 ID。

默认的 '' 表示帐户所有者。

domain

字符串 / 必需

要使用的域。可以是域名(例如“mydomain.com”)或 DNS Made Easy 中域的数字 ID(例如“839989”),以便更快地解析

failover

布尔值

如果 true,则添加或更改故障转移。这仅适用于 A 记录。

选择

  • false ←(默认)

  • true

httpFile

字符串

监视器为 HTTP 或 HTTPS 查询的 Fqdn 上的文件。

httpFqdn

字符串

监视器使用的完全限定域名。

httpQueryString

字符串

监视器为 HTTP 或 HTTPS 查询的 httpFile 中的字符串。

ip1

字符串

故障转移的主 IP 地址。

如果添加或更改监视器或故障转移,则为必需。

ip2

字符串

故障转移的辅助 IP 地址。

如果添加或更改故障转移,则为必需。

ip3

字符串

故障转移的第三个 IP 地址。

ip4

字符串

故障转移的第四个 IP 地址。

ip5

字符串

故障转移的第五个 IP 地址。

maxEmails

整数

监视器发送给联系人列表的电子邮件数量。

默认值: 1

monitor

布尔值

如果 true,则添加或更改监视器。这仅适用于 A 记录。

选择

  • false ←(默认)

  • true

port

整数

监视器使用的端口。

默认值: 80

protocol

字符串

监视器使用的协议。

选择

  • "TCP"

  • "UDP"

  • "HTTP" ←(默认)

  • "DNS"

  • "SMTP"

  • "HTTPS"

record_name

字符串

要获取/创建/删除/更新的记录名称。如果未指定 record_name;无论 state 参数如何,“result”中将返回该域的所有记录。

record_ttl

整数

记录的“生存时间”。记录在 DNS 服务器中缓存的秒数。

默认值: 1800

record_type

字符串

记录类型。

选择

  • "A"

  • "AAAA"

  • "CNAME"

  • "ANAME"

  • "HTTPRED"

  • "MX"

  • "NS"

  • "PTR"

  • "SRV"

  • "TXT"

record_value

字符串

记录值。HTTPRED:<重定向 URL>,MX:<优先级> <目标名称>,NS:<名称服务器>,PTR:<目标名称>,SRV:<优先级> <权重> <端口> <目标名称>,TXT:<文本值>”

如果未指定 record_value;则不会进行任何更改,记录将返回到“result”中(换句话说,此模块可用于获取记录的当前 ID、类型和 TTL)

sandbox

布尔值

确定是否应使用沙盒 API。否则(默认情况下)使用 DNS Made Easy 的生产 API。

选择

  • false ←(默认)

  • true

sensitivity

字符串

监视器在发生故障转移之前执行的检查次数,其中低 = 8,中 = 5,高 = 3。

选择

  • "Low"

  • "Medium" ←(默认)

  • "High"

state

字符串 / 必需

记录是否应存在

选择

  • "present"

  • "absent"

systemDescription

字符串

监视器使用的描述。

默认值: ""

validate_certs

布尔值

如果 false,则不会验证 SSL 证书。这应该仅在个人控制的使用自签名证书的站点上使用。

选择

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持:

可以在 check_mode 模式下运行,并返回更改状态预测,而无需修改目标。

diff_mode

支持:

当处于 diff 模式时,将返回有关已更改的内容(或可能需要在 check_mode 模式下更改的内容)的详细信息。

注释

注意

  • DNS Made Easy 服务要求与 API 交互的机器设置正确的时间和时区。请务必使用 NTP 将您的时间保持在实际时间的几秒钟内。

  • 当 ‘state’ 设置为 ‘present’ 时,此模块会在 “result” 元素中返回记录和监视器。这些值可以注册并在您的 playbook 中使用。

  • 只有 A 记录可以有监视器或故障转移。

  • 要添加故障转移,需要 ‘failover’、‘autoFailover’、‘port’、‘protocol’、‘ip1’ 和 ‘ip2’ 选项。

  • 要添加监视器,需要 ‘monitor’、‘port’、‘protocol’、‘maxEmails’、‘systemDescription’ 和 ‘ip1’ 选项。

  • 监视器和故障转移将共享 ‘port’、‘protocol’ 和 ‘ip1’ 选项。

示例

- name: Fetch my.com domain records
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
  register: response

- name: Create a record
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1

- name: Update the previously created record
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_value: 192.0.2.23

- name: Fetch a specific record
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
  register: response

- name: Delete a record
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    record_type: A
    state: absent
    record_name: test

- name: Add a failover
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    failover: true
    ip1: 127.0.0.2
    ip2: 127.0.0.3

- name: Add a failover
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    failover: true
    ip1: 127.0.0.2
    ip2: 127.0.0.3
    ip3: 127.0.0.4
    ip4: 127.0.0.5
    ip5: 127.0.0.6

- name: Add a monitor
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    monitor: true
    ip1: 127.0.0.2
    protocol: HTTP  # default
    port: 80  # default
    maxEmails: 1
    systemDescription: Monitor Test A record
    contactList: my contact list

- name: Add a monitor with http options
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    monitor: true
    ip1: 127.0.0.2
    protocol: HTTP  # default
    port: 80  # default
    maxEmails: 1
    systemDescription: Monitor Test A record
    contactList: 1174  # contact list id
    httpFqdn: http://my.com
    httpFile: example
    httpQueryString: some string

- name: Add a monitor and a failover
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    failover: true
    ip1: 127.0.0.2
    ip2: 127.0.0.3
    monitor: true
    protocol: HTTPS
    port: 443
    maxEmails: 1
    systemDescription: monitoring my.com status
    contactList: emergencycontacts

- name: Remove a failover
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    failover: false

- name: Remove a monitor
  community.general.dnsmadeeasy:
    account_key: key
    account_secret: secret
    domain: my.com
    state: present
    record_name: test
    record_type: A
    record_value: 127.0.0.1
    monitor: false

作者

  • Brice Burgess (@briceburg)