summaryrefslogtreecommitdiffstats
path: root/roles/mailman
diff options
context:
space:
mode:
authorMichael Scherer <misc@zarb.org>2014-12-12 14:28:47 +0100
committerMichael Scherer <misc@zarb.org>2014-12-12 14:28:47 +0100
commitca315bf9c292d4757b67a86117e3182c1b0dd680 (patch)
tree57923818c4e974b2d7f8e16be14ef3d8612b855f /roles/mailman
parentd9e874ece0c162fcba01553fbea0a8b2fd86d249 (diff)
Import postfix/mailman from rad
Diffstat (limited to 'roles/mailman')
-rw-r--r--roles/mailman/files/dump_mailman.sh10
-rw-r--r--roles/mailman/files/fix_ansible.conf5
-rw-r--r--roles/mailman/files/update_templates_mailman.sh16
-rw-r--r--roles/mailman/handlers/main.yml9
-rw-r--r--roles/mailman/meta/main.yml5
-rw-r--r--roles/mailman/tasks/main.yml36
-rw-r--r--roles/mailman/templates/aliases12
-rw-r--r--roles/mailman/templates/mm_cfg.py12
-rw-r--r--roles/mailman/templates/vhost.conf14
9 files changed, 119 insertions, 0 deletions
diff --git a/roles/mailman/files/dump_mailman.sh b/roles/mailman/files/dump_mailman.sh
new file mode 100644
index 0000000..4626e31
--- /dev/null
+++ b/roles/mailman/files/dump_mailman.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+DIR=/var/backups/mailman/
+[ -d $DIR ] || mkdir -p $DIR
+
+for i in $(/usr/lib/mailman/bin/list_lists -b); do
+ for j in admins members owners; do
+ /usr/lib/mailman/bin/list_${j} > $DIR/${i}.${j}
+ done
+ /usr/lib/mailman/bin/config_list -o $DIR/${i}.config ${i}
+done
diff --git a/roles/mailman/files/fix_ansible.conf b/roles/mailman/files/fix_ansible.conf
new file mode 100644
index 0000000..036fa8e
--- /dev/null
+++ b/roles/mailman/files/fix_ansible.conf
@@ -0,0 +1,5 @@
+[Service]
+ExecStop=
+ExecStop=/usr/lib/mailman/bin/mailman-update-cfg
+ExecStop=/usr/lib/mailman/bin/mailmanctl stop
+ExecStop=/bin/sh -c 'echo -e "# Master copy is /usr/lib/mailman/cron/crontab.in" > /etc/cron.d/mailman'
diff --git a/roles/mailman/files/update_templates_mailman.sh b/roles/mailman/files/update_templates_mailman.sh
new file mode 100644
index 0000000..1e954ce
--- /dev/null
+++ b/roles/mailman/files/update_templates_mailman.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+GIT_URL=$1
+CACHE_DIR=/var/cache/mailman_templates
+
+if [ ! -d $CACHE_DIR ]; then
+ git clone $GIT_URL /var/cache/mailman_templates
+ cd $CACHE_DIR
+else
+ cd $CACHE_DIR
+ # on EL6, git is not respecting -q, unlike Fedora
+ git pull --rebase -q >/dev/null
+fi
+cp -R * /var/lib/mailman/lists/
+rm -f /var/lib/mailman/lists/README.md
+chown -R apache:mailman /var/lib/mailman/lists/
+
diff --git a/roles/mailman/handlers/main.yml b/roles/mailman/handlers/main.yml
new file mode 100644
index 0000000..2995857
--- /dev/null
+++ b/roles/mailman/handlers/main.yml
@@ -0,0 +1,9 @@
+---
+- name: restart mailman
+ service: name=mailman state=restarted
+
+- name: update mailman aliases
+ command: postalias {{ item }}
+ with_items:
+ - /etc/postfix/aliases.mailman
+ - /etc/postfix/aliases.mailman_default
diff --git a/roles/mailman/meta/main.yml b/roles/mailman/meta/main.yml
new file mode 100644
index 0000000..e949ef9
--- /dev/null
+++ b/roles/mailman/meta/main.yml
@@ -0,0 +1,5 @@
+---
+dependencies:
+- { role: postfix }
+- { role: httpd, custom_vhost: yes }
+
diff --git a/roles/mailman/tasks/main.yml b/roles/mailman/tasks/main.yml
new file mode 100644
index 0000000..e5b78da
--- /dev/null
+++ b/roles/mailman/tasks/main.yml
@@ -0,0 +1,36 @@
+---
+- yum: name={{ item }} state=installed
+ with_items:
+ - mailman
+ - git
+ - pwgen
+
+- command: creates=/var/lib/mailman/lists/mailman /usr/lib/mailman/bin/newlist -q mailman root@{{ ansible_domain }} {{ mailman_pass }}
+
+#
+# this is a ugly work around for https://github.com/ansible/ansible-modules-core/issues/127
+- file: name=/etc/systemd/system/mailman.service.d/ state=directory
+ when: ansible_distribution == 'Fedora' or ansible_distribution_major_version == '7'
+
+- copy: mode=0644 src=fix_ansible.conf dest=/etc/systemd/system/mailman.service.d/fix_ansible_bug.conf
+ when: ansible_distribution == 'Fedora' or ansible_distribution_major_version == '7'
+
+- template: src=mm_cfg.py dest=/etc/mailman/mm_cfg.py
+
+- service: name=mailman state=started enabled=yes
+
+- template: src=aliases dest=/etc/postfix/aliases.mailman_default
+ notify: update mailman aliases
+
+
+- template: src=vhost.conf dest=/etc/httpd/conf.d/{{ website_url | default( ansible_hostname ) }}.conf
+ notify: restart httpd
+
+- copy: mode=0755 src=update_templates_mailman.sh dest=/usr/local/bin/update_templates_mailman.sh
+
+- cron: name="update mailman {{ mailman_git }}" job="/usr/local/bin/update_templates_mailman.sh {{ mailman_git }}" minute="*/5"
+ when: mailman_git is defined
+
+- copy: mode=0755 src=dump_mailman.sh dest=/usr/local/bin/dump_mailman.sh
+
+- cron: name="dump mailman" job=/usr/local/bin/dump_mailman.sh hour=3 minute=30
diff --git a/roles/mailman/templates/aliases b/roles/mailman/templates/aliases
new file mode 100644
index 0000000..9fbf58f
--- /dev/null
+++ b/roles/mailman/templates/aliases
@@ -0,0 +1,12 @@
+## default list
+mailman: "|/usr/lib/mailman/mail/mailman post mailman"
+mailman-admin: "|/usr/lib/mailman/mail/mailman admin mailman"
+mailman-bounces: "|/usr/lib/mailman/mail/mailman bounces mailman"
+mailman-confirm: "|/usr/lib/mailman/mail/mailman confirm mailman"
+mailman-join: "|/usr/lib/mailman/mail/mailman join mailman"
+mailman-leave: "|/usr/lib/mailman/mail/mailman leave mailman"
+mailman-owner: "|/usr/lib/mailman/mail/mailman owner mailman"
+mailman-request: "|/usr/lib/mailman/mail/mailman request mailman"
+mailman-subscribe: "|/usr/lib/mailman/mail/mailman subscribe mailman"
+mailman-unsubscribe: "|/usr/lib/mailman/mail/mailman unsubscribe mailman"
+
diff --git a/roles/mailman/templates/mm_cfg.py b/roles/mailman/templates/mm_cfg.py
new file mode 100644
index 0000000..539234a
--- /dev/null
+++ b/roles/mailman/templates/mm_cfg.py
@@ -0,0 +1,12 @@
+# -*- python -*-
+
+from Defaults import *
+import pwd, grp
+
+MAILMAN_UID = pwd.getpwnam('mailman')[2]
+MAILMAN_GID = grp.getgrnam('mailman')[2]
+
+DEFAULT_URL_HOST = "{{ mailman_webinterface }}"
+DEFAULT_EMAIL_HOST = "{{ mailman_prefix }}"
+
+add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
diff --git a/roles/mailman/templates/vhost.conf b/roles/mailman/templates/vhost.conf
new file mode 100644
index 0000000..bd2f01e
--- /dev/null
+++ b/roles/mailman/templates/vhost.conf
@@ -0,0 +1,14 @@
+{% for i in '80', '443' %}
+<VirtualHost *:{{ i }}>
+
+ <Directory /usr/lib/mailman/cgi-bin/>
+ DirectoryIndex listinfo
+ </Directory>
+
+ RedirectMatch ^/$ /mailman/
+
+ RedirectMatch ^/mailman[/]*$ /mailman/listinfo
+ ServerName {{ website_url | default( ansible_hostname ) }}
+
+</VirtualHost>
+{% endfor %}