ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.83k stars 3.39k forks source link

Normal user Can't choose project for adding inventory source to inventory #13948

Open lutskevich opened 1 year ago

lutskevich commented 1 year ago

Please confirm the following

Bug Summary

Normal user with inventory admin/use and project admin/use permissions Can't choose project for inventory source image image

AWX version

22.1.0

Select the relevant components

Installation method

kubernetes

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

Go to inventories, choose or create inventory Next going to Sources - Add Source - Source from a Project Project - field blocked

Expected results

Pick a project with inventory file

Actual results

Project Field is blocked

Additional information

No response

mabashian commented 1 year ago

@AlanCoding in determining whether or not to disable this field in the UI we're looking at whether or not a user can create a project: https://github.com/ansible/awx/blob/devel/awx/ui/src/components/Lookup/ProjectLookup.js#L61-L63 (whether or not POST is present in the options actions). Is that correct or should we be looking at something different there? Seems like we should be checking to see if the user in question has at least use role on at least one project to determine whether or not to disable this lookup. Is that correct?

AlanCoding commented 1 year ago

^ that sounds right. A user can have use_role to a project without having the project_admin_role necessary to create new projects which is what would dictate the POST presentation in OPTIONS.

But from a UX perspective, if you have already selected the other box to source the inventory from a project, then the form will be invalid without a project filled in. I'm not sure if I see a lot of value in greying out the box in the first place, because if the source is selected to be any option other than source-from-project then the box (to select project) should be hidden.

jedthe3rd commented 3 months ago

I ran into this issue in AAP at work. Is there any more testing needed to narrow down the issue or does a implementation just need to be decided on?

hxp-plus commented 1 month ago

I ran into the same issue on AWX version 23.9, please check that the user you mentioned has use permission for at least one project with a valid ansible playbook.

It seems that for each Git projects, if the project does not contain at least one ansible playbook, AWX will mark the project as "invalid" and hide it as if it doesn't exist.

In my case, I created an organization test and a team test, the user test is a member of test team, and a member of test organization. I created a project that has no ansible playbooks, only ansible inventories, called "awx". And I gave the inventory manager permission to test team, created an inventory and tried to add invenroty source via "Sourced from project", and found the project selector disabled just like this : image

then I added another project called test with a valid ansible playbook, the disabled button is still disabled but displayed "test":

Weixin Image_20240708223426

And in that case, the test user has use permission of 2 projects, awx and test :

Weixin Image_20240708223534

Project awx doesn't has an ansible playbook, while project test has. So the only option that can be selected in the selector is test project.

So the solution of the problem is to make sure each of the projects which test user has use permission, has at least one ansible playbook in the project.