forked from ISTI-ansible-roles/ansible-role-mailman
Add tasks to configure the header acceptance rules in the mailing lists settings.
This commit is contained in:
parent
123e9f3f7e
commit
9d2e4c48d0
14
README.md
14
README.md
|
|
@ -10,3 +10,17 @@ mailman_antispam_chain_behaviour: discard
|
||||||
Mailing-list owners can manage list-specific header matches and select their
|
Mailing-list owners can manage list-specific header matches and select their
|
||||||
action (`accept`, `discard`, `hold`, or `reject`) from Postorius. The global
|
action (`accept`, `discard`, `hold`, or `reject`) from Postorius. The global
|
||||||
chain is used only when a matching rule has no explicit action.
|
chain is used only when a matching rule has no explicit action.
|
||||||
|
|
||||||
|
Existing lists without any header matches can be initialized through the
|
||||||
|
Mailman database model by enabling the optional seed operation:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
mailman_seed_empty_list_header_matches: true
|
||||||
|
mailman_empty_list_header_matches:
|
||||||
|
- header: 'X-Spam-Flag'
|
||||||
|
pattern: '^YES$'
|
||||||
|
action: 'discard'
|
||||||
|
```
|
||||||
|
|
||||||
|
The operation is idempotent. A list is modified only when its header-match
|
||||||
|
collection is empty; lists with one or more existing rules are left untouched.
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,12 @@ mailman_antispam_header_checks: []
|
||||||
# 'accept', otherwise 'hold' will be used.
|
# 'accept', otherwise 'hold' will be used.
|
||||||
mailman_antispam_chain_behaviour: "discard"
|
mailman_antispam_chain_behaviour: "discard"
|
||||||
|
|
||||||
|
# Optionally seed list-specific header matches, but only on mailing lists that
|
||||||
|
# do not already have any rules. Existing list configuration is never merged
|
||||||
|
# with or replaced by these defaults.
|
||||||
|
mailman_seed_empty_list_header_matches: false
|
||||||
|
mailman_empty_list_header_matches: []
|
||||||
|
|
||||||
mailman_start_nntp_runner: 'no'
|
mailman_start_nntp_runner: 'no'
|
||||||
|
|
||||||
mailman_repository: 'https://gitlab.com/mailman/mailman-suite.git'
|
mailman_repository: 'https://gitlab.com/mailman/mailman-suite.git'
|
||||||
|
|
@ -182,5 +188,3 @@ mailman_postorius_cronjob_frequency:
|
||||||
mailman_postorius_cronjob_special_times:
|
mailman_postorius_cronjob_special_times:
|
||||||
- 'quarter_hourly'
|
- 'quarter_hourly'
|
||||||
- 'minutely'
|
- 'minutely'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
- '{{ mailman_spool_dir }}'
|
- '{{ mailman_spool_dir }}'
|
||||||
|
|
||||||
- name: Create the mailman virtualenv. Manually, because python 3.6
|
- name: Create the mailman virtualenv. Manually, because python 3.6
|
||||||
become: True
|
become: true
|
||||||
become_user: '{{ mailman_user }}'
|
become_user: '{{ mailman_user }}'
|
||||||
shell: cd '{{ mailman_home }}' && python3 -m venv '{{ mailman_virtualenv_name }}'
|
shell: cd '{{ mailman_home }}' && python3 -m venv '{{ mailman_virtualenv_name }}'
|
||||||
args:
|
args:
|
||||||
|
|
@ -111,6 +111,47 @@
|
||||||
|
|
||||||
tags: [ 'mailman', 'mailman_conf' ]
|
tags: [ 'mailman', 'mailman_conf' ]
|
||||||
|
|
||||||
|
- name: Seed header matches on lists without existing rules
|
||||||
|
block:
|
||||||
|
- name: Create the Mailman administration scripts directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: '{{ mailman_conf_dir }}/scripts'
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: '{{ mailman_user }}'
|
||||||
|
mode: '0750'
|
||||||
|
|
||||||
|
- name: Install the list header matches seed script
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: seed-empty-list-header-matches.py.j2
|
||||||
|
dest: '{{ mailman_conf_dir }}/scripts/seed_empty_list_header_matches.py'
|
||||||
|
owner: root
|
||||||
|
group: '{{ mailman_user }}'
|
||||||
|
mode: '0440'
|
||||||
|
|
||||||
|
- name: Add header matches only to lists without rules
|
||||||
|
become: true
|
||||||
|
become_user: '{{ mailman_user }}'
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- '{{ mailman_bindir }}/mailman'
|
||||||
|
- -C
|
||||||
|
- '{{ mailman_conf_dir }}/mailman.cfg'
|
||||||
|
- shell
|
||||||
|
- --run
|
||||||
|
- seed_empty_list_header_matches.apply
|
||||||
|
- --listspec
|
||||||
|
- '^.*'
|
||||||
|
environment:
|
||||||
|
PYTHONPATH: '{{ mailman_conf_dir }}/scripts'
|
||||||
|
register: mailman_seed_header_matches_result
|
||||||
|
changed_when: "'CHANGED ' in mailman_seed_header_matches_result.stdout"
|
||||||
|
|
||||||
|
when:
|
||||||
|
- not ansible_check_mode
|
||||||
|
- mailman_seed_empty_list_header_matches | bool
|
||||||
|
- mailman_empty_list_header_matches | length > 0
|
||||||
|
tags: [ 'mailman', 'mailman_conf', 'mailman_header_matches' ]
|
||||||
|
|
||||||
- name: Add the maintenance cron jobs
|
- name: Add the maintenance cron jobs
|
||||||
tags: ['mailman', 'mailman_conf', 'mailman_cron']
|
tags: ['mailman', 'mailman_conf', 'mailman_cron']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue