I am trying to come up with a host filter query in awx that is able to filter for a value in a key contained in the variables field of my inventory.
My variable field looks something like this:
{
"variables": "{..., \"labels\": {\"automation\": \"awx\"}, ...}"
}
My current host filter like this:
https://my-awx.com/api/v2/hosts/?host_filter=variables__icontains=automation
Using the filter above, I at least am able to receive the corresponding instance, however I'd like to be able to filter for more than automation
. Ultimately I'd like to receive all instances whose automation
label has the key awx
and integrate them into a smart inventory.
One additional question: Is there better documentation available then https://docs.ansible.com/ansible-tower/latest/html/towerapi/filtering.html? I feel like it is missing such details as contained in my question.
Best regards, stiller-leser
According to this issue: https://github.com/ansible/awx/issues/371 it doesn't look like it's supported yet.
One suggested workaround:
You can build your inventory, using a dynamic script or otherwise, and then create a playbook that caches the desired host variables as ansible facts.