diff --git a/plays/re2o.yml b/plays/re2o.yml index 1aff13b2960940eacd9e1bf5802a26a4e2768392..adb5a5d3eeed94316295486ffcdf9acbc64b77cc 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 0000000000000000000000000000000000000000..bc651bf93bfeae0e3a67733d34d0f439924c98d2 --- /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 0000000000000000000000000000000000000000..67a6b5a7670f9de93ae91b8d2fdcece110481b7e --- /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 0000000000000000000000000000000000000000..77bc8a0fdc22ec118bf2f168308acfb6425f4d0b --- /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 0000000000000000000000000000000000000000..8a05922c559063edb5fef8b2a3245f4d8a81e044 --- /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