36.14. 使用 Ansible 确保 IdM 用户可以使用两个证书登录到 IdM 客户端
如果您希望一个通常使用密码登录到 IdM 身份管理(IdM)的用户只使用智能卡验证到一个特定的 IdM 客户端,则您可以创建一个 ID 视图,该视图要求对该客户端上的用户进行认证。
完成此流程,以使用 ansible-freeipa
idoverrideuser
模块,来:
- 将 ID 视图应用到名为 idview_for_host01 的 host01。
- 确保在 idview_for_host01 中,对带有两个证书的 idm_user 的用户 ID 覆盖存在。
先决条件
您已配置了 Ansible 控制节点以满足以下要求:
- 您在使用 Ansible 版本 2.15 或更高版本。
-
已安装
freeipa.ansible_freeipa
集合。 - 示例假定在 ~/MyPlaybooks/ 目录中,您已创建了一个具有 IdM 服务器的完全限定域名(FQDN)的 Ansible 清单文件。
-
示例假定 secret.yml Ansible vault 存储了您的
ipaadmin_password
,并且您可以访问存储了保护 secret.yml 文件的密码的文件。
-
目标节点(这是执行
freeipa.ansible_freeipa
模块的节点)是作为 IdM 客户端、服务器或副本的 IdM 域的一部分。
--- - name: Ensure both local user and IdM user have access to same files hosts: ipaserver become: false gather_facts: false tasks: - name: Ensure idview_for_host1 is applied to host01.idm.example.com ipaidview: ipaadmin_password: "{{ ipaadmin_password }}" name: *idview_for_host01* host: *host01.idm.example.com* - name: Ensure an IdM user is present in ID view with two certificates ipaidoverrideuser: ipaadmin_password: "{{ ipaadmin_password }}" idview: *idview_for_host01* anchor: *idm_user* certificate: - "{{ lookup('file', 'cert1.b64', rstrip=False) }}" - "{{ lookup('file', 'cert2.b64', rstrip=False) }}"
---
- name: Ensure both local user and IdM user have access to same files
hosts: ipaserver
become: false
gather_facts: false
tasks:
- name: Ensure idview_for_host1 is applied to host01.idm.example.com
ipaidview:
ipaadmin_password: "{{ ipaadmin_password }}"
name: *idview_for_host01*
host: *host01.idm.example.com*
- name: Ensure an IdM user is present in ID view with two certificates
ipaidoverrideuser:
ipaadmin_password: "{{ ipaadmin_password }}"
idview: *idview_for_host01*
anchor: *idm_user*
certificate:
- "{{ lookup('file', 'cert1.b64', rstrip=False) }}"
- "{{ lookup('file', 'cert2.b64', rstrip=False) }}"
+ rstrip=False
指令会导致不从查找文件末尾删除空格。
+ .保存该文件。
+ .运行 playbook。指定 playbook 文件、存储保护 secret.yml 文件的密码,以及清单文件:
+
ansible-playbook --vault-password-file=password_file -v -i inventory ensure-idmuser-present-in-idview-with-certificates.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory ensure-idmuser-present-in-idview-with-certificates.yml