community.dns.hosttech_dns_record_set 模块 – 在 Hosttech DNS 服务中添加或删除记录集
注意
此模块是 community.dns 集合 (版本 3.1.0) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.dns。您需要其他要求才能使用此模块,有关详细信息,请参见 要求。
要在 playbook 中使用它,请指定: community.dns.hosttech_dns_record_set。
community.dns 2.0.0 中的新增功能
概要
- 在 Hosttech DNS 服务中创建和删除 DNS 记录集。 
- 此模块替换了 community.dns 2.0.0 之前的 - hosttech_dns_record。
要求
执行此模块的主机需要以下要求。
- lxml 
参数
| 参数 | 注释 | 
|---|---|
| Hosttech API 用户的密码。 与  自 community.dns 1.2.0 起,可以使用别名  | |
| 此选项定义如果记录集已存在但与指定的记录集不同时的行为。在此比较中, 如果设置为  如果设置为  如果设置为  如果设置为  如果  选项 
 | |
| 指定资源记录的状态。 选项 
 | |
| 赋予新记录的 TTL(以秒为单位)。 默认值:  | |
| 是否将数字转义序列( 在 community.dns 3.0.0 版本中,默认值更改为  选项 
 | |
| 确定如何在 API 和此模块的输入和输出之间转换 TXT 条目值。 值  值  值  默认值  注意:转换代码假定值为 UTF-8 编码。如果您需要其他编码,请使用  选项 
 | |
| 要创建或删除的 DNS 记录类型。 选项 
 | |
| 创建 DNS 记录时的新值。 允许使用 YAML 列表或多个以逗号分隔的值。 删除记录时,必须指定记录的所有值,否则将不会删除。 如果  如果  | |
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 动作组: community.dns.hosttech community.dns 2.4.0 版本中添加 | 在  | |
| 支持:完全支持 | 可以在  | |
| 支持:完全支持 | 在差异模式下,将返回有关已更改内容(或在  | 
示例
- name: Add new.foo.com as an A record with 3 IPs
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: new.foo.com
    type: A
    ttl: 7200
    value: 1.1.1.1,2.2.2.2,3.3.3.3
    hosttech_token: access_token
- name: Update new.foo.com as an A record with a list of 3 IPs
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: new.foo.com
    type: A
    ttl: 7200
    value:
      - 1.1.1.1
      - 2.2.2.2
      - 3.3.3.3
    hosttech_token: access_token
- name: Retrieve the details for new.foo.com
  community.dns.hosttech_dns_record_set_info:
    zone_name: foo.com
    record: new.foo.com
    type: A
    hosttech_username: foo
    hosttech_password: bar
  register: rec
- name: Delete new.foo.com A record using the results from the facts retrieval command
  community.dns.hosttech_dns_record_set:
    state: absent
    zone_name: foo.com
    record: "{{ rec.set.record }}"
    ttl: "{{ rec.set.ttl }}"
    type: "{{ rec.set.type }}"
    value: "{{ rec.set.value }}"
    hosttech_username: foo
    hosttech_password: bar
- name: Add an AAAA record
  # Note that because there are colons in the value that the IPv6 address must be quoted!
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: localhost.foo.com
    type: AAAA
    ttl: 7200
    value: "::1"
    hosttech_token: access_token
- name: Add a TXT record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: localhost.foo.com
    type: TXT
    ttl: 7200
    value: 'bar'
    hosttech_username: foo
    hosttech_password: bar
- name: Remove the TXT record
  community.dns.hosttech_dns_record_set:
    state: absent
    zone_name: foo.com
    record: localhost.foo.com
    type: TXT
    ttl: 7200
    value: 'bar'
    hosttech_username: foo
    hosttech_password: bar
- name: Add a CAA record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: foo.com
    type: CAA
    ttl: 3600
    value:
    - '128 issue "letsencrypt.org"'
    - '128 iodef "mailto:[email protected]"'
    hosttech_token: access_token
- name: Add an MX record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: foo.com
    type: MX
    ttl: 3600
    value:
    - "10 mail.foo.com"
    hosttech_token: access_token
- name: Add a CNAME record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: bla.foo.com
    record: foo.com
    type: CNAME
    ttl: 3600
    value:
    - foo.foo.com
    hosttech_username: foo
    hosttech_password: bar
- name: Add a PTR record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.foo.com
    record: foo.com
    type: PTR
    ttl: 3600
    value:
    - foo.foo.com
    hosttech_token: access_token
- name: Add an SPF record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: foo.com
    type: SPF
    ttl: 3600
    value:
    - "v=spf1 a mx ~all"
    hosttech_username: foo
    hosttech_password: bar
- name: Add a PTR record
  community.dns.hosttech_dns_record_set:
    state: present
    zone_name: foo.com
    record: foo.com
    type: PTR
    ttl: 3600
    value:
    - "10 100 3333 service.foo.com"
    hosttech_token: access_token
返回值
常用返回值已在此处 记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 区域的 ID。 返回:成功 示例:  | 
