Update how modules are deployed (#13)

From last deployment, I discovered that you can not loop with `npm install --no-save --legacy-peer-deps ep_whatever` like we used to do, because it removes every other installed modules for some reason. So you have to do all at once like `npm install --no-save --legacy-peer-deps ep_whatever ep_whatever1 ep_whatever2 ep_whatever3`.

This fixes this.

Co-authored-by: meaz <meaz@disroot.org>
Reviewed-on: #13
Reviewed-by: muppeth <muppeth@no-reply@disroot.org>
This commit is contained in:
meaz 2023-09-02 05:55:02 +00:00
parent 37f497d096
commit a82884ee15
5 changed files with 44 additions and 70 deletions

View File

@ -56,43 +56,26 @@ etherpad_apt:
- nodejs - nodejs
- git - git
etherpad_plugins: etherpad_plugins_list:
- name: ep_adminpads2 ep_adminpads2: enabled
install: true ep_comments_page: enabled
- name: ep_comments_page ep_desktop_notifications: enabled
install: true ep_font_color: enabled
- name: ep_desktop_notifications ep_headings2: enabled
install: true ep_markdown: enabled
- name: ep_font_color ep_previewimages: enabled
install: true ep_spellcheck: enabled
- name: ep_headings2 ep_real_time_chat: enabled
install: true ep_delete_after_delay: enabled
- name: ep_markdown ep_align: enabled
install: true ep_font_size: enabled
- name: ep_previewimages ep_table_of_contents: enabled
install: true ep_author_follow: enabled
- name: ep_spellcheck ep_cursortrace: enabled
install: true ep_prompt_for_name: enabled
- name: ep_real_time_chat ep_user_fontsize_version_2: enabled
install: true ep_author_hover: enabled
- name: ep_delete_after_delay
install: true
- name: ep_align
install: true
- name: ep_font_size
install: true
- name: ep_table_of_contents
install: true
- name: ep_author_follow
install: true
- name: ep_cursortrace
install: true
- name: ep_prompt_for_name
install: true
- name: ep_user_fontsize_version_2
install: true
- name: ep_author_hover
install: true
# ep_delete_after_delay # ep_delete_after_delay
# Etherpad-Lite plugin that deletes your pads after a configured delay # Etherpad-Lite plugin that deletes your pads after a configured delay
delay: '7776000' # one day, in seconds Default is 86400 delay: '7776000' # one day, in seconds Default is 86400

View File

@ -7,6 +7,7 @@
owner: "{{ etherpad_username }}" owner: "{{ etherpad_username }}"
group: "{{ etherpad_group }}" group: "{{ etherpad_group }}"
mode: 0755 mode: 0755
tags: configuration
- name: '[CONFIGURE] - Deploy config' - name: '[CONFIGURE] - Deploy config'
template: template:
@ -17,3 +18,4 @@
mode: 0644 mode: 0644
notify: notify:
restart etherpad restart etherpad
tags: configuration

View File

@ -11,6 +11,7 @@
- name: Deploy configuration - name: Deploy configuration
include_tasks: configure.yml include_tasks: configure.yml
tags: configuration
- name: Install Modules - name: Install Modules
include_tasks: modules.yml include_tasks: modules.yml

View File

@ -1,40 +1,28 @@
--- ---
#- name: '[Modules] - Install modules' # The following command get the etherpad_plugins_list dictionnary
# npm: # selects only the enabled plugins
# name: "{{ item.name }}" # then uses filter to get all plugins names in one line, without comas or quotes as needed for npm
# path: "{{ etherpad_app_dir }}/app"
# state: latest
# with_items: "{{ etherpad_plugins }}"
# become: yes
# become_user: "{{ etherpad_username }}"
# when: item.install|lower == 'true'
# notify:
# restart etherpad
# tags: modules
- name: '[Modules] - Install modules' - name: '[Modules] - Install modules'
shell: shell:
cmd: "npm install --no-save --legacy-peer-deps {{ item.name }}" cmd: "npm install --no-save --legacy-peer-deps {{ etherpad_plugins_list| dict2items | selectattr('value', 'eq', 'enabled') | map(attribute='key') |join(',') | replace(\",\", \" \") }}"
args: args:
chdir: "{{ etherpad_app_dir }}/app" chdir: "{{ etherpad_app_dir }}/app"
with_items: "{{ etherpad_plugins }}"
become: yes become: yes
become_user: "{{ etherpad_username }}" become_user: "{{ etherpad_username }}"
when: item.install|lower == 'true' when: etherpad_plugins_list| dict2items | selectattr('value', 'eq', 'enabled') |length > 0
notify: notify:
restart etherpad restart etherpad
tags: modules tags: modules
- name: '[Modules] - Uninstall modules' - name: '[Modules] - Uninstall modules'
npm: shell:
name: "{{ item.name }}" cmd: "npm uninstall {{ etherpad_plugins_list| dict2items | selectattr('value', 'eq', 'disabled') | map(attribute='key') |join(',') | replace(\",\", \" \") }}"
path: "{{ etherpad_app_dir }}/app" args:
state: absent chdir: "{{ etherpad_app_dir }}/app"
with_items: "{{ etherpad_plugins }}"
become: yes become: yes
become_user: "{{ etherpad_username }}" become_user: "{{ etherpad_username }}"
when: item.install|lower == 'false' when: etherpad_plugins_list| dict2items | selectattr('value', 'eq', 'disabled') |length > 0
notify: notify:
restart etherpad restart etherpad
tags: modules tags: modules

View File

@ -532,20 +532,20 @@
*/ */
}, },
{% for item in etherpad_plugins %} {% for key, value in etherpad_plugins_list.items() %}
{% if item.name == 'ep_delete_after_delay' and item.install %} {% if key == "ep_delete_after_delay" and value == "enabled" %}
/* This adds delete_after_delay config vars "ep_delete_after_delay": {
*/ "delay": {{ delay }}, // one day, in seconds
"ep_delete_after_delay": { "loop": {{ loopdeletion }},
"delay": {{ delay }}, // one day, in seconds "loopDelay": {{ loopDelay }}, // one hour, in seconds
"loop": {{ loopdeletion }}, "deleteAtStart": {{ deleteAtStart }},
"loopDelay": {{ loopDelay }}, // one hour, in seconds "text": "{{ text }}"
"deleteAtStart": {{ deleteAtStart }},
"text": "{{ text }}"
}, },
{% endif %} {% endif %}
{% endfor %} {% endfor %}
/* /*
* Restrict socket.io transport methods * Restrict socket.io transport methods
*/ */