Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWX: problem getting vars without unsing ansible_host #27

Open
pierredemain opened this issue Apr 26, 2024 · 0 comments
Open

AWX: problem getting vars without unsing ansible_host #27

pierredemain opened this issue Apr 26, 2024 · 0 comments

Comments

@pierredemain
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant