How To Assign A Team Member As Team Admin In Ansible Tower?
Environment
- Red Hat Ansible Automation Platform
Issue
- Not able to assign Team Admin role from Tower UI.
Resolution
-
Starting with Ansible Tower
3.5.xyou can add user to a team only as a member from UI. -
You can refer to below documentation for more information here
Snip from link :
Adding a user to a team adds them as a member only, specifying a role for the user on different resources (other than team) can be done in the Permissions tab. -
But you can still grant a team admin role to the user using
API.
Associate Roles with this User
Example: #Assign Team Admin role to a user.
-
Navigate to your team API endpoint.
(https://TOWER_URL/api/v2/teams/N/)Under object_roles, you'll see the available roles. Note that the role IDs are unique for every Tower objects.https://TOWER_URL/api/v2/teams/N/object_roles/<<-- Here N is the ID of your team.{ "count": 3, "next": null, "previous": null, "results": [ { "id": 85, "type": "role", "url": "/api/v2/roles/85/", "related": { "users": "/api/v2/roles/85/users/", "teams": "/api/v2/roles/85/teams/", "team": "/api/v2/teams/1/" }, "summary_fields": { "resource_name": "test_team", "resource_type": "team", "resource_type_display_name": "Team" }, "name": "Admin", "description": "Can manage all aspects of the team" }, { "id": 86, "type": "role", "url": "/api/v2/roles/86/", "related": { "users": "/api/v2/roles/86/users/", "teams": "/api/v2/roles/86/teams/", "team": "/api/v2/teams/1/" }, "summary_fields": { "resource_name": "test_team", "resource_type": "team", "resource_type_display_name": "Team" }, "name": "Member", "description": "User is a member of the team" }, { "id": 87, "type": "role", "url": "/api/v2/roles/87/", "related": { "users": "/api/v2/roles/87/users/", "teams": "/api/v2/roles/87/teams/", "team": "/api/v2/teams/1/" }, "summary_fields": { "resource_name": "test_team", "resource_type": "team", "resource_type_display_name": "Team" }, "name": "Read", "description": "May view settings for the team" } ] } -
To assign Team Admin role, i.e the role ID 85 to a user, use below API curl command (Please replace
<TOKEN>to your actual token):curl -k -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" -X POST -d '{"id": 85}' https://TOWER-URL/api/v2/users/N/roles/ <<-- Here N is the user ID
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments