# Proper way to run AWX against hosts: localhost

**URL:** <https://forum.ansible.com/t/proper-way-to-run-awx-against-hosts-localhost/30921>\
**Category:** AWX Project\
**Tags:** kubernetes, awx\
**Created:** [July 31, 2019, 6:25pm UTC](https://forum.ansible.com/t/proper-way-to-run-awx-against-hosts-localhost/30921 "2019-07-31T18:25:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin2](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Justin2](https://forum.ansible.com/u/Justin2)\
**Post date:** [July 31, 2019, 6:25pm UTC](https://forum.ansible.com/t/proper-way-to-run-awx-against-hosts-localhost/30921/1 "2019-07-31T18:25:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Justin2](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Justin2](https://forum.ansible.com/u/Justin2)\
**Post date:** [July 31, 2019, 7:57pm UTC](https://forum.ansible.com/t/proper-way-to-run-awx-against-hosts-localhost/30921/2 "2019-07-31T19:57:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Uriel](https://avatars.discourse-cdn.com/v4/letter/u/53a042/32.png) [@Uriel](https://forum.ansible.com/u/Uriel)\
**Post date:** [August 1, 2019, 3:26pm UTC](https://forum.ansible.com/t/proper-way-to-run-awx-against-hosts-localhost/30921/3 "2019-08-01T15:26:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Justin2](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Justin2](https://forum.ansible.com/u/Justin2)\
**Post date:** [August 1, 2019, 6:29pm UTC](https://forum.ansible.com/t/proper-way-to-run-awx-against-hosts-localhost/30921/4 "2019-08-01T18:29:31Z")

</div>

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.
