30.12. 使用 Ansible 确保在 IdM 中 DNS 转发区域有多个转发器
按照以下流程,使用 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.yml
Ansible playbook 文件的一个副本。例如:$ cp forwarders-absent.yml ensure-presence-multiple-forwarders.yml
-
打开
ensure-presence-multiple-forwarders.yml
文件进行编辑。 通过设置以下变量来调整文件:
-
将 playbook 的
name
变量更改为Playbook to ensure the presence of multiple forwarders in a dnsforwardzone in IdM DNS
。 -
在
tasks
部分中,将任务的name
更改为Ensure presence of 8.8.8.8 and 4.4.4.4 forwarders in dnsforwardzone for example.com
。 -
在
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
其它资源
-
请参阅
/usr/share/doc/ansible-freeipa/
目录中的README-dnsforwardzone.md
文件。