ovh/the-bastion-ansible-wrapper

AWX: problem getting vars without unsing ansible_host

Opened this issue · 0 comments

Hi,

I'm using AWX with the bastion_vars in group variables and it's not working.

After searching in the code, I found the problem.
In the "awx_get_vars" function, the "ansible_host" variable is used to identify the host and I'm not using it.

My inventory looks like that

[servers]
serv01.example.net
serv02.example.net

In the lib.py file, line 224, I changed:

# this should not happen
if not host:
    return {}

with this:

# maybe ansible_host is not define
if not host:
    for k, v in inv.get("_meta", {}).get("hostvars", {}).items():
        if k == host_ip:
            host = k
            host_vars = v
            break

    # this should not happen
    if not host_vars:
        return {}

With this change, it's working.
I don't think this will break other things but I let more experienced people check that.

Thank you