6.12. 确保 DNS 转发区使用 Ansible 在 IdM 中有多个转发器
按照以下流程,使用 Ansible playbook 确保 IdM 中的 DNS 转发区有多个转发器。在以下示例中,IdM 管理员确保 example.com 的 DNS 转发区被转发到 8.8.8.8 和 4.4.4.4。
先决条件
您已配置了 Ansible 控制节点以满足以下要求:
- 您在使用 Ansible 版本 2.13 或更高版本。
-
您已安装了
ansible-freeipa软件包。 - 示例假定在 ~/MyPlaybooks/ 目录中,您已创建了带有 IdM 服务器的完全限定域名(FQDN)的 Ansible 清单文件。
-
示例假定 secret.yml Ansible vault 存储了
ipaadmin_password。
-
目标节点(这是执行
ansible-freeipa模块的节点)是 IdM 域的一部分,来作为 IdM 客户端、服务器或副本。 - 您知道 IdM 管理员密码。
步骤
进入
/usr/share/doc/ansible-freeipa/playbooks/dnsconfig目录:$ cd /usr/share/doc/ansible-freeipa/playbooks/dnsconfig打开清单文件,并确保
[ipaserver]部分中列出了您要配置的 IdM 服务器。例如,要指示 Ansible 配置server.idm.example.com,请输入:[ipaserver] server.idm.example.com复制
forwarders-absent.ymlAnsible playbook 文件。例如:$ cp forwarders-absent.yml ensure-presence-multiple-forwarders.yml-
打开
ensure-presence-multiple-forwarders.yml文件进行编辑。 通过设置以下变量来调整文件:
-
将 playbook 的
name变量更改为Playbook,以确保 IdM DNS 中存在 dnsforwardzone 中的多个转发器。 -
在
tasks部分,更改任务的名称,来确保 example.com 的 dnsforwardzone 中存在 8.8.8.8 和 4.4.4.4 转发器。 -
在
tasks部分中,将ipadnsconfig标题更改为ipadnsforwardzone。 在
ipadnsforwardzone部分中:-
添加
ipaadmin_password变量,并将其设置为您的 IdM 管理员密码。 -
添加
name变量,并将它设为example.com。 在
forwarders部分:-
删除
ip_address和port行。 添加您要确保的 DNS 服务器的 IP 地址存在,以破折号前:
- 8.8.8.8 - 4.4.4.4
-
删除
- 将 state 变量更改为 present。
对于当前示例为修改过的 Ansible playbook 文件:
-
添加
--- - name: name: Playbook to ensure the presence of multiple forwarders in a dnsforwardzone in IdM DNS hosts: ipaserver vars_files: - /home/user_name/MyPlaybooks/secret.yml tasks: - name: Ensure presence of 8.8.8.8 and 4.4.4.4 forwarders in dnsforwardzone for example.com ipadnsforwardzone: ipaadmin_password: "{{ ipaadmin_password }}" name: example.com forwarders: - 8.8.8.8 - 4.4.4.4 state: present-
将 playbook 的
- 保存这个文件。
运行 playbook:
$ ansible-playbook --vault-password-file=password_file -v -i inventory.file ensure-presence-multiple-forwarders.yml