Unable to delete Inventory in Ansible Automation Platform, stuck in Pending Delete.

Solution Verified - Updated -

Environment

  • Ansible Automation Platform 2.3+

Issue

  • Deleting an inventory is in Pending Delete state.

Resolution

1) run the following API endpoint to find if there is any running/pending jobs using the inventory:

https://[AAP FQDN]/api/v2/jobs/?not__status=successful&not__status=failed&not__status=error&not__status=canceled&inventory=[INVENTORY ID]

Replace [INVENTORY ID] with the failed inventory ID
Cancel all resulted jobs or wait for them to finish.

2) Run the following commands to delete any pending deletion and delete the inventory :

# awx-manage shell_plus
>>> Inventory.objects.filter(pending_deletion=True).update(pending_deletion=False)

>>> Inventory.objects.filter(id=inventoryId).delete()

Replace inventoryId with the failed inventory ID

Root Cause

  • 1) The inventory delete pending issue could happen if the deleted inventory contains large number of hosts with big number of saved facts or there is a running/pending jobs using the inventory.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments