Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling members in ipa role. #469

Merged
merged 1 commit into from Jan 7, 2021

Conversation

rjeffman
Copy link
Member

When adding new members to a role, the existing members were removed.
The correct behavior for the "member" action is to add those members,
and substitute the existing ones. This patch fixes this behavior.

Fix #409, #411, #412, #413

When adding new members to a role, the existing members were removed.
The correct behavior for the "member" action is to add those members,
and substitute the existing ones. This patch fixes this behavior.

Fix freeipa#409, freeipa#411, freeipa#412, freeipa#413
@varunmylaraiah
Copy link
Collaborator

varunmylaraiah commented Jan 7, 2021

#411 issue fixed


Console output

Before
[root@master ~]# ipa role-show testnonexistingmember
  Role name: testnonexistingmember
  Member users: rbacuser01
  Member groups: rbacgroup01
  Member hosts: mytesthost1.ipadomain.test
  Member host-groups: hostgroup02
  Member services: HTTP/master.ipadomain.test@IPADOMAIN.TEST

[root@ansible ~]# cat rbac_role_add_nonexisting_user_as_a_member.yaml
---
- name: "Playbook to ensure not able to add nonexisting user members in role"
  hosts: ipaserver

  tasks:
  - iparole:
      ipaadmin_password: <xxxxxxxx>
      name: "test-negative-role"
      user: nouser

Error:
TASK [iparole] *****************************************************************
task path: /root/rbac_role_add_nonexisting_user_as_a_member.yaml:6
fatal: [master.ipadomain.test]: FAILED! => {"changed": false, "msg": "role_add_member: user nouser: no such entry"}

After:
[root@master ~]# ipa role-show testnonexistingmember
  Role name: testnonexistingmember
  Member users: rbacuser01
  Member groups: rbacgroup01
  Member hosts: mytesthost1.ipadomain.test
  Member host-groups: hostgroup02
  Member services: HTTP/master.ipadomain.test@IPADOMAIN.TEST

@varunmylaraiah
Copy link
Collaborator

#409 issue has been fixed.

Console-output:
Before:
[root@master ~]# ipa role-show Admin-role
  Role name: Admin-role
  Description: test role in IPA.
  Privileges: Group Administrators

[root@ansible ~]# cat rbac_role_update_with_additional_privileges.yaml
---
- name: "Playbook to ensure role is present with the additional privilege."
  hosts: ipaserver

  tasks:
  - iparole:
      ipaadmin_password: <xxxxxxxx>
      name: Admin-role
      privilege: 
        - "DNS Administrators"
        - "DNS Servers"
        - "Host Administrators"
      action: member

After:
[root@master ~]# ipa role-show Admin-role
  Role name: Admin-role
  Description: test role in IPA.
  Privileges: Group Administrators, Host Administrators, DNS
              Administrators, DNS Servers

@varunmylaraiah varunmylaraiah self-requested a review January 7, 2021 12:30
@varunmylaraiah
Copy link
Collaborator

varunmylaraiah commented Jan 7, 2021

#412 issue has been fixed.

Console-output:
Before:
[root@master ~]# ipa role-show memberrole
  Role name: memberrole
  Member users: rbacuser02, rbacuser03, rbacuser01
  Member groups: rbacgroup02
  Member hosts: mytesthost2.ipadomain.test,
                mytesthost1.ipadomain.test,
                mytesthost3.ipadomain.test
  Member host-groups: hostgroup01, hostgroup03


[root@ansible ~]# cat rbac_role_update_with_multiple_group_member.yaml
---
- name: "Playbook to ensure additional hostgroup member is updated in the existing role."
  hosts: ipaserver

  tasks:
  - iparole:
      ipaadmin_password: <xxxxx>
      name: memberrole
      group: 
         - rbacgroup01
         - rbacgroup03
      action: member

After:
[root@master ~]# ipa role-show memberrole
  Role name: memberrole
  Member users: rbacuser02, rbacuser03, rbacuser01
  Member groups: rbacgroup02, rbacgroup01, rbacgroup03
  Member hosts: mytesthost2.ipadomain.test,
                mytesthost1.ipadomain.test,
                mytesthost3.ipadomain.test
  Member host-groups: hostgroup01, hostgroup03
  Privileges: Certificate Administrators

@varunmylaraiah
Copy link
Collaborator

#413 issue has been fixed.

Console-output
Before:
[root@master ~]# ipa role-show svcrole
  Role name: svcrole
  Member services: HTTP/master.ipadomain.test@IPADOMAIN.TEST,
                   dogtag/master.ipadomain.test@IPADOMAIN.TEST


[root@ansible ~]# cat test.yaml
---
- name: "Add host member to the role"
  hosts: ipaserver

  tasks:
  - iparole:
      ipaadmin_password: <xxxxxxxx>
      name: svcrole
      host: mytesthost2.ipadomain.test
      action: member

After:
[root@master ~]# ipa role-show svcrole
  Role name: svcrole
  Member hosts: mytesthost2.ipadomain.test
  Member services: HTTP/master.ipadomain.test@IPADOMAIN.TEST,
                   dogtag/master.ipadomain.test@IPADOMAIN.TEST

Copy link
Collaborator

@varunmylaraiah varunmylaraiah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes LGTM.
Thanks @rjeffman

@varunmylaraiah
Copy link
Collaborator

@t-woerner We can merge this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Role handling] Not able to add additional privileges with existing privilege.
3 participants