From 37efebe85b360f35a4f74d063ba2a0fe0eb7f177 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 02:49:39 +0100 Subject: [PATCH] Ansible builds and deploys the documentation --- ansible/base.yml | 1 + .../host_vars/bde-nk20-beta.adh.crans.org.yml | 1 + ansible/host_vars/bde-note.adh.crans.org.yml | 2 ++ ansible/host_vars/bde3-virt.adh.crans.org.yml | 2 ++ .../roles/5-nginx/templates/nginx_note.conf | 30 ++++++++++++++++++- ansible/roles/8-docs/tasks/main.yml | 20 +++++++++++++ 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 ansible/roles/8-docs/tasks/main.yml diff --git a/ansible/base.yml b/ansible/base.yml index 950aafa5..359f396c 100755 --- a/ansible/base.yml +++ b/ansible/base.yml @@ -16,3 +16,4 @@ - 5-nginx - 6-psql - 7-postinstall + - 8-docs diff --git a/ansible/host_vars/bde-nk20-beta.adh.crans.org.yml b/ansible/host_vars/bde-nk20-beta.adh.crans.org.yml index d4ef70ef..725ca9ce 100644 --- a/ansible/host_vars/bde-nk20-beta.adh.crans.org.yml +++ b/ansible/host_vars/bde-nk20-beta.adh.crans.org.yml @@ -3,3 +3,4 @@ note: server_name: note-beta.crans.org git_branch: beta cron_enabled: false + doc_enabled: false diff --git a/ansible/host_vars/bde-note.adh.crans.org.yml b/ansible/host_vars/bde-note.adh.crans.org.yml index ba085433..287ff72a 100644 --- a/ansible/host_vars/bde-note.adh.crans.org.yml +++ b/ansible/host_vars/bde-note.adh.crans.org.yml @@ -3,3 +3,5 @@ note: server_name: note.crans.org git_branch: master cron_enabled: true + doc_enabled: true + doc_url: doc.note.crans.org diff --git a/ansible/host_vars/bde3-virt.adh.crans.org.yml b/ansible/host_vars/bde3-virt.adh.crans.org.yml index 477a4b7a..5eed89a9 100644 --- a/ansible/host_vars/bde3-virt.adh.crans.org.yml +++ b/ansible/host_vars/bde3-virt.adh.crans.org.yml @@ -3,3 +3,5 @@ note: server_name: note-dev.crans.org git_branch: beta cron_enabled: false + doc_enabled: true + doc_url: bde3.crans.org diff --git a/ansible/roles/5-nginx/templates/nginx_note.conf b/ansible/roles/5-nginx/templates/nginx_note.conf index 218d6537..d2e65ba6 100644 --- a/ansible/roles/5-nginx/templates/nginx_note.conf +++ b/ansible/roles/5-nginx/templates/nginx_note.conf @@ -1,8 +1,36 @@ # the upstream component nginx needs to connect to -upstream note{ +upstream note { server unix:///var/www/note_kfet/note_kfet.sock; # file socket } +{% if note.doc_enabled %} +# Redirect doc HTTP to doc HTTPS +server { + listen 80; + listen [::]:80; + server_name {{ note.doc_url }}; + + location / { + return 301 https://{{ note.doc_url }}$request_uri; + } +} + +# configuration of the documentation website +server { + listen 443 ssl; + listen [::]:443 ssl; + + server_name {{ note.doc_url }}; + root /var/www/documentation; + charset utf-8; + + ssl_certificate /etc/letsencrypt/live/{{ note.server_name }}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/{{ note.server_name }}/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; +} +{% endif %} + # Redirect HTTP to nk20 HTTPS server { listen 80 default_server; diff --git a/ansible/roles/8-docs/tasks/main.yml b/ansible/roles/8-docs/tasks/main.yml new file mode 100644 index 00000000..be8c9607 --- /dev/null +++ b/ansible/roles/8-docs/tasks/main.yml @@ -0,0 +1,20 @@ +--- +- name: Install Sphinx and RTD theme + pip: + requirements: /var/www/note_kfet/docs/requirements.txt + virtualenv: /var/www/note_kfet/env + virtualenv_command: /usr/bin/python3 -m venv + virtualenv_site_packages: true + become_user: www-data + +- name: Create documentation directory with good permissions + file: + path: /var/www/documentation + state: directory + owner: www-data + group: www-data + mode: u=rwx,g=rwxs,o=rx + +- name: Build HTML documentation + command: /var/www/note_kfet/env/bin/sphinx-build -b dirhtml /var/www/note_kfet/docs/ /var/www/documentation/ + become_user: www-data