diff --git a/overleaf/files/nginx.conf.j2 b/overleaf/files/nginx.conf.j2 new file mode 100644 index 0000000..c0faa36 --- /dev/null +++ b/overleaf/files/nginx.conf.j2 @@ -0,0 +1,20 @@ +server { + + listen 80; + server_name {{ http_host }}; + + # set max upload size + client_max_body_size 10G; + + location / { + + proxy_set_header Host $host:$server_port; + proxy_set_header X-Scheme $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive" always; + add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always; + proxy_pass http://localhost:{{ host_port }}; + } + +} + diff --git a/overleaf/playbook.yml b/overleaf/playbook.yml new file mode 100755 index 0000000..dab5da7 --- /dev/null +++ b/overleaf/playbook.yml @@ -0,0 +1,13 @@ +################################################# +# Setup Overleaf +################################################# +--- +# - hosts: gondor +- hosts: all + become: true + vars_files: + - vars/default.yml + + roles: + - sharelatex +# - nginx diff --git a/overleaf/readme.md b/overleaf/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/overleaf/roles/nginx/handlers/main.yaml b/overleaf/roles/nginx/handlers/main.yaml new file mode 100644 index 0000000..622fd36 --- /dev/null +++ b/overleaf/roles/nginx/handlers/main.yaml @@ -0,0 +1,6 @@ +--- +# Handlers for Nginx role +- name: Reload Nginx + service: + name: nginx + state: reloaded diff --git a/overleaf/roles/nginx/tasks/main.yaml b/overleaf/roles/nginx/tasks/main.yaml new file mode 100644 index 0000000..4441fe7 --- /dev/null +++ b/overleaf/roles/nginx/tasks/main.yaml @@ -0,0 +1,24 @@ +--- +# Tasks for Nginx role +- name: Check if Nginx conf file exists + stat: + path: "/etc/nginx/sites-available/{{ http_conf }}" + register: status + +- name: No need to reload Nginx + debug: + msg: "No need to reload Nginx as sites-available entries have already been created" + +- name: Set Nginx conf file + when: status.stat.exists == false + template: + src: "files/nginx.conf.j2" + dest: "/etc/nginx/sites-available/{{ http_conf }}" + +- name: Enable new site + when: status.stat.exists == false + file: + src: "/etc/nginx/sites-available/{{ http_conf }}" + dest: "/etc/nginx/sites-enabled/{{ http_conf }}" + state: link + notify: Reload Nginx diff --git a/overleaf/roles/sharelatex/tasks/main.yaml b/overleaf/roles/sharelatex/tasks/main.yaml new file mode 100644 index 0000000..7929242 --- /dev/null +++ b/overleaf/roles/sharelatex/tasks/main.yaml @@ -0,0 +1,50 @@ +--- +# Tasks for Sharelatex role +- name: Pull Sharelatex image + docker_image: + name: "{{ sharelatex_image }}" + source: pull + force_source: yes + +- name: Ensure Overleaf Directory exists + file: + path: "/var/lib/{{ host_directory }}" + state: directory + mode: 0755 + +- name: Create webserver container + docker_container: + name: "{{ sharelatex_container }}" + image: "{{ sharelatex_image }}" + state: started + restart_policy: "unless-stopped" + env: +# SHARELATEX_APP_NAME: Overleaf Community Edition +# SHARELATEX_MONGO_URL: mongodb://mongo/sharelatex + OVERLEAF_APP_NAME: Overleaf Community Edition + OVERLEAF_MONGO_URL: mongodb://mongo/sharelatex + + # Same property, unfortunately with different names in + # different locations + OVERLEAF_REDIS_HOST: redis + REDIS_HOST: redis + + ENABLED_LINKED_FILE_TYPES: 'project_file,project_output_file' + + # Enables Thumbnail generation using ImageMagick + ENABLE_CONVERSIONS: 'true' + + # Disables email confirmation requirement + EMAIL_CONFIRMATION_DISABLED: 'true' + + # temporary fix for LuaLaTex compiles + # see https://github.com/overleaf/overleaf/issues/695 + TEXMFVAR: /var/lib/sharelatex/tmp/texmf-var + links: + - "{{ mongo_container }}:mongo" + - "{{ redis_container }}:redis" + published_ports: + - "127.0.0.1:{{ host_port }}:80" + volumes: + - "/var/lib/{{ host_directory }}:/var/lib/overleaf" +# - "/var/lib/{{ host_directory }}:/var/lib/sharelatex" diff --git a/overleaf/vars/default.yml b/overleaf/vars/default.yml new file mode 100644 index 0000000..ffe8eb0 --- /dev/null +++ b/overleaf/vars/default.yml @@ -0,0 +1,12 @@ +--- +http_host: "latex.tanshu.com" +http_conf: "latex.tanshu.com.conf" + +sharelatex_image: sharelatex/sharelatex +sharelatex_container: sharelatex + +mongo_container: mongo +redis_container: redis + +host_directory: overleaf +host_port: 3199