Jeremy Stanley 087fbd7dd7 Re-expose our Mailman archives.yaml and robots.txt
In switching to all-HTTPS for Mailman sites, it was missed that only
the plain HTTP vhosts set a DocumentRoot of /var/www. This was only
used for publishing metadata so went unnoticed until now. Rather
than add a DocumentRoot to the new HTTPS vhosts, simply use Aliases
to map the specific files we want to expose, for improved clarity
and to make it less likely they'll be overlooked in configuration in
the future.

In order to make sure the archives.yaml file exists at server
creation, before its cronjob fires for the first time, add a direct
invocation of the script which builds it. Move all tasks related to
this after the tasks which create the mailing lists, so that the
generated file will include them. This also simplifies testing.

For the non-multihost configuration, only robots.txt is expected to
be present, so don't add an alias for archives.yaml there.

Also add regression tests to ensure we keep these working.

Change-Id: I6b54b0386f0ea9f888c1f23580ad8698314474b9
2022-09-22 20:10:20 +00:00

145 lines
3.5 KiB
YAML

- name: Install apache2
package:
name:
- apache2
- apache2-utils
state: present
- name: Apache modules
apache2_module:
state: present
name: "{{ a2_mod }}"
loop:
- rewrite
- cgid
- ssl
loop_control:
loop_var: a2_mod
notify: mailman restart apache2
- name: Make sure packaged default site disabled
command: a2dissite 000-default.conf
args:
removes: /etc/apache2/sites-enabled/000-default.conf
- name: Install mailman
package:
name:
- mailman
- python-is-python2
state: present
# Install index.html, robots.txt
- name: Install mailman index.html
copy:
src: index.html
dest: /var/www/index.html
owner: root
group: root
mode: '0444'
- name: Install mailman robots.txt
copy:
src: robots.txt
dest: /var/www/robots.txt
owner: root
group: root
mode: '0444'
- name: multihost mailman configs
block:
- name: Create multihost dir
file:
path: /srv/mailman
state: directory
owner: root
group: root
mode: '0755'
- name: Install multihost mailman config
copy:
src: mm_cfg_multihost.py
dest: /etc/mailman/mm_cfg.py
owner: root
group: root
mode: '0444'
- name: Create mm sites file
template:
src: sites.j2
dest: /etc/mailman/sites
owner: root
group: root
mode: '0444'
- name: Create mailman sites and lists
include_role:
name: mailman-site
vars:
mailman_site: "{{ site }}"
loop: "{{ mailman_sites }}"
loop_control:
loop_var: site
- name: Write /etc/aliases.domain
template:
src: "domain_aliases.j2"
dest: "/etc/aliases.domain"
mode: 0444
- name: Install mailman mk-archives-index
copy:
src: mk-archives-index
dest: /usr/local/sbin/mk-archives-index
owner: root
group: root
mode: '0744'
- name: Set cron PATH for mk-archives-index
cron:
name: PATH
env: yes
job: /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
- name: Pre-run mk-archives-index
shell:
cmd: /usr/local/sbin/mk-archives-index > /var/www/archives.yaml
args:
creates: /var/www/archives.yaml
- name: Enable mk-archives-index cron
cron:
name: "mk-archives-index cron"
state: present
job: mk-archives-index > /var/www/archives.yaml
minute: "0"
hour: "0"
when: mailman_multihost
- name: normal mailman configs
block:
- name: Install normal mailman config
template:
src: mm_cfg.py.j2
dest: /etc/mailman/mm_cfg.py
owner: root
group: root
mode: '0444'
- name: Create normal mailman vhost config
template:
src: mailman.vhost.j2
dest: "/etc/apache2/sites-enabled/50-{{ mailman_listdomain }}.conf"
owner: root
group: root
mode: '0644'
notify: mailman reload apache2
- name: Enable mailman site service
service:
name: "mailman"
enabled: yes
- name: Create mailman site lists
include_role:
name: mailman-list
vars:
mm_site_name: "_default"
mm_list_name: "{{ list.name }}"
mm_list_description: "{{ list.description }}"
mm_list_admin: "{{ list.admin }}"
mm_list_password: "{{ list.password }}"
loop: "{{ mailman_lists }}"
loop_control:
loop_var: list
when: not mailman_multihost