15.5. 使用 Ansible 确保属性是 IdM RBAC 权限的成员
作为身份管理系统管理员 (IdM),您可以自定义 IdM 基于角色的访问控制 (RBAC)。
以下流程描述了如何使用 Ansible playbook 确保属性是 IdM 中 RBAC 权限的成员。因此,拥有权限的用户可以创建具有属性的条目。
示例描述了如何确保特权包含 MyPermission 权限的用户创建的主机条目可以具有 gecos
和 description
值。
创建或修改权限时可以指定的属性类型不受 IdM LDAP 模式的限制。但是,当 object_type
是 host
时指定 attrs: car_licence
,会导致在使用权限并为一个主机添加特定的 car 许可证时出现 ipa: ERROR: attribute "car-license" not allowed
错误。
先决条件
在控制节点上:
- 您在使用 Ansible 版本 2.15 或更高版本。
-
已安装
freeipa.ansible_freeipa
集合。 - 示例假定在 ~/MyPlaybooks/ 目录中,您已创建了一个具有 IdM 服务器的完全限定域名(FQDN)的 Ansible 清单文件。
-
示例假定 secret.yml Ansible vault 存储了您的
ipaadmin_password
,并且您可以访问存储了保护 secret.yml 文件的密码的文件。
-
目标节点(这是执行
freeipa.ansible_freeipa
模块的节点)是作为 IdM 客户端、服务器或副本的 IdM 域的一部分。 - MyPermission 权限存在。
流程
进入 ~/MyPlaybooks/ 目录:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 制作位于
/usr/share/ansible/collections/ansible_collections/ansible_freeipa/playbooks/permission/ 目录中的
文件的副本:permission
-member-present.ymlcp /usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/permission/permission-member-present.yml permission-member-present-copy.yml
$ cp /usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/permission/permission-member-present.yml permission-member-present-copy.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
打开
permission-member-present-copy.yml
Ansible playbook 文件以进行编辑。 通过在
freeipa.ansible_freeipa.ipapermission
任务部分设置以下变量来调整文件:-
将
name
变量设置为权限的名称。 -
将
attrs
列表设置为description
和gecos
变量。 -
确保
action
变量设置为member
。
这是当前示例修改的 Ansible playbook 文件:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
将
- 保存该文件。
运行 Ansible playbook。指定 playbook 文件、存储保护 secret.yml 文件的密码,以及清单文件:
ansible-playbook --vault-password-file=password_file -v -i inventory permission-member-present-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory permission-member-present-copy.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow