community.general.ipa_dnsrecord 模块 – 管理 FreeIPA DNS 记录
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.general。
要在 playbook 中使用它,请指定: community.general.ipa_dnsrecord。
概要
- 使用 IPA API 添加、修改和删除 IPA DNS 记录。 
参数
| 参数 | 注释 | 
|---|---|
| IPA 服务器的 IP 地址或主机名。 如果任务中未指定此值,则将使用环境变量  如果任务中既未指定环境变量  FreeIPA 中需要的相关条目是  如果任务中既没有 DNS 条目,也没有环境变量  默认值:  | |
| 管理员用户的密码。 如果任务中未指定此值,则将使用环境变量  请注意,如果  如果环境变量  如果环境变量  如果 GSSAPI 不可用,则需要使用  | |
| FreeIPA/IPA 服务器的端口。 如果任务中未指定此值,则将使用环境变量  如果任务中既未指定环境变量  默认值:  | |
| IPA 服务器使用的协议。 如果任务中未指定此值,则将使用环境变量  如果任务中既未指定环境变量  选项 
 | |
| 指定连接的空闲超时时间(以秒为单位)。 对于批量操作,您可能需要增加此值以避免 IPA 服务器超时。 如果任务中未指定此值,则将使用环境变量  如果任务中既未指定环境变量  默认值:  | |
| 在 IPA 服务器上使用的管理员帐户。 如果任务中未指定值,则将使用环境变量  如果任务中既未指定环境变量  默认值:  | |
| 要管理的DNS记录名称。 | |
| 设置记录的TTL。 仅在添加新记录或更改  | |
| DNS记录名称的类型。 在community.general 8.2.0中添加了对 在community.general 9.1.0中添加了对 选项 
 | |
| 使用此值管理DNS记录名称。 与 如果需要指定多个值,请使用 对于 对于 对于 对于 对于 对于 对于 对于 对于 对于 | |
| 使用此值管理DNS记录名称。 与 对于 对于 对于 对于 对于 对于 对于 对于 对于 对于 | |
| 要确保的状态 选项 
 | |
| 需要管理DNS记录的DNS区域名称。 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完全支持 | 可以在 | |
| 支持:不支持 | 在差异模式下,将返回有关已更改内容(或可能需要在 | 
示例
- name: Ensure dns record is present
  community.general.ipa_dnsrecord:
    ipa_host: spider.example.com
    ipa_pass: Passw0rd!
    state: present
    zone_name: example.com
    record_name: vm-001
    record_type: 'AAAA'
    record_value: '::1'
- name: Ensure that dns records exists with a TTL
  community.general.ipa_dnsrecord:
    name: host02
    zone_name: example.com
    record_type: 'AAAA'
    record_values: '::1,fe80::1'
    record_ttl: 300
    ipa_host: ipa.example.com
    ipa_pass: topsecret
    state: present
- name: Ensure a PTR record is present
  community.general.ipa_dnsrecord:
    ipa_host: spider.example.com
    ipa_pass: Passw0rd!
    state: present
    zone_name: 2.168.192.in-addr.arpa
    record_name: 5
    record_type: 'PTR'
    record_value: 'internal.ipa.example.com'
- name: Ensure a TXT record is present
  community.general.ipa_dnsrecord:
    ipa_host: spider.example.com
    ipa_pass: Passw0rd!
    state: present
    zone_name: example.com
    record_name: _kerberos
    record_type: 'TXT'
    record_value: 'EXAMPLE.COM'
- name: Ensure an SRV record is present
  community.general.ipa_dnsrecord:
    ipa_host: spider.example.com
    ipa_pass: Passw0rd!
    state: present
    zone_name: example.com
    record_name: _kerberos._udp.example.com
    record_type: 'SRV'
    record_value: '10 50 88 ipa.example.com'
- name: Ensure an MX records are present
  community.general.ipa_dnsrecord:
    ipa_host: spider.example.com
    ipa_pass: Passw0rd!
    state: present
    zone_name: example.com
    record_name: '@'
    record_type: 'MX'
    record_values:
      - '1 mailserver-01.example.com'
      - '2 mailserver-02.example.com'
- name: Ensure that dns record is removed
  community.general.ipa_dnsrecord:
    name: host01
    zone_name: example.com
    record_type: 'AAAA'
    record_value: '::1'
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret
    state: absent
- name: Ensure an NS record for a subdomain is present
  community,general.ipa_dnsrecord:
    name: subdomain
    zone_name: example.com
    record_type: 'NS'
    record_value: 'ns1.subdomain.exmaple.com'
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: ChangeMe!
- name: Retrieve the current sshfp fingerprints
  ansible.builtin.command: ssh-keyscan -D localhost
  register: ssh_hostkeys
- name: Update the SSHFP records in DNS
  community.general.ipa_dnsrecord:
    name: "{{ inventory_hostname}}"
    zone_name: example.com
    record_type: 'SSHFP'
    record_values: "{{ ssh_hostkeys.stdout.split('\n') | map('split', 'SSHFP ') | map('last') | list }}"
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: ChangeMe!
返回值
常用返回值已在此处记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| IPA API返回的DNS记录。 返回:始终返回 | 
