<p>AWX is running in a docker container, isn't it?</p>
<p>If you make a venv on your ansible controller with python3.9 it still won't be functional.  To get this to work, you will have to add your actual host (which seems insecure ) to your inventory and have a method to log on to it.</p>
<p>The best way around this, that I can think of, would be to upgrade python on your docker container running AWX, probably don't need a venv on the container, but that might be best practice.</p>
<hr />
<p>Also, <code>hosts: localhost</code> implies <code>connection: local</code> so that part is redundant, unless there's a reason it's not (like a global variable setting <code>connection: ssh</code>)</p>

CC BY-SA 4.0
2023-11-06T05:22:58.433Z
2023-11-06T05:22:58.433Z
Peter Turner
<p>I updated a recent playbook module that says I need to use at least Python version  3.8.  I run this playbook on our AWX controller.  When I run the cmd module and do a &quot;which python3&quot; I get back version 3.6 in /var/lib/awx/venv/ansible/bin/python3.  I tried doing a pre_task to install python3.9 using the yum module, and I see in the output that it gets installed.</p>
<p>I thought I could use the &quot;var: ansible_python_interpreter: <em>path</em>
but I need to find out where new versions of python get installed. Do you know where python gets installed within the AWX controller when running a playbook to install it?</p>
<pre><code>---
- name: Test commands
  hosts: localhost
  connection: local
  gather_facts: false

  pre_tasks:
    - name: install Python 
      ansible.builtin.yum:
        name: python3.9
        state: present
      become: yes
      delegate_to: localhost  
      

- name: Configure Avi Controller
  hosts: localhost
  connection: local
  collections:
    - cyberark.pas
    - vmware.alb
  vars:
    ansible_python_interpreter: /var/lib/awx/venv/ansible/bin/python3.9
  tasks:
</code></pre>
<p>When I run this I get &quot;/var/lib/awx/venv/ansible/bin/python3.9 file or directory does not exist&quot;</p>

<ansible><python><awx>
Using a different Python version in AWX
David Desjardins
# Using a different Python version in AWX

(Asked by: username_0 on 2023-03-23)

I updated a recent playbook module that says I need to use at least Python version  3.8.  I run this playbook on our AWX controller.  When I run the cmd module and do a "which python3" I get back version 3.6 in /var/lib/awx/venv/ansible/bin/python3.  I tried doing a pre_task to install python3.9 using the yum module, and I see in the output that it gets installed.
I thought I could use the "var: ansible_python_interpreter: path
but I need to find out where new versions of python get installed. Do you know where python gets installed within the AWX controller when running a playbook to install it?
---
- name: Test commands
  hosts: localhost
  connection: local
  gather_facts: false

  pre_tasks:
    - name: install Python 
      ansible.builtin.yum:
        name: python3.9
        state: present
      become: yes
      delegate_to: localhost  
      

- name: Configure Avi Controller
  hosts: localhost
  connection: local
  collections:
    - cyberark.pas
    - vmware.alb
  vars:
    ansible_python_interpreter: /var/lib/awx/venv/ansible/bin/python3.9
  tasks:

When I run this I get "/var/lib/awx/venv/ansible/bin/python3.9 file or directory does not exist"

**Tags:** ansible, python, awx


---

## 1 answers

### Answer by username_1 on 2023-11-06. Score: 1

AWX is running in a docker container, isn't it?

If you make a venv on your ansible controller with python3.9 it still won't be functional. To get this to work, you will have to add your actual host (which seems insecure ) to your inventory and have a method to log on to it.

The best way around this, that I can think of, would be to upgrade python on your docker container running AWX, probably don't need a venv on the container, but that might be best practice.

---

Also, `hosts: localhost` implies `connection: local` so that part is redundant, unless there's a reason it's not (like a global variable setting `connection: ssh`)


---

