community.windows.win_dns_record 模块 – 管理 Windows Server DNS 记录
注意
此模块是 community.windows 集合(版本 2.3.0)的一部分。
如果您使用的是 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.windows。您需要满足其他要求才能使用此模块,请参阅 要求 了解详细信息。
要在剧本中使用它,请指定:community.windows.win_dns_record。
概要
- 管理现有 Windows Server DNS 区域内的 DNS 记录。 
要求
执行此模块的主机需要满足以下要求。
- 此模块需要 Windows 8、Server 2012 或更新版本。 
参数
| 参数 | 注释 | 
|---|---|
| 是否应为记录激活老化。 如果设置为  选择 
 | |
| 指定 DNS 服务器。 您可以指定 IP 地址或解析为 IP 地址的任何值,例如完全限定域名 (FQDN)、主机名或 NETBIOS 名称。 | |
| 记录的名称。 | |
| 记录的端口号。 当  仅支持  | |
| SRV 记录中每个服务的优先级号。 当  仅支持  | |
| 记录是否存在。 选择 
 | |
| 记录的“生存时间”,以秒为单位。 当  有效范围为 1 - 31557600。 请注意,Active Directory 林可以指定最小 TTL,并将动态地将其他值“向上舍入”到该最小值。 默认值:  | |
| 要管理的 DNS 记录的类型。 
 
 
 
 选择 
 | |
| 要指定的值。当  当  当  默认值:  | |
| SRV 记录中每个服务记录的权重。 当  仅支持  | |
| 要管理的区域的名称(例如  该区域必须已存在。 | |
| 要管理的区域范围的名称(例如  该区域必须已存在。 | 
示例
# Demonstrate creating a matching A and PTR record.
- name: Create database server record
  community.windows.win_dns_record:
    name: "cgyl1404p"
    type: "A"
    value: "10.1.1.1"
    zone: "amer.example.com"
- name: Create matching PTR record
  community.windows.win_dns_record:
    name: "1.1.1"
    type: "PTR"
    value: "db1"
    zone: "10.in-addr.arpa"
# Demonstrate replacing an A record with a CNAME
- name: Remove static record
  community.windows.win_dns_record:
    name: "db1"
    type: "A"
    state: absent
    zone: "amer.example.com"
- name: Create database server alias
  community.windows.win_dns_record:
    name: "db1"
    type: "CNAME"
    value: "cgyl1404p.amer.example.com"
    zone: "amer.example.com"
# Demonstrate creating multiple A records for the same name
- name: Create multiple A record values for www
  community.windows.win_dns_record:
    name: "www"
    type: "A"
    values:
      - 10.0.42.5
      - 10.0.42.6
      - 10.0.42.7
    zone: "example.com"
# Demonstrates a partial update (replace some existing values with new ones)
# for a pre-existing name
- name: Update www host with new addresses
  community.windows.win_dns_record:
    name: "www"
    type: "A"
    values:
      - 10.0.42.5  # this old value was kept (others removed)
      - 10.0.42.12  # this new value was added
    zone: "example.com"
# Demonstrate creating a SRV record
- name: Creating a SRV record with port number and priority
  community.windows.win_dns_record:
    name: "test"
    priority: 5
    port: 995
    state: present
    type: "SRV"
    weight: 2
    value: "amer.example.com"
    zone: "example.com"
# Demonstrate creating a NS record with multiple values
- name: Creating NS record
  community.windows.win_dns_record:
    name: "ansible.prog"
    state: present
    type: "NS"
    values:
      - 10.0.0.1
      - 10.0.0.2
      - 10.0.0.3
      - 10.0.0.4
    zone: "example.com"
# Demonstrate creating a TXT record
- name: Creating a TXT record with descriptive Text
  community.windows.win_dns_record:
    name: "test"
    state: present
    type: "TXT"
    value: "justavalue"
    zone: "example.com"
# Demostrate creating a A record to Zone Scope
- name: Create database server record
  community.windows.win_dns_record:
    name: "cgyl1404p.amer.example.com"
    type: "A"
    value: "10.1.1.1"
    zone: "amer.example.com"
    zone_scope: "external"
