Skip to content

Install uwsgi in venv and point service file to venv binary #144

@tyler-8

Description

@tyler-8

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.

- 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.

[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).

- 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 }}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions