Bug 2169838

Summary: ipahbacrule module is not idempotent.
Product: Red Hat Enterprise Linux 9 Reporter: Rafael Jeffman <rjeffman>
Component: ansible-freeipaAssignee: Rafael Jeffman <rjeffman>
Status: CLOSED MIGRATED QA Contact: Varun Mylaraiah <mvarun>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.2CC: mvarun
Target Milestone: rcKeywords: MigratedToJIRA
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-18 22:37:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rafael Jeffman 2023-02-14 18:10:44 UTC
ipahbacrule module fails to execute if hbacsvcgroup has uppercase letters.

Reproducer:

1. Given the playbook "hbac_reproducer.yml":

```
---
- name: ipahbacrule idempotence issue reproducer
  host: ipaserver
  become: false
  gather_facts: false

  tasks:
  - name: Ensure hbacsvcgroup Sudo is present.
    ipahbacsvcgroup:
      ipaadmin_password: SomeADMINpassword
      name: Sudo
      state: present

  - name: Ensure hbacrule with hbacsvcgroup is present.
    ipahbacrule:
      ipaadmin_password: SomeADMINpassword
      name: reproducer
      hbacgroup: sudo
 
  - name: Ensure hbacrule with hbacsvcgroup is present.
    ipahbacrule:
      ipaadmin_password: SomeADMINpassword
      name: reproducer
      hbacgroup: sudo
```

2. Execute the playbook against an IPA server:

$ ansible-playbook -i inventory hbac_reproducer.yml

3. The result will be that at least one of the 'ipahbacrule' modules will fail with message "hbacrule_add_service: hbacsvcgroup sudo: This entry is already a member".


Initial investigation:

By debugging the issue, one can see that the command in the task that succeeds is:

* ['all-users/sudo', 'hbacrule_add_service', {'hbacsvc': [], 'hbacsvcgroup': ['sudo']}]]

And the commands in the task that fails are:

* ['all-users/sudo', 'hbacrule_add_service', {'hbacsvc': [], 'hbacsvcgroup': ['sudo']}]
* ['all-users/sudo', 'hbacrule_remove_service', {'hbacsvc': [], 'hbacsvcgroup': ['Sudo']}]

Comment 1 Rafael Jeffman 2023-02-14 18:17:43 UTC
The issue is not reproduced if the hbacsvcgroup is all lowercase:

$ ipa hbacsvcgroup-del Sudo
$ ipa hbacsvcgroup-add sudo --desc="Default group of Sudo related services"
$ ipa hbacsvcgroup-add-member sudo --hbacsvcs=sudo --hbacsvcs=sudo-i

Comment 2 RHEL Program Management 2023-09-18 22:35:48 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 3 RHEL Program Management 2023-09-18 22:37:36 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.