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.75k stars 3.38k forks source link

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

Open absynth76 opened 3 months ago

absynth76 commented 3 months ago

Please confirm the following

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= returned 2 items, expected 1",

there is indeed the same inventory name on 2 different organizations

AWX version

23.9.0

Select the relevant components

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:

Actual results

failing with the message mentioned in the description

Additional information

No response

absynth76 commented 3 months ago

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.