32.7. 使用 Ansible 在 IdM 中存在 SRV 记录
DNS 服务 (SRV) 记录定义域中可用服务的主机名、端口号、传输协议、优先级和权重。在 RHEL Identity Management (IdM)中,您可以使用 SRV 记录来定位 IdM 服务器和副本。
按照以下流程,使用 Ansible playbook 确保 SRV 记录在 IdM DNS 中存在。在以下示例中,IdM 管理员可确保存在 _kerberos._udp.idm.example.com SRV 记录,其值为 10 50 88 idm.example.com。这会设置以下值:
- 它将服务的优先级设置为 10。
- 它将服务的权重设置为 50。
- 它将服务要使用的端口设置为 88。
先决条件
您已配置了 Ansible 控制节点以满足以下要求:
- 您在使用 Ansible 版本 2.15 或更高版本。
-
已安装
freeipa.ansible_freeipa
集合。 - 示例假定在 ~/MyPlaybooks/ 目录中,您已创建了一个具有 IdM 服务器的完全限定域名(FQDN)的 Ansible 清单文件。
-
示例假定 secret.yml Ansible vault 存储了您的
ipaadmin_password
,并且您可以访问存储了保护 secret.yml 文件的密码的文件。
-
目标节点(这是执行
freeipa.ansible_freeipa
模块的节点)是作为 IdM 客户端、服务器或副本的 IdM 域的一部分。 - idm.example.com 区域存在,并由 IdM DNS 管理。有关在 IdM DNS 中添加主 DNS 区域的更多信息,请参阅使用 Ansible playbook 管理 IdM DNS 区域。
流程
导航到
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/dnsrecord
目录:cd /usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/dnsrecord
$ cd /usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/dnsrecord
Copy to Clipboard Copied! 生成 ensure-SRV-record-is-present.yml Ansible playbook 文件的副本。例如:
cp ensure-SRV-record-is-present.yml ensure-SRV-record-is-present-copy.yml
$ cp ensure-SRV-record-is-present.yml ensure-SRV-record-is-present-copy.yml
Copy to Clipboard Copied! - 打开 ensure-SRV-record-is-present-copy.yml 文件进行编辑。
通过在
freeipa.ansible_freeipa.ipadnsrecord
任务部分设置以下变量来调整文件:-
表示
ipaadmin_password
变量的值已在 secret.yml Ansible vault 文件中定义。 -
将
name
变量设置为 _kerberos._udp.idm.example.com。 -
将
srv_rec
变量设置为 '10 50 88 idm.example.com'。 将
zone_name
变量设置为 idm.example.com。对于当前示例为修改过的 Ansible playbook 文件:
--- - name: Test multiple DNS Records are present. hosts: ipaserver become: true gather_facts: false tasks: # Ensure a SRV record is present - freeipa.ansible_freeipa.ipadnsrecord: ipaadmin_password: "{{ ipaadmin_password }}" name: _kerberos._udp.idm.example.com srv_rec: '10 50 88 idm.example.com' zone_name: idm.example.com state: present
--- - name: Test multiple DNS Records are present. hosts: ipaserver become: true gather_facts: false tasks: # Ensure a SRV record is present - freeipa.ansible_freeipa.ipadnsrecord: ipaadmin_password: "{{ ipaadmin_password }}" name: _kerberos._udp.idm.example.com srv_rec: '10 50 88 idm.example.com' zone_name: idm.example.com state: present
Copy to Clipboard Copied! -
表示
- 保存这个文件。
运行 playbook:
ansible-playbook --vault-password-file=password_file -v -i inventory.file ensure-SRV-record-is-present.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory.file ensure-SRV-record-is-present.yml
Copy to Clipboard Copied!