From 25167bc296971d01c7638adf75855d6fb4b290b6 Mon Sep 17 00:00:00 2001 From: Crest Date: Wed, 10 Feb 2021 15:32:59 +0100 Subject: [PATCH] Implement the requested features (as far as possible) --- roles/mlmmj/tasks/main.yml | 66 ++++++++++++++++++++++++++++- roles/mlmmj/templates/moderators.j2 | 3 ++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 roles/mlmmj/templates/moderators.j2 diff --git a/roles/mlmmj/tasks/main.yml b/roles/mlmmj/tasks/main.yml index 1718cbd..4c3c3b3 100644 --- a/roles/mlmmj/tasks/main.yml +++ b/roles/mlmmj/tasks/main.yml @@ -266,7 +266,7 @@ label: '{{ item.name }}@{{ item.domain }}' with_items: '{{ mlmmj_lists }}' -- name: Moderate subscription +- name: Set moderate subscription copy: dest: '/var/vmail/mlmmj/{{ item.name }}/control/submod' content: '' @@ -278,3 +278,67 @@ loop_control: label: '{{ item.name }}@{{ item.domain }}' with_items: '{{ mlmmj_lists }}' + +- name: Unset moderate subscription + file: + path: '/var/vmail/mlmmj/{{ item.name }}/control/submod' + state: absent + when: not (item.subscription_moderated | default(false)) + loop_control: + label: '{{ item.name }}@{{ item.domain }}' + with_items: '{{ mlmmj_lists }}' + +- name: Limit posts to subscribers + copy: + dest: '/var/vmail/mlmmj/{{ item.name }}/control/subonlypost' + content: '' + force: no + owner: mlmmj + group: mlmmj + mode: 0444 + when: item.subscribers_only | default(false) + loop_control: + label: '{{ item.name }}@{{ item.domain }}' + with_items: '{{ mlmmj_lists }}' + +- name: Allow off list posts + file: + path: '/var/vmail/mlmmj/{{ item.name }}/control/subonlypost' + state: absent + when: not (item.subscribers_only | default(false)) + loop_control: + label: '{{ item.name }}@{{ item.domain }}' + with_items: '{{ mlmmj_lists }}' + +- name: Moderate posts from non subscribers + copy: + dest: '/var/vmail/mlmmj/{{ item.name }}/control/modnonsubposts' + content: '' + force: no + owner: mlmmj + group: mlmmj + mode: 0444 + when: item.moderate_nonsubscribers | default(false) + loop_control: + label: '{{ item.name }}@{{ item.domain }}' + with_items: '{{ mlmmj_lists }}' + +- name: Deny posts from non subscribers + file: + path: '/var/vmail/mlmmj/{{ item.name }}/control/modnonsubposts' + state: absent + when: not (item.moderate_nonsubscribers | default(false)) + loop_control: + label: '{{ item.name }}@{{ item.domain }}' + with_items: '{{ mlmmj_lists }}' + +- name: Generate list of moderators + template: + dest: '/var/vmail/mlmmj/{{ item.name }}/control/moderators' + src: moderators.j2 + owner: mlmmj + group: mlmmj + mode: 0444 + loop_control: + label: '{{ item.name }}@{{ item.domain }}' + with_items: '{{ mlmmj_lists }}' diff --git a/roles/mlmmj/templates/moderators.j2 b/roles/mlmmj/templates/moderators.j2 new file mode 100644 index 0000000..055014a --- /dev/null +++ b/roles/mlmmj/templates/moderators.j2 @@ -0,0 +1,3 @@ +{% for moderator in item.moderators | default([]) %} +{{ moderator }} +{% endfor %}