Skip to content

infra.aap_configuration.gateway_role_team_assignments fails to retrieve team from organization #1288

@daleroux

Description

@daleroux

Issue
When trying to assign an Org Role to a Team using the infra.aap_configuration (4.2.0) collection, it fails to retrieve the Team if there is more than one Team with the same name.

I am copying below the content from https://issues.redhat.com/browse/AAP-63115

Steps to Reproduce

  1. Configure your project directory as follows:

collections
requirements.yml
aap-config
infra.aap_configuration.yml
configs
auth.yml
gateway_role_team_assignments.yml
organizations.yml
teams.yml
requirements.yml


collections:

  • name: ansible.platform
  • name: ansible.hub
  • name: ansible.controller
    version: ">=4.6.0"
  • name: ansible.eda
  • name: infra.aap_configuration
    infra.aap_configuration.yml

  • name: Playbook to configure an Organization
    hosts: localhost
    gather_facts: false
    pre_tasks:
    • name: Include vars
      ansible.builtin.include_vars:
      dir: "{{ includeVarsFolder }}"
      extensions: ["yml"]
      tasks: - name: Include organization
      ansible.builtin.include_role:
      name: infra.aap_configuration.gateway_organizations
      when: hostvars[inventory_hostname]['aap_organizations'] is defined - name: Include teams
      ansible.builtin.include_role:
      name: infra.aap_configuration.gateway_teams
      when: hostvars[inventory_hostname]['aap_teams'] is defined - name: Include credentials
      ansible.builtin.include_role:
      name: infra.aap_configuration.controller_credentials
      when: hostvars[inventory_hostname]['controller_credentials'] is defined - name: Include inventories
      ansible.builtin.include_role:
      name: infra.aap_configuration.controller_inventories
      when: hostvars[inventory_hostname]['controller_inventories'] is defined - name: Include hosts
      ansible.builtin.include_role:
      name: infra.aap_configuration.controller_hosts
      when: hostvars[inventory_hostname]['controller_hosts'] is defined - name: Include team controller roles
      ansible.builtin.include_role:
      name: infra.aap_configuration.controller_roles
      when: hostvars[inventory_hostname]['controller_roles'] is defined - name: Include gateway_role_team_assignments
      ansible.builtin.include_role:
      name: infra.aap_configuration.gateway_role_team_assignments
      when: hostvars[inventory_hostname]['gateway_role_team_assignments'] is defined - name: include authenticator_maps
      ansible.builtin.include_role:
      name: infra.aap_configuration.gateway_authenticator_maps
      when: hostvars[inventory_hostname]['gateway_authenticator_maps'] is defined - name: List applied roles
      ansible.builtin.debug:
      msg:
      • "{% if hostvars[inventory_hostname]['aap_organizations'] is defined %}infra.aap_configuration.gateway_organizations{% endif %}"
      • "{% if hostvars[inventory_hostname]['aap_teams'] is defined %}infra.aap_configuration.gateway_teams{% endif %}"
      • "{% if hostvars[inventory_hostname]['controller_credentials'] is defined %}infra.aap_configuration.controller_credentials{% endif %}"
      • "{% if hostvars[inventory_hostname]['controller_inventories'] is defined %}infra.aap_configuration.controller_inventories{% endif %}"
      • "{% if hostvars[inventory_hostname]['controller_hosts'] is defined %}infra.aap_configuration.controller_hosts{% endif %}"
      • "{% if hostvars[inventory_hostname]['controller_roles'] is defined %}infra.aap_configuration.controller_roles{% endif %}"
      • "{% if hostvars[inventory_hostname]['gateway_authenticator_maps'] is defined %}infra.aap_configuration.gateway_authenticator_maps{% endif %}"
        auth.yml

aap_hostname: my.gateway.node
aap_username: admin
aap_password: password
aap_validate_certs: false
gateway_role_team_assignments.yml


gateway_role_team_assignments:

  • assignment_objects:
    • name: Org1
      type: organizations
      role_definition: Organization Inventory Admin
      team: TeamA
      organizations.yml

aap_organizations:

  • name: Org1
  • name: Org2
    teams.yml

aap_teams:

  • name: TeamA
    organization: Org1
  • name: TeamA
    organization: Org2
  1. In AAP, create a job template as follows

Name: gateway_role_team_assignments
Organization: Default
Inventory: Demo Inventory
Projects:
Execution environment: Default Exeution Environment
Playbook: aap-config/infra.aap_configuration.yml
Extra vars: includeVarsFolder: configs
Verbosity: 2 (optional)
3) Ensure project is synced and contains the collections in the requirements.yml

  1. Run the job

Expected Behavior
Orgs/Teams are created and the Inventory Admin role is assigned to the team

Actual Behavior
Orgs/Teams are created, but the Inventory Admin role is not assigned due to the following error: (also attached the entire output to this Jira)

TASK [infra.aap_configuration.collect_async_status : Create/Update Role Team Assignments Organization Inventory Admin | Wait for finish the Role Team Assignments creation] ***
task path: /runner/requirements_collections/ansible_collections/infra/aap_configuration/roles/collect_async_status/tasks/main.yml:5
FAILED - RETRYING: [localhost]: Create/Update Role Team Assignments Organization Inventory Admin | Wait for finish the Role Team Assignments creation (50 retries left).
fatal: [localhost]: FAILED! => {"ansible_job_id": "j34676163412.400", "attempts": 2, "changed": false, "finished": 1, "msg": "Request to ParseResult(scheme='https', netloc='10.0.110.223', path='api/gateway/v1/teams/', params='', query='name=TeamA', fragment='') returned 2 items, expected 1", "query": {"name": "TeamA"}, "response": {"json": {"count": 2, "next": null, "previous": null, "results": [{"created": "2026-01-19T17:47:12.581282Z", "created_by": 2, "description": "", "id": 8, "modified": "2026-01-19T17:47:12.581262Z", "modified_by": 2, "name": "TeamA", "organization": 13, "related": {"activity_stream": "/api/gateway/v1/activitystream/?content_type=11&object_id=8", "admins": "/api/gateway/v1/teams/8/admins/", "created_by": "/api/gateway/v1/users/2/", "modified_by": "/api/gateway/v1/users/2/", "organization": "/api/gateway/v1/organizations/13/", "users": "/api/gateway/v1/teams/8/users/"}, "summary_fields": {"created_by": {"first_name": "", "id": 2, "last_name": "", "username": "admin"}, "modified_by": {"first_name": "", "id": 2, "last_name": "", "username": "admin"}, "organization": {"id": 13, "name": "Org1"}, "resource": {"ansible_id": "1100c91b-4725-4bac-953f-7a94bd2beddc", "resource_type": "shared.team"}}, "url": "/api/gateway/v1/teams/8/"}, {"created": "2026-01-19T17:47:12.855403Z", "created_by": 2, "description": "", "id": 9, "modified": "2026-01-19T17:47:12.855375Z", "modified_by": 2, "name": "TeamA", "organization": 14, "related": {"activity_stream": "/api/gateway/v1/activitystream/?content_type=11&object_id=9", "admins": "/api/gateway/v1/teams/9/admins/", "created_by": "/api/gateway/v1/users/2/", "modified_by": "/api/gateway/v1/users/2/", "organization": "/api/gateway/v1/organizations/14/", "users": "/api/gateway/v1/teams/9/users/"}, "summary_fields": {"created_by": {"first_name": "", "id": 2, "last_name": "", "username": "admin"}, "modified_by": {"first_name": "", "id": 2, "last_name": "", "username": "admin"}, "organization": {"id": 14, "name": "Org2"}, "resource": {"ansible_id": "5ff18057-8c50-4735-aa98-894fb8b9dbaf", "resource_type": "shared.team"}}, "url": "/api/gateway/v1/teams/9/"}, "...more results snipped..."]}, "status_code": 200}, "results_file": "/home/runner/.ansible_async/j34676163412.400", "started": 1, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": [], "total_results": 2}
...ignoring
Additional Info
The problem lies in the fact that these new roles do not have the "lookup_organization" method and since the team name isn't a unique property inside the AAP platform

This used to work in AAP 2.5 with the following configuration

controller_roles:

  • teams:
    • TeamA
      organization: Org1
      lookup_organization: Org1
      roles:
    • project_admin
    • inventory_admin
    • credential_admin
    • workflow_admin
    • notification_admin
    • job_template_admin
    • approval
    • auditor
    • execute

```yaml (config/list/array/variables)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions