The module awx.awx.inventory is failing to create constructed inventories - Edge case uncaught #15310
Closed
5 of 11 tasks
Labels
community
component:awx_collection
issues related to the collection for controlling AWX
needs_triage
type:bug
Please confirm the following
[email protected]
instead.)Bug Summary
Edge Case
hello, I believe there is an edge case uncaught with the module
awx.awx.inventory
when attempting to add aninput_inventories
which causes the error message below:It's due to the fact the URL built is wrong when adding an
associations
of typeinput_inventories
to a resourceconstructed_inventory
Related discussion: https://forum.ansible.com/t/awx-awx-inventory-is-failing-to-create-constructed-inventories-potential-edge-case/6845
Problematic Code Snippets
I believe the problematic code that caused the URL to be built wrong and cause the
404
to happen is combination of the snippets below inawx/awx_collection/plugins/module_utils/controller_api.py
and
Explanation
In
ControllerAPIModule.create_if_needed(self)
(code ref link)The url and the body for the POST call
will yield the successful response
this is then stored in
item_url
which used to build the associationsub_endpoint
(code ref link)`sub_endpoint=/api/v2/constructed_inventories//input_inventories
then later on, when
self.get_all_endpoint(association_endpoint)
which callsresponse = self.get_endpoint(endpoint, *args, **kwargs)
with this/api/v2/constructed_inventories/<id>/input_inventories
it will cause the 404 as that enpoint isn't defined.Hope this makes sense. Please let me know what the action items are from this, or suggested course of action I can take.
FYI @TheRealHaoLiu @relrod (@cidrblock fom AnsibleFest 2024 conference Denver, US )
AWX version
22.0.0
Select the relevant components
Installation method
kubernetes
Modifications
no
Ansible version
2.17.1
Operating system
No response
Web browser
No response
Steps to reproduce
ANSIBLE_KEEP_REMOTE_FILES=1 ansible localhost -m awx.awx.inventory -a '<module_args>' -vvv
cd /path/to/temporary/file
python AnsiballZ_inventory.py explode
python AnsiballZ_inventory.py execute
this assumes an inventory already exists when added to the
input_inventory
field.used arguments:
Expected results
The built URL should be
inventories/<id>/input_inventories
when adding association of typeinput_inventories
to aconstruced_inventory
Actual results
Additional information
#13448
Commit: e22967d
The text was updated successfully, but these errors were encountered: