Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Overleaf #97

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ If you have a spare domain name you can configure applications to be accessible
* [openHAB](https://www.openhab.org/) - A vendor and technology agnostic open source automation software for your home
* [openLDAP](https://www.openldap.org/) - An open source implementation of the Lightweight Directory Access Protocol
* [Organizr](https://organizr.app/) - ORGANIZR aims to be your one stop shop for your Servers Frontend.
* [Overleaf](https://github.com/overleaf/overleaf) - A web-based collaborative LaTeX editor
* [overseerr](https://docs.overseerr.dev) - open source software application for managing requests for your media library
* [Paperless_ng](https://github.com/jonaswinkler/paperless-ng) - Scan, index and archive all your physical documents
* [Photofield](https://github.com/SmilyOrg/photofield) - Experimental fast photo viewer
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@
tags:
- organizr

- role: overleaf
tags:
- overleaf

- role: overseerr
tags:
- overseerr
Expand Down
92 changes: 92 additions & 0 deletions roles/overleaf/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
overleaf_enabled: false
overleaf_available_externally: false

# directories
overleaf_data_directory: "{{ docker_home }}/overleaf"

# network
overleaf_port: "8127"
overleaf_hostname: "overleaf"
overleaf_network_name: "overleaf"

# specs
overleaf_memory: 1g
overleaf_mongo_memory: 1g
overleaf_redis_memory: 1g

# docker
overleaf_container_name: overleaf
overleaf_image_name: "sharelatex/sharelatex"
overleaf_image_version: latest

overleaf_mongo_container_name: overleaf-mongo
overleaf_mongo_image_name: "mongo"
overleaf_mongo_image_version: "4.4"

overleaf_redis_container_name: overleaf-redis
overleaf_redis_image_name: "redis"
overleaf_redis_image_version: "6.2"
overleaf_user_id: "1000"
overleaf_group_id: "1000"

# overleaf
overleaf_app_name: "Ansible-NAS Overleaf"
overleaf_mongo_url: "mongodb://{{ overleaf_mongo_container_name }}/sharelatex"
# Same property, unfortunately with different names in
# different locations
overleaf_redis_host: "{{ overleaf_redis_container_name }}"
overleaf_enabled_linked_file_types: "'project_file,project_output_file'"
# Enables Thumbnail generation using ImageMagick
overleaf_enabled_conversions: "true"
# Disables email confirmation requirement
overleaf_email_confirmation_disabled: "true"
# temporary fix for LuaLaTex compiles
# see https://github.com/overleaf/overleaf/issues/695
overleaf_texmfvar: "/var/lib/sharelatex/tmp/texmf-var"
## Set for SSL via nginx-proxy
# overleaf_virtual_host: "103.112.212.22"
overleaf_site_url: "https://{{ overleaf_hostname }}.{{ ansible_nas_domain }}"
overleaf_nav_title: "Ansible-NAS ShareLaTeX Instance"
overleaf_header_image_url: "http://somewhere.com/mylogo.png"
overleaf_admin_email: "overleaf@{{ ansible_nas_domain }}"

overleaf_left_footer: "[{\"text\": \"Powered by <a href=\\\"https://www.sharelatex.com\\\">ShareLaTeX</a> 2016\"},{\"text\": \"Another page I want to link to can be found <a href=\\\"here\\\">here</a>\"} ]"
overleaf_right_footer: "[{\"text\": \"Hello I am on the Right\"} ]"

overleaf_email_from_address: "overleaf@{{ ansible_nas_domain }}"

overleaf_email_aws_ses_access_key_id: ""
overleaf_email_aws_ses_secret_key: ""

overleaf_email_smtp_host: "smtp.mydomain.com"
overleaf_email_smtp_port: "587"
overleaf_email_smtp_secure: "false"
overleaf_email_smtp_user: ""
overleaf_email_smtp_pass: ""
overleaf_email_smtp_tls_reject_unauth: "true"
overleaf_email_smtp_ignore_tls: "false"
overleaf_email_smtp_name: "'127.0.0.1'"
overleaf_email_smtp_logger: "true"
overleaf_custom_email_footer: "This system is run by Ansible-NAS"

overleaf_enable_cron_resource_deletion: "true"


# Database settings
# These are currently only required for configuring PostreSQL.
# By default, overleaf uses SQLite for which you don't need to configure anything.

# Database engine, can be sqlite (default) or postgres
overleaf_db_engine: "sqlite"
# Database name (default: overleaf)
overleaf_db_database: "overleaf"
# Username to connect to the database server (default: overleaf)
overleaf_db_user: "overleaf"
# Password to connect to the database server
overleaf_db_password: "overleaf"
# The hostname where the database is hosted (default: localhost)
overleaf_db_host: ""
# Port use to connect to the database server
# Should use the default port if not set
overleaf_db_port: ""
13 changes: 13 additions & 0 deletions roles/overleaf/docs/overleaf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Overleaf

Homepage: <https://github.com/overleaf/overleaf/>

Overleaf is an open-source online real-time collaborative LaTeX editor.

## Usage

Set `overleaf_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.

Overleaf web interface can be found at <http://ansible_nas_host_or_ip:8127>.

Go to <http://ansible_nas_host_or_ip:8127/launchpad> and register an admin user.
6 changes: 6 additions & 0 deletions roles/overleaf/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
overleaf_enabled: true
10 changes: 10 additions & 0 deletions roles/overleaf/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
overleaf_enabled: false
33 changes: 33 additions & 0 deletions roles/overleaf/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get overleaf mongo container state
community.docker.docker_container:
name: "{{ overleaf_mongo_container_name }}"
register: result_mongo

- name: Get overleaf redis container state
community.docker.docker_container:
name: "{{ overleaf_redis_container_name }}"
register: result_redis

- name: Get overleaf container state
community.docker.docker_container:
name: "{{ overleaf_container_name }}"
register: result

- name: Check if overleaf containers are running
ansible.builtin.assert:
that:
- result_mongo.container['State']['Status'] == "running"
- result_mongo.container['State']['Restarting'] == false
- result_redis.container['State']['Status'] == "running"
- result_redis.container['State']['Restarting'] == false
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
33 changes: 33 additions & 0 deletions roles/overleaf/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove overleaf
community.docker.docker_container:
name: "{{ overleaf_container_name }}"
state: absent
register: result

- name: Try and stop and remove overleaf redis
community.docker.docker_container:
name: "{{ overleaf_redis_container_name }}"
state: absent
register: result_redis

- name: Try and stop and remove overleaf mongo
community.docker.docker_container:
name: "{{ overleaf_mongo_container_name }}"
state: absent
register: result_mongo

- name: Check if overleaf is stopped
ansible.builtin.assert:
that:
- not result.changed
- not result_redis.changed
- not result_mongo.changed
143 changes: 143 additions & 0 deletions roles/overleaf/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
- name: Start Overleaf
block:
- name: Create overleaf Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
with_items:
- "{{ overleaf_data_directory }}"
- "{{ overleaf_data_directory }}/data"
- "{{ overleaf_data_directory }}/mongo_data"
- "{{ overleaf_data_directory }}/redis_data"

- name: Create Overleaf Network
community.docker.docker_network:
name: "{{ overleaf_network_name }}"

- name: Create Overleaf Mongo Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ overleaf_mongo_container_name }}"
image: "{{ overleaf_mongo_image_name }}:{{ overleaf_mongo_image_version }}"
pull: true
networks:
- name: "{{ overleaf_network_name }}"
network_mode: "{{ overleaf_network_name }}"
exposed_ports:
- 27017
volumes:
- "{{ overleaf_data_directory }}/mongo_data:/data/db"
env:
MONGODB_REPLICA_SET_MODE: primary
ALLOW_EMPTY_PASSWORD: 'yes'
command: "--replSet overleaf"
healthcheck:
test: "mongo --quiet --eval 'rs.hello().setName ? rs.hello().setName : rs.initiate({_id: \"overleaf\",members:[{_id: 0, host:\"{{ overleaf_mongo_container_name }}:27017\"}]})'"
labels:
traefik.enable: "false"
restart_policy: always
memory: "{{ overleaf_mongo_memory }}"

- name: Create Overleaf Redis Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ overleaf_redis_container_name }}"
image: "{{ overleaf_redis_image_name }}:{{ overleaf_redis_image_version }}"
pull: true
networks:
- name: "{{ overleaf_network_name }}"
network_mode: "{{ overleaf_network_name }}"
exposed_ports:
- 6379
volumes:
- "{{ overleaf_data_directory }}/redis_data:/data"
labels:
traefik.enable: "false"
restart_policy: always
memory: "{{ overleaf_redis_memory }}"

- name: Create Overleaf Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ overleaf_container_name }}"
image: "{{ overleaf_image_name }}:{{ overleaf_image_version }}"
pull: true
networks:
- name: "{{ overleaf_network_name }}"
network_mode: "{{ overleaf_network_name }}"
volumes:
- "{{ overleaf_data_directory }}/data:/var/lib/sharelatex"
ports:
- "{{ overleaf_port }}:80"
env:
TZ: "{{ ansible_nas_timezone }}"
PUID: "{{ overleaf_user_id | quote }}"
PGID: "{{ overleaf_group_id | quote }}"
SHARELATEX_APP_NAME: "{{ overleaf_app_name }}"
SHARELATEX_MONGO_URL: "{{ overleaf_mongo_url }}"
# Same property, unfortunately with different names in
# different locations
SHARELATEX_REDIS_HOST: "{{ overleaf_redis_host }}"
REDIS_HOST: "{{ overleaf_redis_host }}"
ENABLED_LINKED_FILE_TYPES: "{{ overleaf_enabled_linked_file_types }}"
# Enables Thumbnail generation using ImageMagick
ENABLE_CONVERSIONS: "{{ overleaf_enabled_conversions }}"
# Disables email confirmation requirement
EMAIL_CONFIRMATION_DISABLED: "{{ overleaf_email_confirmation_disabled }}"
# temporary fix for LuaLaTex compiles
# see https://github.com/overleaf/overleaf/issues/695
TEXMFVAR: "{{ overleaf_texmfvar }}"
## Set for SSL via nginx-proxy
# VIRTUAL_HOST: "{{ overleaf_virtual_host }}"
SHARELATEX_SITE_URL: "{{ overleaf_site_url }}"
SHARELATEX_NAV_TITLE: "{{ overleaf_nav_title }}"
SHARELATEX_HEADER_IMAGE_URL: "{{ overleaf_header_image_url }}"
SHARELATEX_ADMIN_EMAIL: "{{ overleaf_admin_email }}"

SHARELATEX_LEFT_FOOTER: "{{ overleaf_left_footer | string }}"
SHARELATEX_RIGHT_FOOTER: "{{ overleaf_right_footer | string }}"

SHARELATEX_EMAIL_FROM_ADDRESS: "{{ overleaf_email_from_address }}"

SHARELATEX_EMAIL_AWS_SES_ACCESS_KEY_ID: "{{ overleaf_email_aws_ses_access_key_id }}"
SHARELATEX_EMAIL_AWS_SES_SECRET_KEY: "{{ overleaf_email_aws_ses_secret_key }}"

SHARELATEX_EMAIL_SMTP_HOST: "{{ overleaf_email_smtp_host }}"
SHARELATEX_EMAIL_SMTP_PORT: "{{ overleaf_email_smtp_port }}"
SHARELATEX_EMAIL_SMTP_SECURE: "{{ overleaf_email_smtp_secure }}"
SHARELATEX_EMAIL_SMTP_USER: "{{ overleaf_email_smtp_user }}"
SHARELATEX_EMAIL_SMTP_PASS: "{{ overleaf_email_smtp_pass }}"
SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH: "{{ overleaf_email_smtp_tls_reject_unauth }}"
SHARELATEX_EMAIL_SMTP_IGNORE_TLS: "{{ overleaf_email_smtp_ignore_tls }}"
SHARELATEX_EMAIL_SMTP_NAME: "{{ overleaf_email_smtp_name }}"
SHARELATEX_EMAIL_SMTP_LOGGER: "{{ overleaf_email_smtp_logger }}"
SHARELATEX_CUSTOM_EMAIL_FOOTER: "{{ overleaf_custom_email_footer }}"

ENABLE_CRON_RESOURCE_DELETION: "{{ overleaf_enable_cron_resource_deletion }}"
restart_policy: unless-stopped
memory: "{{ overleaf_memory }}"
labels:
traefik.enable: "{{ overleaf_available_externally | string }}"
traefik.http.routers.overleaf.rule: "Host(`{{ overleaf_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.overleaf.tls.certresolver: "letsencrypt"
traefik.http.routers.overleaf.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.overleaf.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.overleaf.loadbalancer.server.port: "80"
when: overleaf_enabled is true

- name: Stop Overleaf
block:
- name: Stop Overleaf
community.docker.docker_container:
name: "{{ overleaf_container_name }}"
state: absent
- name: Stop Overleaf Redis
community.docker.docker_container:
name: "{{ overleaf_redis_container_name }}"
state: absent
- name: Stop Overleaf Mongo
community.docker.docker_container:
name: "{{ overleaf_mongo_container_name }}"
state: absent
when: overleaf_enabled is false
16 changes: 16 additions & 0 deletions website/docs/applications/other/overleaf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "Overleaf"
description: "Open-source online real-time collaborative LaTeX editor"
---

Homepage: <https://github.com/overleaf/overleaf/>

Overleaf is an open-source online real-time collaborative LaTeX editor.

## Usage

Set `overleaf_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.

Overleaf web interface can be found at <http://ansible_nas_host_or_ip:8127>.

Go to <http://ansible_nas_host_or_ip:8127/launchpad> and register an admin user.
Loading