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

ipagroup: Fix management of AD objects #1335

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rjeffman
Copy link
Member

When using AD objects, a user expects to use the more human readable
form, like "[email protected]", but this impose some dificulties on
evaluating which object is being referenced as AD has several forms to
refer to the same object.

Each object is AD is identified uniquely by its SID, and this is the
identifier that IPA stores in its database. When managing AD objects,
IPA finds its SID and works with that value.

ansible-freeipa tried to process these objects using the human readable
values, and it cause idempontence error when ensuring the values were
present or modified, and, at least in some cases, prevented the objects
to be made absent, as the object list created didn't match the SID to
the value used as module parameter.

By using SID to process the AD objects in ipagroup, the addition or
removal of members works and idempotence of these members is ensured.

The only issue with thils approach is that it only works no server
nodes. In client nodes, the conversion to SID is not available and the
same issues that existed before will still be present.

Tests were updated to reflect these changes, a new test, specific to
idempotence issues of AD objects was added:

tests/group/test_group_ad_users.yml

Resolves: https://issues.redhat.com/browse/RHEL-70023

For information on some changes required to finish or test this changes, please, refer to the specific commits.

When managing AD objects the SID of the objects are stored in FreeIPA
database, but a user would still use the human readable values, like
"AD\\user" or "[email protected]". This can cause idempotence issues in
many cases, and prevent some actions to be performed, like ensure
absence of the object.

The methods added allow the conversion of one or multiple objects, and
will be used by any module that manages AD objects.

Signed-off-by: Rafael Guterres Jeffman <[email protected]>
This patch improves tests/env_freeipa_facts.yml by ensuring
ipaserver_realm is set, making AD server availability discoverable, and
allowing playbooks to run with 'gather_facts: false' by gathering
minimal facts.
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.

Fix is working fine.

[root@master ~]# ipa group-show external-group1
  Group name: external-group1
  External member: [email protected], [email protected]
[root@ansible ~]# cat external_group_remove.yaml
---
- name: Playbook to ensure external member is absent from the external group(external-group1)
 hosts: ipaserver
 become: true
 tasks:
 - ipagroup:
     ipaadmin_password: <xxxxxxxxx>
     name: external-group1
     action: member
     externalmember: 
       - [email protected]
       - [email protected]
     state: absent

PLAY [Playbook to ensure external member is absent from the external group(external-group1)] **************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************************************
task path: /root/external_group_remove.yaml:2
ok: [master.ipadomain.test]

TASK [ipagroup] *******************************************************************************************************************************************************************
task path: /root/external_group_remove.yaml:6
changed: [master.ipadomain.test] => {"changed": true}

PLAY RECAP ************************************************************************************************************************************************************************
master.ipadomain.test      : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
[root@master ~]# ipa group-show external-group1
  Group name: external-group1
  External member: [email protected]

@rjeffman
Copy link
Member Author

@varunmylaraiah in this example shouldn't both the members should have been excluded?

@varunmylaraiah
Copy link
Collaborator

varunmylaraiah commented Jan 29, 2025

@rjeffman

[root@master ~]# ipa group-show external-group1
  Group name: external-group1
  External member: [email protected], [email protected]
  Member groups: testgroup
  Membership managed by groups: gmm_group01
  Membership managed by users: gmm_user01
[root@ansible ~]# cat external_group_remove.yaml
---
- name: Playbook to ensure external member is absent from the external group(external-group1)
  hosts: ipaserver
  become: true
  tasks:
  - ipagroup:
      ipaadmin_password: <xxxxxxxx>
      name: external-group1
      action: member
      externalmember: 
        - [email protected]
      state: absent

PLAY [Playbook to ensure external member is absent from the external group(external-group1)] **************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************************************
task path: /root/external_group_remove.yaml:2
ok: [master.ipadomain.test]

TASK [ipagroup] *******************************************************************************************************************************************************************
task path: /root/external_group_remove.yaml:6
changed: [master.ipadomain.test] => {"changed": true}

PLAY RECAP ************************************************************************************************************************************************************************
master.ipadomain.test      : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
[root@master ~]# ipa group-show external-group1
  Group name: external-group1
  External member: [email protected]
  Member groups: testgroup
  Membership managed by groups: gmm_group01
  Membership managed by users: gmm_user01

@t-woerner
Copy link
Member

Please add a failure in case of external_member usage with client context. Please also add this to the docs (README and documentation sections in the module).

@rjeffman rjeffman force-pushed the ipagroup_fix_1 branch 2 times, most recently from 9c98caa to 6e17212 Compare January 30, 2025 19:31
@rjeffman
Copy link
Member Author

Added the test to fail in case externalmember or idoverrideuser are used without ipa_context: server.

@t-woerner, please, review de documentation.

When using AD objects, a user expects to use the more human readable
form, like "[email protected]", but this impose some dificulties on
evaluating which object is being referenced as AD has several forms to
refer to the same object.

Each object is AD is identified uniquely by its SID, and this is the
identifier that IPA stores in its database. When managing AD objects,
IPA finds its SID and works with that value.

ansible-freeipa tried to process these objects using the human readable
values, and it cause idempontence error when ensuring the values were
present or modified, and, at least in some cases, prevented the objects
to be made absent, as the object list created didn't match the SID to
the value used as module parameter.

By using SID to process the AD objects in ipagroup, the addition or
removal of members works and idempotence of these members is ensured.

The only issue with thils approach is that it only works no server
nodes. In client nodes, the conversion to SID is not available and the
same issues that existed before will still be present.

Tests were updated to reflect these changes, a new test, specific to
idempotence issues of AD objects was added:

   tests/group/test_group_ad_users.yml

Resolves: https://issues.redhat.com/browse/RHEL-70023
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.

3 participants