diff --git a/README.md b/README.md index 87dc92a..ed04a19 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # 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 \ No newline at end of file diff --git a/roles/etherpad/defaults/main.yml b/roles/etherpad/defaults/main.yml index 41a9373..22e1318 100644 --- a/roles/etherpad/defaults/main.yml +++ b/roles/etherpad/defaults/main.yml @@ -1,99 +1,14 @@ --- -etherpad: - title: "Etherpad" - favicon: "favicon.ico" - ip: 0.0.0.0 - port: 9001 - 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 +title: "Etherpad" +favicon: "favicon.ico" +hostname: "0.0.0.0" +database_password: "{{lookup('password', './database_password')}}" +pad_options_lang: 'it-it' - mysql_database_host: /var/run/postgresql - mysql_database_name: etherpad - mysql_database_user: etherpad - mysql_database_password: etherpad - mysql_database_port: 3306 +plugins: ['ep_comments_page', 'ep_headings2', 'ep_markdown', 'ep_align', 'ep_page_view'] - # Recommendation for large setups is MyISAM - mysql_database_engine: InnoDB - mysql_database_collation: utf8mb4_bin - mysql_database_charset: utf8mb4 - - # Settings for plugin 'ep_table_of_contents' - toc_disable: "true" - - # Settings for plugin 'ep_auth_author' - # auth_author_prefix: +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" diff --git a/roles/etherpad/handlers/main.yml b/roles/etherpad/handlers/main.yml index 17f31a4..4e66530 100644 --- a/roles/etherpad/handlers/main.yml +++ b/roles/etherpad/handlers/main.yml @@ -1,5 +1,5 @@ --- -- name: restart etherpad-lite +- name: restart etherpad service: - name: etherpad-lite + name: etherpad state: restarted diff --git a/roles/etherpad/meta/main.yml b/roles/etherpad/meta/main.yml new file mode 100644 index 0000000..225440b --- /dev/null +++ b/roles/etherpad/meta/main.yml @@ -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" diff --git a/roles/etherpad/tasks/abiword.yml b/roles/etherpad/tasks/abiword.yml index 310ef13..b04f153 100644 --- a/roles/etherpad/tasks/abiword.yml +++ b/roles/etherpad/tasks/abiword.yml @@ -1,6 +1,7 @@ --- -- name: Ensure abiword package is installed +- name: Ensure abiword, soffice, tidy packages are installed apt: - pkg: abiword - state: present + pkg: + - abiword + - tidy diff --git a/roles/etherpad/tasks/main.yml b/roles/etherpad/tasks/main.yml index 58f147d..4dba172 100644 --- a/roles/etherpad/tasks/main.yml +++ b/roles/etherpad/tasks/main.yml @@ -1,6 +1,4 @@ --- -- include: postgresql.yml - - name: ensure etherpad user is present user: name: "etherpad" @@ -19,25 +17,29 @@ - name: ensure etherpad systemd unit is latest template: - src: etherpad-lite.service.j2 - dest: /etc/systemd/system/etherpad-lite.service + src: etherpad.service.j2 + dest: /etc/systemd/system/etherpad.service owner: root group: root mode: 0644 - name: ensure etherpad will start after system is booted service: - name: etherpad-lite + name: etherpad enabled: yes +- name: install etherpad deps + shell: installDeps.sh + args: + chdir: /srv/etherpad/etherpad/bin + - name: install etherpad plugins npm: name: "{{ item }}" - path: "{{ etherpad.path }}" - state: "{{ etherpad.plugins_state }}" + path: "/srv/etherpad/etherpad" become: true become_user: etherpad - with_items: "{{ etherpad.plugins|d() }}" - notify: restart etherpad-lite + with_items: "{{ plugins|d() }}" + notify: restart etherpad - include: abiword.yml diff --git a/roles/etherpad/tasks/postgresql.yml b/roles/etherpad/tasks/postgresql.yml index f269e17..8e1f34c 100644 --- a/roles/etherpad/tasks/postgresql.yml +++ b/roles/etherpad/tasks/postgresql.yml @@ -4,6 +4,7 @@ pkg: - postgresql - python3-psycopg2 + - name: Create etherpad postgresql db become: yes become_user: postgres diff --git a/roles/etherpad/templates/etherpad-lite.sysvinit.j2 b/roles/etherpad/templates/etherpad-lite.sysvinit.j2 deleted file mode 100644 index 4a440cf..0000000 --- a/roles/etherpad/templates/etherpad-lite.sysvinit.j2 +++ /dev/null @@ -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 diff --git a/roles/etherpad/templates/etherpad-lite.service.j2 b/roles/etherpad/templates/etherpad.service.j2 similarity index 100% rename from roles/etherpad/templates/etherpad-lite.service.j2 rename to roles/etherpad/templates/etherpad.service.j2 diff --git a/roles/etherpad/templates/settings.json.j2 b/roles/etherpad/templates/settings.json.j2 index 0f8e524..395a834 100644 --- a/roles/etherpad/templates/settings.json.j2 +++ b/roles/etherpad/templates/settings.json.j2 @@ -1,74 +1,73 @@ #jinja2: lstrip_blocks: True { - "title": "{{ etherpad.title }}", - "favicon": "{{ etherpad.favicon }}", - "ip": "{{ etherpad.ip }}", - "port" : {{ etherpad.port }}, + "title": "{{ title }}", + "favicon": "{{ favicon }}", + "ip": "", + "port" : "/tmp/etherpad.socket", "showSettingsInAdminPage": false, "sessionKey": "{{ etherpad.session_key }}", "skinName": "colibris", - "dbType": "mysql", + "dbType": "postgresql", "dbSettings" : { - "user" : "{{ etherpad.mysql_database_user }}", - "host" : "{{ etherpad.mysql_database_host }}", - "port" : {{ etherpad.mysql_database_port }}, - "password": "{{ etherpad.mysql_database_password }}", - "database": "{{ etherpad.mysql_database_name }}", - "charset" : "{{ etherpad.mysql_database_charset }}" + "user" : "etherpad", + "host" : "/var/run/postgresql", + "password": "{{ database_password }}", + "database": "etherpad", + "charset" : "utf8mb4" }, - "defaultPadText": {{ etherpad.default_text }}, + "defaultPadText": "{{ pad_default_text }}", "padOptions": { - "noColors": {{ etherpad.pad_options_no_colors }}, - "showControls": {{ etherpad.pad_options_show_controls }}, - "showChat": {{ etherpad.pad_options_show_chat }}, - "showLineNumbers": {{ etherpad.pad_options_show_line_numbers }}, - "useMonospaceFont": {{ etherpad.pad_options_use_monospace_font }}, - "userName": {{ etherpad.pad_options_user_name }}, - "userColor": {{ etherpad.pad_options_user_color }}, - "rtl": {{ etherpad.pad_options_rtl }}, - "alwaysShowChat": {{ etherpad.pad_options_always_show_chat }}, - "chatAndUsers": {{ etherpad.pad_options_chat_and_users }}, - "lang": "{{ etherpad.pad_options_lang }}" + "noColors": false, + "showControls": true, + "showChat": true, + "showLineNumbers": true, + "useMonospaceFont": true, + "userName": true, + "userColor": false, + "rtl": false, + "alwaysShowChat": false, + "chatAndUsers": false, + "lang": "{{ pad_options_lang }}" }, "padShortcutEnabled" : { - "altF9": {{ etherpad.pad_shortcut_alt_f9 }}, - "altC": {{ etherpad.pad_shortcut_alt_c }}, - "cmdShift2": {{ etherpad.pad_shortcut_cmd_shft_2 }}, - "delete": {{ etherpad.pad_shortcut_delete }}, - "return": {{ etherpad.pad_shortcut_return }}, - "esc": {{ etherpad.pad_shortcut_esc }}, - "cmdS": {{ etherpad.pad_shortcut_cmd_s }}, - "tab": {{ etherpad.pad_shortcut_tab }}, - "cmdZ": {{ etherpad.pad_shortcut_cmd_z }}, - "cmdY": {{ etherpad.pad_shortcut_cmd_y }}, - "cmdI": {{ etherpad.pad_shortcut_cmd_i }}, - "cmdB": {{ etherpad.pad_shortcut_cmd_b }}, - "cmdU": {{ etherpad.pad_shortcut_cmd_u }}, - "cmd5": {{ etherpad.pad_shortcut_cmd_5 }}, - "cmdShiftL": {{ etherpad.pad_shortcut_cmd_shift_l }}, - "cmdShiftN": {{ etherpad.pad_shortcut_cmd_shift_n }}, - "cmdShift1": {{ etherpad.pad_shortcut_cmd_shift_1 }}, - "cmdShiftC": {{ etherpad.pad_shortcut_cmd_shift_c }}, - "cmdH": {{ etherpad.pad_shortcut_cmd_h }}, - "ctrlHome": {{ etherpad.pad_shortcut_ctrl_home }}, - "pageUp": {{ etherpad.pad_shortcut_page_up }}, - "pageDown": {{ etherpad.pad_shortcut_page_down }} + "altF9": true, + "altC": true, + "cmdShift2": true, + "delete": true, + "return": true, + "esc": true, + "cmdS": true, + "tab": true, + "cmdZ": true, + "cmdY": true, + "cmdI": true, + "cmdB": true, + "cmdU": true, + "cmd5": true, + "cmdShiftL": true, + "cmdShiftN": true, + "cmdShift1": true, + "cmdShiftC": true, + "cmdH": true, + "ctrlHome": true, + "pageUp": true, + "pageDown": true} }, - "suppressErrorsInPadText": {{ etherpad.suppress_errors_in_pad_text }}, - "requireSession": {{ etherpad.require_session }}, - "editOnly": {{ etherpad.edit_only }}, - "sessionNoPassword": {{ etherpad.session_no_password }}, - "minify": {{ etherpad.minify }}, - "maxAge": {{ etherpad.max_age }}, - "abiword": {{ etherpad.abiword }}, - "soffice": {{ etherpad.soffice }}, - "tidyHtml": {{ etherpad.tidyhtml }}, - "allowUnknownFileEnds": {{ etherpad.allow_unknown_file_ends }}, - "requireAuthentication": {{ etherpad.require_authentication }}, - "requireAuthorization": {{ etherpad.require_authorization }}, - "trustProxy": {{ etherpad.trust_proxy }}, - "disableIPlogging": {{ etherpad.disable_ip_logging }}, - "automaticReconnectionTimeout": {{ etherpad.automatic_reconnection_timeout }}, + "suppressErrorsInPadText": false, + "requireSession": false, + "editOnly": false, + "sessionNoPassword": false, + "minify": true, + "maxAge": 21600, + "abiword": "/usr/bin/abiword", + "soffice": "/usr/bin/soffice", + "tidyHtml": "/usr/bin/tidy", + "allowUnknownFileEnds": true, + "requireAuthentication": false, + "requireAuthorization": false, + "trustProxy": false, + "disableIPlogging": true, + "automaticReconnectionTimeout": 5, "scrollWhenFocusLineIsOutOfViewport": { "percentage": { "editionAboveViewport": 0, @@ -78,32 +77,25 @@ "scrollWhenCaretIsInTheLastLineOfViewport": false, "percentageToScrollWhenUserPressesArrowUp": 0 }, -{% if 'ep_table_of_contents' in etherpad.plugins %} - "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 }}, + "socketTransportProtocols": : ["xhr-polling", "jsonp-polling", "htmlfile"], "loadTest": false, - "indentationOnNewLine": {{ etherpad.indentation_on_new_line }}, - "toolbar": {{ etherpad.toolbar|to_json }}, + "indentationOnNewLine": 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"] + ] + } "exposeVersion": false, - "loglevel": "{{ etherpad.log_level }}", + "loglevel": "WARN", } diff --git a/roles/postgresql/README.md b/roles/postgresql/README.md new file mode 100644 index 0000000..7612bda --- /dev/null +++ b/roles/postgresql/README.md @@ -0,0 +1,4 @@ +# cisti.org postgresql + +- installa postgresql +- se specificato crea un db e un utente con tutti i permessi su quel db \ No newline at end of file diff --git a/roles/postgresql/defaults/main.yml b/roles/postgresql/defaults/main.yml new file mode 100644 index 0000000..10e8503 --- /dev/null +++ b/roles/postgresql/defaults/main.yml @@ -0,0 +1,4 @@ +--- +username: false +password: false +database: false diff --git a/roles/postgresql/tasks/main.yml b/roles/postgresql/tasks/main.yml new file mode 100644 index 0000000..26e7217 --- /dev/null +++ b/roles/postgresql/tasks/main.yml @@ -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}}" + +