forked from ISTI-ansible-roles/ansible-role-mailman
Add a missing template.
This commit is contained in:
parent
9d2e4c48d0
commit
13f6679de3
|
|
@ -0,0 +1,28 @@
|
|||
"""Seed configured header matches on otherwise unconfigured mailing lists."""
|
||||
|
||||
from json import loads
|
||||
|
||||
from mailman.interfaces.mailinglist import IHeaderMatchList
|
||||
|
||||
|
||||
RULES = loads({{ mailman_empty_list_header_matches | to_json | to_json }})
|
||||
|
||||
|
||||
def apply(mlist):
|
||||
"""Add all configured rules if *mlist* has no header matches."""
|
||||
header_matches = IHeaderMatchList(mlist)
|
||||
existing_count = len(header_matches)
|
||||
if existing_count:
|
||||
print('SKIPPED {} existing_header_matches={}'.format(
|
||||
mlist.fqdn_listname, existing_count))
|
||||
return
|
||||
|
||||
for rule in RULES:
|
||||
header_matches.append(
|
||||
rule['header'],
|
||||
rule['pattern'],
|
||||
chain=rule.get('action'),
|
||||
tag=rule.get('tag'))
|
||||
|
||||
print('CHANGED {} added_header_matches={}'.format(
|
||||
mlist.fqdn_listname, len(RULES)))
|
||||
Loading…
Reference in New Issue