From 360c37299c314d7626290440cf79fcd0d297306c Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Sun, 8 Jul 2018 14:59:09 +0200 Subject: [PATCH] Install and use gunicorn inside the virtualenv. --- tasks/setup-web-backend.yml | 3 ++- templates/gunicorn_config.py.j2 | 4 ++-- templates/netbox.conf.j2 | 4 ++-- vars/Debian.yml | 2 -- vars/Ubuntu-18.04.yml | 2 -- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tasks/setup-web-backend.yml b/tasks/setup-web-backend.yml index 50265e5..96313fc 100644 --- a/tasks/setup-web-backend.yml +++ b/tasks/setup-web-backend.yml @@ -4,7 +4,8 @@ pip: name: gunicorn extra_args: "--upgrade" - executable: "{{ netbox_pip_binary }}" + virtualenv: "{{ netbox_install_directory }}" + virtualenv_python: "{{ netbox_python_binary }}" - name: configure gunicorn template: diff --git a/templates/gunicorn_config.py.j2 b/templates/gunicorn_config.py.j2 index 984a4dd..41a56f3 100644 --- a/templates/gunicorn_config.py.j2 +++ b/templates/gunicorn_config.py.j2 @@ -1,7 +1,7 @@ # {{ ansible_managed }} -command = '{{ gunicorn_binary_path }}' +command = '{{ netbox_install_directory }}/bin/gunicorn' pythonpath = '{{ netbox_install_directory }}/netbox' bind = '{{ netbox_gunicorn_address }}:{{ netbox_gunicorn_port }}' workers = {{ netbox_gunicorn_workers_number }} -user = '{{ netbox_gunicorn_user }}' \ No newline at end of file +user = '{{ netbox_gunicorn_user }}' diff --git a/templates/netbox.conf.j2 b/templates/netbox.conf.j2 index 415f006..d4a0f2d 100644 --- a/templates/netbox.conf.j2 +++ b/templates/netbox.conf.j2 @@ -1,6 +1,6 @@ # {{ ansible_managed }} [program:netbox] -command = gunicorn -c {{ netbox_install_directory }}/gunicorn_config.py netbox.wsgi +command = {{ netbox_install_directory }}/bin/gunicorn -c {{ netbox_install_directory }}/gunicorn_config.py netbox.wsgi directory = {{ netbox_install_directory }}/netbox/ -user = {{ netbox_supervisor_user }} \ No newline at end of file +user = {{ netbox_supervisor_user }} diff --git a/vars/Debian.yml b/vars/Debian.yml index 0e8775c..300a342 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -38,8 +38,6 @@ become_method_to_use: su postgresql_service: postgresql postgresql_user: postgres -gunicorn_binary_path: /usr/local/bin/gunicorn - supervisord_service: supervisor supervisord_config_directory: /etc/supervisor/conf.d diff --git a/vars/Ubuntu-18.04.yml b/vars/Ubuntu-18.04.yml index b9f187a..85bb519 100644 --- a/vars/Ubuntu-18.04.yml +++ b/vars/Ubuntu-18.04.yml @@ -38,8 +38,6 @@ become_method_to_use: su postgresql_service: postgresql postgresql_user: postgres -gunicorn_binary_path: /usr/local/bin/gunicorn - supervisord_service: supervisor supervisord_config_directory: /etc/supervisor/conf.d