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 记录集。 
- 此模块替换了 2.0.0 之前 community.dns 中的 - 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:webmaster@foo.com"'
    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
返回值
通用返回值记录在 此处,以下是此模块特有的字段
| Key | 描述 | 
|---|---|
| 区域的 ID。 已返回: 成功 示例:  | 
