-
-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Currently, the uwsgi
installation isn't done into a virtual environment, but the environment of ansible_python_interpreter
, which may not be using the same python binary that the NetBox venv is using.
This task installs uwsgi
and happens after the NetBox-specific venv has been created.
ansible-role-netbox/tasks/main.yml
Lines 68 to 79 in dbead68
- name: Install uWSGI via pip | |
pip: | |
name: uwsgi | |
state: "{{ 'latest' if netbox_keep_uwsgi_updated else 'present' }}" | |
umask: "0022" | |
environment: | |
PATH: "/usr/local/bin:{{ _path }}" | |
notify: | |
- reload netbox.service | |
retries: 2 | |
register: _netbox_uwsgi_install | |
until: _netbox_uwsgi_install is succeeded |
I propose adding virtualenv: "{{ netbox_virtualenv_path }}"
to that task to ensure it's installed using the same venv as the rest of the app.
Additionally, the systemd service template relies on /usr/bin/env
, which doesn't have any awareness of the venv as currently written.
ansible-role-netbox/templates/netbox.service.j2
Lines 8 to 9 in dbead68
[Service] | |
ExecStart=/usr/bin/env uwsgi --ini {{ netbox_shared_path }}/uwsgi.ini |
If the above task is modified to install uwsgi
into the venv, then the template could be adjusted to use
ExecStart={{ netbox_virtualenv_path }}/bin/uwsgi --ini {{ netbox_shared_path }}/uwsgi.ini`
All in all this would give users more flexibility in using Python versions from different sources (altinstall, pyenv, package managers, etc).
Something would probably need to be modified with this task as well but we'd likely need to decouple it from netbox_python_binary
(and possibly other tasks).
ansible-role-netbox/tasks/install_packages_yum.yml
Lines 28 to 35 in dbead68
- name: Install psycopg2/selinux via pip on Red Hat-based distros | |
pip: | |
name: | |
- psycopg2-binary | |
- selinux | |
state: present | |
vars: | |
ansible_python_interpreter: "{{ netbox_python_binary }}" |