Red Hat Training

A Red Hat training course is available for RHEL 8

96.4. 确保 IdM 服务器不存在,但不一定与其他 IdM 服务器断开连接

如果要从拓扑中删除身份管理(IdM)服务器,您可以使用 Ansible playbook 使其复制协议保持不变。playbook 还确保 IdM 服务器在 IdM 中不存在,即使作为主机也是如此。

重要

仅当其他服务器是您计划删除的工作不正常的服务器时,才建议在删除时忽略服务器的复制协议。删除拓扑中作为中心点的服务器会将拓扑分成两个断开连接的集群。

您可以使用 ipa server-del 命令从拓扑中删除工作不正常的服务器。

注意

如果删除了作为证书颁发机构(CA)、密钥恢复机构(KRA)或 DNS 服务器的最后一台服务器,将会严重破坏身份管理(IdM)功能。为防止此问题,playbook 在卸载充当 CA、KRA 或 DNS 服务器的服务器之前,确保这些服务运行在域中的另一台服务器上。

ansible-freeipa ipaserver 角色不同,此 playbook 中使用的 ipaserver 模块不会从服务器卸载 IdM 服务。

先决条件

  • 您需要知道 IdM admin 密码。
  • 您已配置了 Ansible 控制节点以满足以下要求:

    • 您使用 Ansible 版本 2.14 或更高版本。
    • 您已在 Ansible 控制器上安装了 ansible-freeipa 软件包。
    • 示例假定在 ~/MyPlaybooks/ 目录中,您已创建了一个具有 IdM 服务器的完全限定域名(FQDN)的 Ansible 清单文件
    • 示例假定 secret.yml Ansible 库存储了 ipaadmin_password
    • 清单文件中定义的从控制节点到 IdM 服务器的 SSH 连接工作正常。

流程

  1. 进入您的 ~/MyPlaybooks/ 目录:

    $ cd ~/MyPlaybooks/
  2. 复制位于 /usr/share/doc/ansible-freeipa/playbooks/server/ 目录中的 server-absent-ignore_topology_disconnect.yml Ansible playbook 文件:

    $ cp /usr/share/doc/ansible-freeipa/playbooks/server/server-absent-ignore_topology_disconnect.yml server-absent-ignore_topology_disconnect-copy.yml
  3. 打开 server-absent-ignore_topology_disconnect-copy.yml 文件进行编辑。
  4. 通过在 ipaserver 任务部分中设置以下变量来调整文件,并保存文件:

    • ipaadmin_password 变量设为 IdM admin 的密码。
    • name 变量设为服务器的 FQDN。示例服务器的 FQDNserver123.idm.example.com
    • 确保 ignore_topology_disconnect 变量设为 yes
    • 确保 state 变量设置为 absent
    ---
    - name: Server absent with ignoring topology disconnects example
      hosts: ipaserver
      vars_files:
      - /home/user_name/MyPlaybooks/secret.yml
      tasks:
      - name: Ensure server “server123.idm.example.com” with ignoring topology disconnects
        ipaserver:
          ipaadmin_password: "{{ ipaadmin_password }}"
          name: server123.idm.example.com
          ignore_topology_disconnect: yes
          state: absent
  5. 运行 Ansible playbook ,并指定 playbook 文件和清单文件:

    $ ansible-playbook --vault-password-file=password_file -v -i inventory server-absent-ignore_topology_disconnect-copy.yml
  6. [可选] 确保指向 server123.idm.example.com 的所有名称服务器(NS)DNS 记录已从 DNS 区域中删除。无论您使用由 IdM 还是外部 DNS 管理的集成 DNS,这个均适用。

其它资源

  • 请参阅卸载 IdM 服务器
  • 请参阅 /usr/share/doc/ansible-freeipa/ 目录中的 README-server.md 文件。
  • 请参阅 /usr/share/doc/ansible-freeipa/playbooks/server 目录中的 playbook 示例。