Red Hat Training

A Red Hat training course is available for RHEL 8

44.5. 使用 Ansible playbook 确保没有 IdM 主机条目

按照以下流程,使用 Ansible playbook 确保主机条目在身份管理(IdM)中不存在。

先决条件

  • IdM 管理员凭证

流程

  1. 创建一个清单文件,如 inventory.file,并在该文件中定义 ipaserver

    [ipaserver]
    server.idm.example.com
  2. 创建 Ansible playbook 文件,使其包含没有存在于 IdM 中的主机的完全限定域名 (FQDN)。如果您的 IdM 域集成了 DNS,请使用 updatedns: yes 选项从 DNS 中删除主机任意类型的关联记录。

    要简化此步骤,您可以复制并修改 /usr/share/doc/ansible-freeipa/playbooks/host/delete-host.yml 文件中的示例:

    ---
    - name: Host absent
      hosts: ipaserver
    
      vars_files:
      - /home/user_name/MyPlaybooks/secret.yml
      tasks:
      - name: Host host01.idm.example.com absent
        ipahost:
          ipaadmin_password: "{{ ipaadmin_password }}"
          name: host01.idm.example.com
          updatedns: yes
          state: absent
  3. 运行 playbook:

    $ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-host-absent.yml
注意

这个过程会产生:

  • IdM Kerberos 域中没有的主机。
  • IdM LDAP 服务器中不存在主机条目。

要从客户端主机本身中删除系统服务的特定 IdM 配置,如系统安全服务守护进程 (SSSD),您必须在客户端上运行 ipa-client-install --uninstall 命令。详情请参阅卸载 IdM 客户端

验证步骤

  1. 以 admin 用户身份登录 ipaserver

    $ ssh admin@server.idm.example.com
    Password:
    [admin@server /]$
  2. 显示 host01.idm.example.com 的信息:

    $ ipa host-show host01.idm.example.com
    ipa: ERROR: host01.idm.example.com: host not found

输出确认 IdM 中不存在该主机。