going on with etherpad role, using postgresql, nodejs and caddy as deps

This commit is contained in:
les 2020-09-29 13:43:03 +02:00
parent d0be376e00
commit 1f07accf2f
13 changed files with 164 additions and 276 deletions

View file

@ -1,3 +1,13 @@
# infra # infra
tentativo di mantenere le cose ordinate, ansible Vagrant e altri amenuncoli
## Roles:
### Common
### nodejs
### etherpad
### caddy
tentativo di mantenere le cose ordinate :D ansible Vagrant e altri amenuncoli

View file

@ -1,99 +1,14 @@
--- ---
etherpad: title: "Etherpad"
title: "Etherpad" favicon: "favicon.ico"
favicon: "favicon.ico" hostname: "0.0.0.0"
ip: 0.0.0.0 database_password: "{{lookup('password', './database_password')}}"
port: 9001 pad_options_lang: 'it-it'
users: []
# -
# name: admin
# password: ""
# is_admin: "true"
default_text: '"Welcome to Etherpad!\\n\\nThis 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!\\n\\nGet involved with Etherpad at http:\\/\\/etherpad.org\\n"'
pad_options_no_colors: "false"
pad_options_show_controls: "true"
pad_options_show_chat: "true"
pad_options_show_line_numbers: "true"
pad_options_use_monospace_font: "false"
pad_options_user_name: "false"
pad_options_user_color: "false"
pad_options_rtl: "false"
pad_options_always_show_chat: "false"
pad_options_chat_and_users: "false"
pad_options_lang: "en-gb"
pad_shortcut_alt_f9: "true"
pad_shortcut_alt_c: "true"
pad_shortcut_cmd_shft_2: "true"
pad_shortcut_delete: "true"
pad_shortcut_return: "true"
pad_shortcut_esc: "true"
pad_shortcut_cmd_s: "true"
pad_shortcut_tab: "true"
pad_shortcut_cmd_z: "true"
pad_shortcut_cmd_y: "true"
pad_shortcut_cmd_i: "true"
pad_shortcut_cmd_b: "true"
pad_shortcut_cmd_u: "true"
pad_shortcut_cmd_5: "true"
pad_shortcut_cmd_shift_l: "true"
pad_shortcut_cmd_shift_n: "true"
pad_shortcut_cmd_shift_1: "true"
pad_shortcut_cmd_shift_c: "true"
pad_shortcut_cmd_h: "true"
pad_shortcut_ctrl_home: "true"
pad_shortcut_page_up: "true"
pad_shortcut_page_down: "true"
suppress_errors_in_pad_text: "false"
require_session: "false"
edit_only: "false"
session_no_password: "false"
minify: "true"
max_age: 21600
abiword: "null"
soffice: "null"
tidyhtml: "null"
allow_unknown_file_ends: "true"
require_authentication: "false"
require_authorization: "false"
trust_proxy: "false"
socket_transport_protocols: ["xhr-polling", "jsonp-polling", "htmlfile"]
load_test: "false"
indentation_on_new_line: "false"
automatic_reconnection_timeout: 0
expose_version: "false"
toolbar:
left:
- ["bold", "italic", "underline", "strikethrough"]
- ["orderedlist", "unorderedlist", "indent", "outdent"]
- ["undo", "redo"]
- ["clearauthorship"]
right:
- ["importexport", "timeslider", "savedrevision"]
- ["settings", "embed"]
- ["showusers"]
timeslider:
- ["timeslider_export", "timeslider_returnToPad"]
log_level: "INFO"
abiword_enabled: False
console_enabled: False
monit_enabled: False
# list of etherpad plugins to be installed
plugins: []
plugins_state: present
mysql_database_host: /var/run/postgresql plugins: ['ep_comments_page', 'ep_headings2', 'ep_markdown', 'ep_align', 'ep_page_view']
mysql_database_name: etherpad
mysql_database_user: etherpad
mysql_database_password: etherpad
mysql_database_port: 3306
# Recommendation for large setups is MyISAM pad_default_text: |
mysql_database_engine: InnoDB Welcome to Etherpad!
mysql_database_collation: utf8mb4_bin This pad text is synchronized as you type, so that everyone viewing this page sees the same text.
mysql_database_charset: utf8mb4 This allows you to collaborate seamlessly on documents!
Get involved with Etherpad at"
# Settings for plugin 'ep_table_of_contents'
toc_disable: "true"
# Settings for plugin 'ep_auth_author'
# auth_author_prefix:

View file

@ -1,5 +1,5 @@
--- ---
- name: restart etherpad-lite - name: restart etherpad
service: service:
name: etherpad-lite name: etherpad
state: restarted state: restarted

View file

@ -0,0 +1,13 @@
---
dependencies:
- role: nodejs
- role: postgresql
vars:
username: etherpad
password: "{{ database_password }}"
database: etherpad
- role: caddy
vars:
caddyfile: |
http://{{hostname}}:80
reverse_proxy / /tmp/etherpad.socket"

View file

@ -1,6 +1,7 @@
--- ---
- name: Ensure abiword package is installed - name: Ensure abiword, soffice, tidy packages are installed
apt: apt:
pkg: abiword pkg:
state: present - abiword
- tidy

View file

@ -1,6 +1,4 @@
--- ---
- include: postgresql.yml
- name: ensure etherpad user is present - name: ensure etherpad user is present
user: user:
name: "etherpad" name: "etherpad"
@ -19,25 +17,29 @@
- name: ensure etherpad systemd unit is latest - name: ensure etherpad systemd unit is latest
template: template:
src: etherpad-lite.service.j2 src: etherpad.service.j2
dest: /etc/systemd/system/etherpad-lite.service dest: /etc/systemd/system/etherpad.service
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
- name: ensure etherpad will start after system is booted - name: ensure etherpad will start after system is booted
service: service:
name: etherpad-lite name: etherpad
enabled: yes enabled: yes
- name: install etherpad deps
shell: installDeps.sh
args:
chdir: /srv/etherpad/etherpad/bin
- name: install etherpad plugins - name: install etherpad plugins
npm: npm:
name: "{{ item }}" name: "{{ item }}"
path: "{{ etherpad.path }}" path: "/srv/etherpad/etherpad"
state: "{{ etherpad.plugins_state }}"
become: true become: true
become_user: etherpad become_user: etherpad
with_items: "{{ etherpad.plugins|d() }}" with_items: "{{ plugins|d() }}"
notify: restart etherpad-lite notify: restart etherpad
- include: abiword.yml - include: abiword.yml

View file

@ -4,6 +4,7 @@
pkg: pkg:
- postgresql - postgresql
- python3-psycopg2 - python3-psycopg2
- name: Create etherpad postgresql db - name: Create etherpad postgresql db
become: yes become: yes
become_user: postgres become_user: postgres

View file

@ -1,79 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: etherpad-lite
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts etherpad lite
# Description: starts etherpad lite using start-stop-daemon
### END INIT INFO
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
LOGFILE="/var/log/etherpad-lite/etherpad-lite.log"
EPLITE_DIR="{{ etherpad_path }}"
EPLITE_BIN="bin/safeRun.sh"
USER="{{ etherpad_user }}"
GROUP="{{ etherpad_group }}"
DESC="Etherpad Lite"
NAME="etherpad-lite"
set -e
. /lib/lsb/init-functions
start() {
echo "Starting $DESC... "
start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
echo "done"
}
#We need this function to ensure the whole process tree will be killed
killtree() {
local _pid=$1
local _sig=${2-TERM}
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
killtree ${_child} ${_sig}
done
kill -${_sig} ${_pid}
}
stop() {
echo "Stopping $DESC... "
if test -f /var/run/$NAME.pid; then
while test -d /proc/$(cat /var/run/$NAME.pid); do
killtree $(cat /var/run/$NAME.pid) 15
sleep 0.5
done
rm /var/run/$NAME.pid
fi
echo "done"
}
status() {
status_of_proc -p /var/run/$NAME.pid "" "etherpad-lite" && exit 0 || exit $?
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $NAME {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0

View file

@ -1,74 +1,73 @@
#jinja2: lstrip_blocks: True #jinja2: lstrip_blocks: True
{ {
"title": "{{ etherpad.title }}", "title": "{{ title }}",
"favicon": "{{ etherpad.favicon }}", "favicon": "{{ favicon }}",
"ip": "{{ etherpad.ip }}", "ip": "",
"port" : {{ etherpad.port }}, "port" : "/tmp/etherpad.socket",
"showSettingsInAdminPage": false, "showSettingsInAdminPage": false,
"sessionKey": "{{ etherpad.session_key }}", "sessionKey": "{{ etherpad.session_key }}",
"skinName": "colibris", "skinName": "colibris",
"dbType": "mysql", "dbType": "postgresql",
"dbSettings" : { "dbSettings" : {
"user" : "{{ etherpad.mysql_database_user }}", "user" : "etherpad",
"host" : "{{ etherpad.mysql_database_host }}", "host" : "/var/run/postgresql",
"port" : {{ etherpad.mysql_database_port }}, "password": "{{ database_password }}",
"password": "{{ etherpad.mysql_database_password }}", "database": "etherpad",
"database": "{{ etherpad.mysql_database_name }}", "charset" : "utf8mb4"
"charset" : "{{ etherpad.mysql_database_charset }}"
}, },
"defaultPadText": {{ etherpad.default_text }}, "defaultPadText": "{{ pad_default_text }}",
"padOptions": { "padOptions": {
"noColors": {{ etherpad.pad_options_no_colors }}, "noColors": false,
"showControls": {{ etherpad.pad_options_show_controls }}, "showControls": true,
"showChat": {{ etherpad.pad_options_show_chat }}, "showChat": true,
"showLineNumbers": {{ etherpad.pad_options_show_line_numbers }}, "showLineNumbers": true,
"useMonospaceFont": {{ etherpad.pad_options_use_monospace_font }}, "useMonospaceFont": true,
"userName": {{ etherpad.pad_options_user_name }}, "userName": true,
"userColor": {{ etherpad.pad_options_user_color }}, "userColor": false,
"rtl": {{ etherpad.pad_options_rtl }}, "rtl": false,
"alwaysShowChat": {{ etherpad.pad_options_always_show_chat }}, "alwaysShowChat": false,
"chatAndUsers": {{ etherpad.pad_options_chat_and_users }}, "chatAndUsers": false,
"lang": "{{ etherpad.pad_options_lang }}" "lang": "{{ pad_options_lang }}"
}, },
"padShortcutEnabled" : { "padShortcutEnabled" : {
"altF9": {{ etherpad.pad_shortcut_alt_f9 }}, "altF9": true,
"altC": {{ etherpad.pad_shortcut_alt_c }}, "altC": true,
"cmdShift2": {{ etherpad.pad_shortcut_cmd_shft_2 }}, "cmdShift2": true,
"delete": {{ etherpad.pad_shortcut_delete }}, "delete": true,
"return": {{ etherpad.pad_shortcut_return }}, "return": true,
"esc": {{ etherpad.pad_shortcut_esc }}, "esc": true,
"cmdS": {{ etherpad.pad_shortcut_cmd_s }}, "cmdS": true,
"tab": {{ etherpad.pad_shortcut_tab }}, "tab": true,
"cmdZ": {{ etherpad.pad_shortcut_cmd_z }}, "cmdZ": true,
"cmdY": {{ etherpad.pad_shortcut_cmd_y }}, "cmdY": true,
"cmdI": {{ etherpad.pad_shortcut_cmd_i }}, "cmdI": true,
"cmdB": {{ etherpad.pad_shortcut_cmd_b }}, "cmdB": true,
"cmdU": {{ etherpad.pad_shortcut_cmd_u }}, "cmdU": true,
"cmd5": {{ etherpad.pad_shortcut_cmd_5 }}, "cmd5": true,
"cmdShiftL": {{ etherpad.pad_shortcut_cmd_shift_l }}, "cmdShiftL": true,
"cmdShiftN": {{ etherpad.pad_shortcut_cmd_shift_n }}, "cmdShiftN": true,
"cmdShift1": {{ etherpad.pad_shortcut_cmd_shift_1 }}, "cmdShift1": true,
"cmdShiftC": {{ etherpad.pad_shortcut_cmd_shift_c }}, "cmdShiftC": true,
"cmdH": {{ etherpad.pad_shortcut_cmd_h }}, "cmdH": true,
"ctrlHome": {{ etherpad.pad_shortcut_ctrl_home }}, "ctrlHome": true,
"pageUp": {{ etherpad.pad_shortcut_page_up }}, "pageUp": true,
"pageDown": {{ etherpad.pad_shortcut_page_down }} "pageDown": true}
}, },
"suppressErrorsInPadText": {{ etherpad.suppress_errors_in_pad_text }}, "suppressErrorsInPadText": false,
"requireSession": {{ etherpad.require_session }}, "requireSession": false,
"editOnly": {{ etherpad.edit_only }}, "editOnly": false,
"sessionNoPassword": {{ etherpad.session_no_password }}, "sessionNoPassword": false,
"minify": {{ etherpad.minify }}, "minify": true,
"maxAge": {{ etherpad.max_age }}, "maxAge": 21600,
"abiword": {{ etherpad.abiword }}, "abiword": "/usr/bin/abiword",
"soffice": {{ etherpad.soffice }}, "soffice": "/usr/bin/soffice",
"tidyHtml": {{ etherpad.tidyhtml }}, "tidyHtml": "/usr/bin/tidy",
"allowUnknownFileEnds": {{ etherpad.allow_unknown_file_ends }}, "allowUnknownFileEnds": true,
"requireAuthentication": {{ etherpad.require_authentication }}, "requireAuthentication": false,
"requireAuthorization": {{ etherpad.require_authorization }}, "requireAuthorization": false,
"trustProxy": {{ etherpad.trust_proxy }}, "trustProxy": false,
"disableIPlogging": {{ etherpad.disable_ip_logging }}, "disableIPlogging": true,
"automaticReconnectionTimeout": {{ etherpad.automatic_reconnection_timeout }}, "automaticReconnectionTimeout": 5,
"scrollWhenFocusLineIsOutOfViewport": { "scrollWhenFocusLineIsOutOfViewport": {
"percentage": { "percentage": {
"editionAboveViewport": 0, "editionAboveViewport": 0,
@ -78,32 +77,25 @@
"scrollWhenCaretIsInTheLastLineOfViewport": false, "scrollWhenCaretIsInTheLastLineOfViewport": false,
"percentageToScrollWhenUserPressesArrowUp": 0 "percentageToScrollWhenUserPressesArrowUp": 0
}, },
{% if 'ep_table_of_contents' in etherpad.plugins %} "socketTransportProtocols": : ["xhr-polling", "jsonp-polling", "htmlfile"],
"ep_toc": {
"disable_by_default": {{ etherpad.toc_disable }}
},
{% endif %}
{% if 'ep_auth_author' in etherpad.plugins and etherpad.auth_author_prefix is defined %}
"ep_auth_author": {
"prefix": "{{ etherpad.auth_author_prefix }}"
},
{% endif %}
"users": {
{% for user in etherpad.users %}
"{% if user.auth_author is defined and user.auth_author %}{{ etherpad.auth_author_prefix }}{% endif %}{{ user.name }}": {
"password": "{{ user.password }}",
{% if user.auth_author is defined and user.auth_author %}
"author_name": "{{ user.name }}",
{% endif %}
"is_admin": {{ user.is_admin }}
}{% if not loop.last %},{% endif %}
{% endfor %}
},
"socketTransportProtocols": {{ etherpad.socket_transport_protocols|to_json }},
"loadTest": false, "loadTest": false,
"indentationOnNewLine": {{ etherpad.indentation_on_new_line }}, "indentationOnNewLine": false,
"toolbar": {{ etherpad.toolbar|to_json }}, "toolbar": {
"left": [
["bold", "italic", "underline", "strikethrough"],
["orderedlist", "unorderedlist", "indent", "outdent"],
["undo", "redo"],
["clearauthorship"]
],
"right": [
["importexport", "timeslider", "savedrevision"],
["settings", "embed"],
["showusers"]
],
"timeslider": [
["timeslider_export", "timeslider_returnToPad"]
]
}
"exposeVersion": false, "exposeVersion": false,
"loglevel": "{{ etherpad.log_level }}", "loglevel": "WARN",
} }

View file

@ -0,0 +1,4 @@
# cisti.org postgresql
- installa postgresql
- se specificato crea un db e un utente con tutti i permessi su quel db

View file

@ -0,0 +1,4 @@
---
username: false
password: false
database: false

View file

@ -0,0 +1,25 @@
---
- name: Install postgresql
apt:
pkg:
- acl
- postgresql
- python3-psycopg2
- name: Create postgresql db
become: true
become_user: postgres
postgresql_db:
name: "{{database}}"
when: database != false
- name: Create postgresql user
when: username != false
become: true
become_user: postgres
postgresql_user:
db: "{{database}}"
name: "{{username}}"
password: "{{password}}"