From 17e289641ab6bd2985891e2021bcde0189fa348f Mon Sep 17 00:00:00 2001 From: les Date: Wed, 30 Sep 2020 10:26:02 +0200 Subject: [PATCH] fully working etherpad role with minimal deps --- etherpad-playbook.yml | 7 +++++++ nodejs.yml | 5 ----- roles/caddy/defaults/main.yml | 2 +- roles/etherpad/defaults/main.yml | 4 ++-- roles/etherpad/meta/main.yml | 14 +++++++++++--- roles/etherpad/tasks/main.yml | 15 +++++++++++++-- roles/etherpad/templates/settings.json.j2 | 20 ++++++++++---------- 7 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 etherpad-playbook.yml delete mode 100644 nodejs.yml diff --git a/etherpad-playbook.yml b/etherpad-playbook.yml new file mode 100644 index 0000000..60f857b --- /dev/null +++ b/etherpad-playbook.yml @@ -0,0 +1,7 @@ +--- + +- name: "Testing etherpad role" + hosts: localhost + become: true + roles: + - role: etherpad diff --git a/nodejs.yml b/nodejs.yml deleted file mode 100644 index 3aed213..0000000 --- a/nodejs.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: nodejs test - hosts: all - roles: - - nodejs diff --git a/roles/caddy/defaults/main.yml b/roles/caddy/defaults/main.yml index d4fc3dd..8d6d34c 100644 --- a/roles/caddy/defaults/main.yml +++ b/roles/caddy/defaults/main.yml @@ -14,7 +14,7 @@ caddy_http2_enabled: "true" # additional cli args to pass to caddy caddy_additional_args: "" caddy_systemd_network_dependency: true -caddy_systemd_capabilities_enabled: false +caddy_systemd_capabilities_enabled: true caddy_systemd_capabilities: "CAP_NET_BIND_SERVICE" caddy_systemd_restart: "on-failure" # always, on-success, on-failure, on-abnormal, on-abort, on-watchdog caddy_systemd_restart_startlimitinterval: "86400" diff --git a/roles/etherpad/defaults/main.yml b/roles/etherpad/defaults/main.yml index 22e1318..1391781 100644 --- a/roles/etherpad/defaults/main.yml +++ b/roles/etherpad/defaults/main.yml @@ -1,7 +1,7 @@ --- title: "Etherpad" favicon: "favicon.ico" -hostname: "0.0.0.0" +hostname: ":80" database_password: "{{lookup('password', './database_password')}}" pad_options_lang: 'it-it' @@ -11,4 +11,4 @@ pad_default_text: | Welcome to Etherpad! This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents! - Get involved with Etherpad at" + Get involved with Etherpad at \ No newline at end of file diff --git a/roles/etherpad/meta/main.yml b/roles/etherpad/meta/main.yml index 225440b..ec898b5 100644 --- a/roles/etherpad/meta/main.yml +++ b/roles/etherpad/meta/main.yml @@ -1,13 +1,21 @@ --- dependencies: + + # install nodejs - role: nodejs + + # install postgres + # and create an etherpad user and db - role: postgresql vars: username: etherpad password: "{{ database_password }}" database: etherpad + + # install caddy and configure it as reverse proxy - role: caddy vars: - caddyfile: | - http://{{hostname}}:80 - reverse_proxy / /tmp/etherpad.socket" + caddy_config: | + {{hostname}} + encode gzip + reverse_proxy localhost:31337 \ No newline at end of file diff --git a/roles/etherpad/tasks/main.yml b/roles/etherpad/tasks/main.yml index 4dba172..911584e 100644 --- a/roles/etherpad/tasks/main.yml +++ b/roles/etherpad/tasks/main.yml @@ -23,15 +23,26 @@ group: root mode: 0644 +- name: copy etherpad settings.json + template: + src: settings.json.j2 + dest: /srv/etherpad/etherpad/settings.json + owner: etherpad + group: etherpad + mode: 0644 + + - name: ensure etherpad will start after system is booted service: name: etherpad enabled: yes - name: install etherpad deps - shell: installDeps.sh + become: true + become_user: etherpad + shell: /srv/etherpad/etherpad/bin/installDeps.sh args: - chdir: /srv/etherpad/etherpad/bin + chdir: /srv/etherpad/etherpad/ - name: install etherpad plugins npm: diff --git a/roles/etherpad/templates/settings.json.j2 b/roles/etherpad/templates/settings.json.j2 index 395a834..990ac22 100644 --- a/roles/etherpad/templates/settings.json.j2 +++ b/roles/etherpad/templates/settings.json.j2 @@ -2,12 +2,12 @@ { "title": "{{ title }}", "favicon": "{{ favicon }}", - "ip": "", - "port" : "/tmp/etherpad.socket", + "ip": "127.0.0.1", + "port" : "31337", "showSettingsInAdminPage": false, - "sessionKey": "{{ etherpad.session_key }}", + "sessionKey": "oijaoifd", "skinName": "colibris", - "dbType": "postgresql", + "dbType": "postgres", "dbSettings" : { "user" : "etherpad", "host" : "/var/run/postgresql", @@ -15,7 +15,7 @@ "database": "etherpad", "charset" : "utf8mb4" }, - "defaultPadText": "{{ pad_default_text }}", + "defaultPadText": "{{ pad_default_text | replace("\n", "\\n")}}", "padOptions": { "noColors": false, "showControls": true, @@ -51,7 +51,7 @@ "cmdH": true, "ctrlHome": true, "pageUp": true, - "pageDown": true} + "pageDown": true }, "suppressErrorsInPadText": false, "requireSession": false, @@ -60,7 +60,7 @@ "minify": true, "maxAge": 21600, "abiword": "/usr/bin/abiword", - "soffice": "/usr/bin/soffice", + "soffice": false, "tidyHtml": "/usr/bin/tidy", "allowUnknownFileEnds": true, "requireAuthentication": false, @@ -77,7 +77,7 @@ "scrollWhenCaretIsInTheLastLineOfViewport": false, "percentageToScrollWhenUserPressesArrowUp": 0 }, - "socketTransportProtocols": : ["xhr-polling", "jsonp-polling", "htmlfile"], + "socketTransportProtocols": ["xhr-polling", "jsonp-polling", "htmlfile"], "loadTest": false, "indentationOnNewLine": false, "toolbar": { @@ -95,7 +95,7 @@ "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] ] - } + }, "exposeVersion": false, - "loglevel": "WARN", + "loglevel": "WARN" }