Proper way to run AWX against hosts: localhost

I have a simple job, that connects to k8s. The openshift module is installed to /var/lib/awx/venv/ansible/

When running the playbook, it fails, being unable to find the openshift module. I had read a couple github issues, relating to this but cant seem to resolve my problem.

its def. not using the proper venv.

vars:
ansible_playbook_python: /var/lib/awx/venv/ansible/bin/python
ansible_python_interpreter: “{{ ansible_playbook_python }}”

TASK [overcorps : Debug Python] ************************************************
15:52:47
67
task path: /var/lib/awx/projects/_34__justin_test/roles/overcorps/tasks/main.yml:9
68
ok: [localhost] => {
69
“ansible_python_interpreter”: “/usr/bin/python2”
70
}
71
72
TASK [overcorps : Debug Python] ************************************************
15:52:47
73
task path: /var/lib/awx/projects/_34__justin_test/roles/overcorps/tasks/main.yml:13
74
ok: [localhost] => {
75
“ansible_playbook_python”: “/usr/bin/python2”
76
}

[root@awx ~]# source /var/lib/awx/venv/ansible/bin/activate
(ansible) [root@awx ~]# python
Python 2.7.5 (default, Jun 20 2019, 20:27:34)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

Not trying to be annoying but rather complete, did you set the Ansible Environment value in the dropdown on the Job Template before running the job? It could be that the default Ansible Environment was set to another venv as part of your Organization config.

Also, did you install the openshift module in the same location on both the web and task container?

Are you running this task locally on AWX or on another server? If the server that actually runs the task doesn’t have the openshift module installed locally I think you’ll get an error message that looks like that.

And finally, what steps did you take to install openshift in the first place? That’ll help to replicate the problem.

The venv is set correctly in awx, I can see it in the UI.

Openshift is there.

Task is targeted to hosts: localhost

During image build, venv is activated, pip modules ran, unask set per the docs.

It works in every situation until we target localhost. You can see from the previous debug, it’s using the incorrect python path, despite is being set to the venv.