change from list to dict

This commit is contained in:
meaz 2023-08-23 08:37:23 +02:00
parent 37f497d096
commit e35b914ed6
Signed by: meaz
GPG key ID: CD7A47B2F1ED43B4
3 changed files with 41 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

@ -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
*/ */