AWX smart inventory with Ansible Local Facts?

I’m a great fan of Ansible’s Local Facts which may stem from the fact that Seth and I had a few beers over the idea just before he wrote the code back in 2013. Yeah, that dates me.

Anyhow, I’m trying to create an AWX smart inventory based off such facts, and have the following data in the fact cache of one of a host:

  "ansible_system": "Linux",
  "ansible_local": {
    "nn": "00",
    "huuid": "c62969f0-4a71-4179-93fd-cb9e0cf0d3df",
    "owner": {
      "username": "Jane"

I can invoke the APi to find Linux hosts with


but no amount of any of this works:


Does anybody know what the magic incantation might be?

(BTW, what worries me is that a search for "ansible_facts__ansible_local" in the ansible/awx repo returns 0 hits.)

I have only done a very simple test on localhost, but it seems to work in my environment.

$ curl -sk --user admin:******** | jq -r '.results[].name'

Can you see stored value in ansible_local in Facts tab for your host in your inventory?

1 Like

Thank you, @kurokobo. As usual, just after typing in the question I realized: “beginner error”. I was querying the API in a Web browser which was logged into AWX as a different user as the user whom the inventory belongs to!

I do see the values in the Facts cache (tab for the host), and it works.


AWX uses just split("__") and for loop without any hard-coded fact names. This is off-topic, though :smiley:

1 Like

While it might be off-topic, it’s a big help to me; I’ve always wondered why on earth the double underscore was used instead of simply using the period as separator we’ve all been used to.

Your mention of split("__") makes it a bit more logical. :blush:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.