diff --git a/group_vars/constellation.yml b/group_vars/constellation.yml index a9c30bde9b7038d477efe201d32f61422a5a0bf6..97741be92153773ac4bda255c7f8efb37fca512e 100644 --- a/group_vars/constellation.yml +++ b/group_vars/constellation.yml @@ -29,3 +29,33 @@ glob_constellation: version: master settings_local_owner: www-data settings_local_group: nounou + +loc_nginx: + service_name: constellation + ssl: [] + servers: + - ssl: false + default: true + server_name: + - "constellation.crans.org" + - "intranet.crans.org" + locations: + - filter: "/static" + params: + - "alias /var/local/constellation/static/" + + - filter: "/javascript" + params: + - "alias /usr/share/javascript/" + + - filter: "/media" + params: + - "alias /var/local/constellation/media/" + + - filter: "/" + params: + - "uwsgi_pass constellation" + - "include /etc/nginx/uwsgi_params" + upstreams: + - name: 'constellation' + server: 'unix:///var/run/uwsgi/app/constellation/constellation.sock' diff --git a/plays/constellation.yml b/plays/constellation.yml index cb18e246b981acb089d6461e63807b27fcdbad98..068395c6033be599891ca7b3ab04ea5ac26a4ca0 100755 --- a/plays/constellation.yml +++ b/plays/constellation.yml @@ -3,5 +3,8 @@ - hosts: constellation vars: constellation: "{{ glob_constellation | combine(loc_constellation | default({})) }}" + nginx: "{{ glob_nginx | combine(loc_nginx | default({})) }}" roles: - constellation + - nginx + - constellation-front diff --git a/roles/constellation-front/handlers/main.yml b/roles/constellation-front/handlers/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..bc651bf93bfeae0e3a67733d34d0f439924c98d2 --- /dev/null +++ b/roles/constellation-front/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: Reload NGINX + systemd: + name: nginx + state: reloaded + +- name: Reload uWSGI + systemd: + name: uwsgi + state: reloaded diff --git a/roles/constellation-front/tasks/main.yml b/roles/constellation-front/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..def0444cab4bc474f895265a0752fee6d1045e0e --- /dev/null +++ b/roles/constellation-front/tasks/main.yml @@ -0,0 +1,30 @@ +--- +- name: Install uWSGI + apt: + install_recommends: false + update_cache: true + name: + - uwsgi + - uwsgi-plugin-python3 + register: apt_result + retries: 3 + until: apt_result is succeeded + +- name: Copy constellation uWSGI app + template: + src: "uwsgi/apps-available/constellation.ini.j2" + dest: "/etc/uwsgi/apps-available/constellation.ini" + owner: root + group: root + mode: 0644 + notify: Reload uWSGI + +- name: Activate constellation uWSGI app + file: + src: "../apps-available/constellation.ini" + dest: "/etc/uwsgi/apps-enabled/constellation.ini" + owner: root + group: root + state: link + ignore_errors: "{{ ansible_check_mode }}" + notify: Reload uWSGI diff --git a/roles/constellation-front/templates/uwsgi/apps-available/constellation.ini.j2 b/roles/constellation-front/templates/uwsgi/apps-available/constellation.ini.j2 new file mode 100644 index 0000000000000000000000000000000000000000..89906f3aa45b4c7ba28788157c9f9b4468d6f1a4 --- /dev/null +++ b/roles/constellation-front/templates/uwsgi/apps-available/constellation.ini.j2 @@ -0,0 +1,23 @@ +{{ ansible_header | comment }} + +[uwsgi] +uid = www-data +gid = www-data +# Django-related settings +# the base directory (full path) +chdir = /var/local/constellation +wsgi-file = /var/local/constellation/constellation/wsgi.py +plugin = python3 +# process-related settings +# master +master = true +# maximum number of worker processes +processes = 10 +# the socket (use the full path to be safe +socket = /var/run/uwsgi/app/constellation/constellation.sock +# ... with appropriate permissions - may be needed +chmod-socket = 664 +# clear environment on exit +vacuum = true +# Touch reload +touch-reload = /var/local/constellation/constellation/settings.py diff --git a/roles/constellation/tasks/main.yml b/roles/constellation/tasks/main.yml index 1d7f58a8291be48b47130d684beb22410369be50..871944d1c96f078e080a807846f88243454d5ff9 100644 --- a/roles/constellation/tasks/main.yml +++ b/roles/constellation/tasks/main.yml @@ -4,6 +4,7 @@ update_cache: true install_recommends: false name: + - gettext - python3-django - python3-django-crispy-forms - python3-django-extensions @@ -68,3 +69,8 @@ mode: 0660 owner: "{{ constellation.settings_local_owner }}" group: "{{ constellation.settings_local_group }}" + +- name: Compile messages + django_manage: + command: compilemessages + project_path: "/var/local/constellation"