awx
awx copied to clipboard
Ansible awx.awx collection tasks altering configuration for a pre-existing inventory should be organization scope aware
Please confirm the following
- [X] I agree to follow this project's code of conduct.
- [X] I have checked the current issues for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.
- [X] I am NOT reporting a (potential) security vulnerability. (These should be emailed to
[email protected]
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
- [X] 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
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.