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

Ansible awx.awx collection tasks altering configuration for a pre-existing inventory should be organization scope aware #15117

Open
5 of 11 tasks
absynth76 opened this issue Apr 18, 2024 · 1 comment
Labels
community component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug

Comments

@absynth76
Copy link

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to security@ansible.com instead.)

Bug Summary

collection version 24.2.0
AWX version 23.9.0

If (at least) 2 inventories with the same name exist, the awx.awx.host task is looping with an error:
"msg": "Request to /api/v2/inventories/?name=<duplicated_name> returned 2 items, expected 1",

there is indeed the same <duplicated_name> inventory name on 2 different organizations

AWX version

23.9.0

Select the relevant components

  • UI
  • UI (tech preview)
  • API
  • Docs
  • Collection
  • CLI
  • Other

Installation method

kubernetes

Modifications

no

Ansible version

ansible [core 2.16.2]

Operating system

wsl - fedoraremix

Web browser

No response

Steps to reproduce

create 2 inventories with the same name on 2 different organization, example:

- name: Create duplicated inventory
  awx.awx.inventory:
      name: "DuplicatedInventoryName"
      description: "duplicate name inventory"
      organization: "{{ item }}"
      state: present
  loop:
    - 'org1'
    - 'org2'

and try to add host to one of them

- name: Add host to inventory
  awx.awx.host:
      name: "localhost"
      inventory: "DuplicatedInventoryName"
      state: present

will result in the error mentioned in the description of this issue

Expected results

mutltiple choices here:

  • alter all inventories with the same name if organization is not specified, mentioning the amount of inventory altered in the msg result
  • alter the target inventory at the condition 'organization' (TBD variable name) filter is provided to the task

Actual results

failing with the message mentioned in the description

Additional information

No response

@github-actions github-actions bot added component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug community labels Apr 18, 2024
@absynth76
Copy link
Author

As a workaround I use the inventory id returned by the inventory task, but an organization filter remains relevant on tasks that are referencing a configuration item by their name.

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

No branches or pull requests

1 participant