Red Hat Training

A Red Hat training course is available for RHEL 8

第 10 章 使用 Ansible playbook 配置全局 IdM 设置

使用 Ansible config 模块,您可以检索和设置 Identity Management (IdM) 的全局配置参数。

10.1. 使用 Ansible playbook 检索 IdM 配置

以下流程描述了如何使用 Ansible playbook 来检索有关当前全局 IdM 配置的信息。

先决条件

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

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

流程

  1. 打开 /usr/share/doc/ansible-freeipa/playbooks/config/retrieve-config.yml Ansible playbook 文件进行编辑:

    ---
    - name: Playbook to handle global IdM configuration
      hosts: ipaserver
      become: no
      gather_facts: no
    
      vars_files:
      - /home/user_name/MyPlaybooks/secret.yml
      tasks:
      - name: Query IPA global configuration
        ipaconfig:
          ipaadmin_password: "{{ ipaadmin_password }}"
        register: serverconfig
    
      - debug:
          msg: "{{ serverconfig }}"
  2. 通过更改以下内容来调整文件:

    • IdM 管理员的密码。
    • 其他值(如有必要)。
  3. 保存该文件。
  4. 运行 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/config/retrieve-config.yml
    [...]
    TASK [debug]
    ok: [server.idm.example.com] => {
        "msg": {
            "ansible_facts": {
                "discovered_interpreter_
            },
            "changed": false,
            "config": {
                "ca_renewal_master_server": "server.idm.example.com",
                "configstring": [
                    "AllowNThash",
                    "KDC:Disable Last Success"
                ],
                "defaultgroup": "ipausers",
                "defaultshell": "/bin/bash",
                "emaildomain": "idm.example.com",
                "enable_migration": false,
                "groupsearch": [
                    "cn",
                    "description"
                ],
                "homedirectory": "/home",
                "maxhostname": "64",
                "maxusername": "64",
                "pac_type": [
                    "MS-PAC",
                    "nfs:NONE"
                ],
                "pwdexpnotify": "4",
                "searchrecordslimit": "100",
                "searchtimelimit": "2",
                "selinuxusermapdefault": "unconfined_u:s0-s0:c0.c1023",
                "selinuxusermaporder": [
                    "guest_u:s0$xguest_u:s0$user_
                ],
                "usersearch": [
                    "uid",
                    "givenname",
                    "sn",
                    "telephonenumber",
                    "ou",
                    "title"
                ]
            },
            "failed": false
        }
    }