Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awx_collection: Adding inventory source with duplicated project name fails in 'multi-tenant' like environment #10571

Closed
Tompage1994 opened this issue Jul 1, 2021 · 2 comments
Assignees
Labels
component:awx_collection issues related to the collection for controlling AWX type:bug

Comments

@Tompage1994
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • awx_collection
SUMMARY

Adding an inventory source of type scm fails when the source_project has the same name as another project in another organization. This therefore fails in a multi-tenant environment.

ENVIRONMENT
  • AWX collection version: 19.2.2
STEPS TO REPRODUCE
  • Create 2 orgs
  • Create a project and copy it so there is one in each org with the same name.
  • Create an inventory in one org
  • Use the awx.awx.inventory_source as below:
- awx.awx.inventory_source:
        name: is1
        source: scm
        source_project: Demo Project
        organization: Default
        inventory: Demo Inventory
EXPECTED RESULTS

It should use the organization which is used for the inventory by default, but you should also be able to specify the source_project's org.

ACTUAL RESULTS
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Request to /api/v2/projects/?name=Demo+Project returned 2 items, expected 1", "query": {"name": "Demo Project"} ...
@shanemcd
Copy link
Member

shanemcd commented Jul 2, 2021

Probably just need to add the organization to the query params here.

@beeankha beeankha added component:awx_collection issues related to the collection for controlling AWX state:needs_test labels Jul 26, 2021
@john-westcott-iv
Copy link
Member

With the merged PR solving the crash and the ability to look up items with the lookup module we are going to close this issue. For reference, as mentioned in the PR, once can lookup objects using the lookup module like:

  - name: create INVSOURCE
    inventory_source:
      name: inv1
      source: scm
      source_project: "{{ lookup('awx.awx.controller_api', 'projects', query_params={'name': 'Demo Project', 'organization__name':'org1'}, return_ids=True )}}"
      organization: Default
      inventory: Demo Inventory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:awx_collection issues related to the collection for controlling AWX type:bug
Projects
None yet
Development

No branches or pull requests

5 participants