Red Hat Training

A Red Hat training course is available for RHEL 8

83.3. 使用 Ansible playbook,确保在 IdM 中存在于非IdM 客户端中的 HTTP 服务

按照以下流程,使用 Ansible playbook 确保 IdM 中的 HTTP 服务器在不是 IdM 客户端的主机上存在。通过将 HTTP 服务器添加到 IdM 中,您还会将主机添加到 IdM。

先决条件

流程

  1. 创建一个清单文件,如 inventory.file

    $ touch inventory.file
  2. 打开 inventory.file,并在 [ipaserver] 部分中定义您要配置的 IdM 服务器。例如,要指示 Ansible 配置 server.idm.example.com,请输入:

    [ipaserver]
    server.idm.example.com
  3. 生成 /usr/share/doc/ansible-freeipa/playbooks/service/service-is-present-without-host-check.yml Ansible playbook 文件的副本。例如:

    $ cp /usr/share/doc/ansible-freeipa/playbooks/service/service-is-present-without-host-check.yml /usr/share/doc/ansible-freeipa/playbooks/service/service-is-present-without-host-check-copy.yml
  4. 打开复制的文件 /usr/share/doc/ansible-freeipa/playbooks/service/service-is-present-without-host-check-copy.yml 以进行编辑。在 ipaservice 任务中找到 ipaadmin_passwordname 变量:

    ---
    - name: Playbook to manage IPA service.
      hosts: ipaserver
      gather_facts: false
    
      vars_files:
      - /home/user_name/MyPlaybooks/secret.yml
      tasks:
      # Ensure service is present
      - ipaservice:
          ipaadmin_password: "{{ ipaadmin_password }}"
          name: HTTP/www2.example.com
          skip_host_check: yes
  5. 调整文件:

    • ipaadmin_password 变量设置为 IdM 管理员密码。
    • name 变量设置为运行 HTTP 服务的主机的名称。
  6. 保存并退出文件。
  7. 运行 Ansible playbook。指定 playbook 文件、存储密码的文件保护 secret.yml 文件以及清单文件:

    $ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file /usr/share/doc/ansible-freeipa/playbooks/service/service-is-present-without-host-check-copy.yml

验证步骤

  1. 以 IdM 管理员身份登录 IdM Web UI。
  2. 导航到 IdentityServices

现在,您可以看到 Services 列表中列出的 HTTP/client.idm.example.com@IDM.EXAMPLE.COM

其它资源