Skip to content

Conversation

john-westcott-iv
Copy link
Member

Description

  • What is being changed?
    Attempting to decouple apps from the rbac app.

  • Why is this change needed?
    Devs may want to include apps w/o including the rbac app.

  • How does this change address the issue?
    Removes direct import from ansible_base.rbac but keeps functionally by checking if ansible_base.rbac is installed.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test update
  • Refactoring (no functional changes)
  • Development environment change
  • Configuration change

Self-Review Checklist

  • I have performed a self-review of my code
  • I have added relevant comments to complex code sections
  • I have updated documentation where needed
  • I have considered the security impact of these changes
  • I have considered performance implications
  • I have thought about error handling and edge cases
  • I have tested the changes in my local environment

Testing Instructions

Prerequisites

Steps to Test

Expected Results

Additional Context

Required Actions

  • Requires documentation updates
  • Requires downstream repository changes
  • Requires infrastructure/deployment changes
  • Requires coordination with other teams
  • Blocked by PR/MR: #XXX

Screenshots/Logs

@john-westcott-iv john-westcott-iv changed the title Decoupling apps from ansible_base.rbac [AAP-54064] Decoupling apps from ansible_base.rbac Sep 22, 2025
Copy link

@john-westcott-iv john-westcott-iv force-pushed the AAP-54064-2 branch 2 times, most recently from cd97257 to 302d51e Compare September 22, 2025 17:53
Copy link

DVCS PR Check Results:

PR appears valid (JIRA key(s) found)

User = get_user_model()


is_rbac_installed = 'ansible_base.rbac' in settings.INSTALLED_APPS
Copy link
Member

Choose a reason for hiding this comment

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

I really want to stop doing this referencing of settings. on import. It's an import circularity problem, and here you don't need it anyway. You can make this into a method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea we do this all over. We might want to just have a generic method like is_dab_app_installed('rbac')

_service_id = str(service_obj.pk)
else:
# Create a ServiceID if none exists
service_obj = ServiceID.objects.create()
Copy link
Member

Choose a reason for hiding this comment

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

Oh, this is a major thing I had on my agenda.

https://issues.redhat.com/browse/AAP-51352

I had assumed we couldn't do it like this. But I'm not saying no.

"shared.user": ResourceTypeProcessor,
}
if 'ansible_base.rbac' in settings.INSTALLED_APPS:
processors["shared.roledefinition"] = RoleDefinitionProcessor
Copy link
Member

Choose a reason for hiding this comment

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

👍 agreed.

This should cause no ill-effects. For the major services, we simply don't care about the case that the RBAC app is not installed.

Copy link
Member

Choose a reason for hiding this comment

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

I somewhat disagree with this. There is no problem with making requests to the RBAC related endpoints when RBAC is not installed locally.

Some methods are still invalid to call, but not all of these.

def to_internal_value(self, data):
if 'ansible_base.rbac' not in settings.INSTALLED_APPS:
raise RuntimeError("LenientPermissionSlugListField requires ansible_base.rbac to be installed")
from ansible_base.rbac.models import DABPermission
Copy link
Member

Choose a reason for hiding this comment

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

this seems entirely unnecessary. The rest of changes in this file, yes.


logger = logging.getLogger('ansible_base.resources_api.tasks.sync')

_is_rbac_installed = 'ansible_base.rbac' in settings.INSTALLED_APPS
Copy link
Member

Choose a reason for hiding this comment

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

Here too, I want to bring this in-line.

@john-westcott-iv john-westcott-iv changed the title [AAP-54064] Decoupling apps from ansible_base.rbac [WIP] [AAP-54064] Decoupling apps from ansible_base.rbac Sep 29, 2025
@AlanCoding
Copy link
Member

I put my review comments in john-westcott-iv#11

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.

2 participants