From 44b3eec6ea2b08fbc958df377e580f77649c2089 Mon Sep 17 00:00:00 2001 From: Benjamin Graillot <graillot@crans.org> Date: Sun, 10 Jan 2021 13:03:16 +0100 Subject: [PATCH 1/3] [re2o] Install version 1.6.0 of django-macaddress --- roles/re2o/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/re2o/tasks/main.yml b/roles/re2o/tasks/main.yml index dcf13f81..a7b83468 100644 --- a/roles/re2o/tasks/main.yml +++ b/roles/re2o/tasks/main.yml @@ -27,7 +27,7 @@ executable: pip3 name: - django-bootstrap3 - - django-macaddress + - django-macaddress==1.6.0 - name: Create re2o directory file: -- GitLab From 9628a7ece0e39ed8e3f8bcd2e5764edf0bb1cb85 Mon Sep 17 00:00:00 2001 From: Benjamin Graillot <graillot@crans.org> Date: Sun, 10 Jan 2021 13:43:47 +0100 Subject: [PATCH 2/3] [re2o] Fix typo --- roles/re2o/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/re2o/tasks/main.yml b/roles/re2o/tasks/main.yml index a7b83468..11bd270f 100644 --- a/roles/re2o/tasks/main.yml +++ b/roles/re2o/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Install re2o dependencies +- name: Install re2o dependancies apt: update_cache: true name: -- GitLab From 3b81f9d75887277a07d3841ff2657d2f439bcb6e Mon Sep 17 00:00:00 2001 From: Benjamin Graillot <graillot@crans.org> Date: Sun, 10 Jan 2021 14:02:40 +0100 Subject: [PATCH 3/3] [re2o-front] Install re2o frontend dependancies --- plays/re2o.yml | 3 ++ roles/re2o-front/handlers/main.yml | 10 ++++ roles/re2o-front/tasks/main.yml | 47 +++++++++++++++++++ .../templates/nginx/sites-available/re2o.j2 | 35 ++++++++++++++ .../uwsgi/apps-available/re2o.ini.j2 | 27 +++++++++++ 5 files changed, 122 insertions(+) create mode 100644 roles/re2o-front/handlers/main.yml create mode 100644 roles/re2o-front/tasks/main.yml create mode 100644 roles/re2o-front/templates/nginx/sites-available/re2o.j2 create mode 100644 roles/re2o-front/templates/uwsgi/apps-available/re2o.ini.j2 diff --git a/plays/re2o.yml b/plays/re2o.yml index 1aff13b2..adb5a5d3 100755 --- a/plays/re2o.yml +++ b/plays/re2o.yml @@ -5,3 +5,6 @@ re2o: "{{ glob_re2o | combine(loc_re2o) }}" roles: - re2o + +- hosts: re2o.adm.crans.org + roles: ["re2o-front"] diff --git a/roles/re2o-front/handlers/main.yml b/roles/re2o-front/handlers/main.yml new file mode 100644 index 00000000..bc651bf9 --- /dev/null +++ b/roles/re2o-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/re2o-front/tasks/main.yml b/roles/re2o-front/tasks/main.yml new file mode 100644 index 00000000..67a6b5a7 --- /dev/null +++ b/roles/re2o-front/tasks/main.yml @@ -0,0 +1,47 @@ +--- +- name: Install re2o dependancies + apt: + update_cache: true + name: + - gettext + - graphviz + - texlive-fonts-recommended + - texlive-latex-base + register: apt_result + retries: 3 + until: apt_result is succeeded + +- name: Install NGINX and uWSGI + apt: + update_cache: true + name: + - nginx + - uwsgi + - uwsgi-plugin-python3 + register: apt_result + retries: 3 + until: apt_result is succeeded + +- name: Copy re2o NGINX site + template: + src: "nginx/sites-available/re2o.j2" + dest: "/etc/nginx/sites-available/re2o" + +- name: Copy re2o uWSGI app + template: + src: "uwsgi/apps-available/re2o.ini.j2" + dest: "/etc/uwsgi/apps-available/re2o.ini" + +- name: Activate re2o NGINX site + file: + src: "../sites-available/re2o" + dest: "/etc/nginx/sites-enabled/re2o" + state: link + notify: Reload NGINX + +- name: Activate re2o uWSGI app + file: + src: "../apps-available/re2o.ini" + dest: "/etc/uwsgi/apps-enabled/re2o.ini" + state: link + notify: Reload uWSGI diff --git a/roles/re2o-front/templates/nginx/sites-available/re2o.j2 b/roles/re2o-front/templates/nginx/sites-available/re2o.j2 new file mode 100644 index 00000000..77bc8a0f --- /dev/null +++ b/roles/re2o-front/templates/nginx/sites-available/re2o.j2 @@ -0,0 +1,35 @@ +upstream re2o { + # Path of the unix socket. For example : + server unix:///var/run/uwsgi/app/re2o/re2o.sock; +} + +server { + listen 80; + listen [::]:80; + + server_name {{ (query('ldap', 'ip', 're2o', 'adm') | ipv4)[0] }} re2o.adm.crans.org intranet.crans.org intranet.infra.crans.org; # Modify this value according to your infrastructure. + charset utf-8; + + server_tokens off; + + location /static { + # Alias the path to the static files. For instance, + alias /var/www/re2o/static_files/; + } + + location /javascript { + # Alias the path to the static files. For instance, + alias /usr/share/javascript/; + } + + location /media { + alias /var/www/re2o/media/; + } + + location / { + uwsgi_pass re2o; + # Include the uwsgi_params file. For instance : + include /etc/nginx/uwsgi_params; + } + +} diff --git a/roles/re2o-front/templates/uwsgi/apps-available/re2o.ini.j2 b/roles/re2o-front/templates/uwsgi/apps-available/re2o.ini.j2 new file mode 100644 index 00000000..8a05922c --- /dev/null +++ b/roles/re2o-front/templates/uwsgi/apps-available/re2o.ini.j2 @@ -0,0 +1,27 @@ +{{ ansible_header | comment }} + +[uwsgi] +uid = www-data +gid = www-data +# Django-related settings +# the base directory (full path) +chdir = /var/www/re2o +# Django's wsgi file +#module = winaps.wsgi:application +# the virtualenv (full path) +# home = /var/www/re2o/venv +wsgi-file = /var/www/re2o/re2o/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/re2o/re2o.sock +# ... with appropriate permissions - may be needed +chmod-socket = 664 +# clear environment on exit +vacuum = true +#Touch reload +touch-reload = /var/www/re2o/re2o/settings.py -- GitLab