From 00383ad2c30c5f12605b6c8246e03c888bbc60a5 Mon Sep 17 00:00:00 2001 From: Andrea Cimbalo Date: Wed, 17 Aug 2016 00:29:12 +0200 Subject: [PATCH] add exim4 role (RELAY/sympa_transport) --- roles/exim4/defaults/main.yaml | 2 + roles/exim4/handlers/main.yml | 11 ++++ roles/exim4/tasks/main.yaml | 105 +++++++++++++++++++++++++++++++++ roles/sympa/meta/main.yaml | 3 + 4 files changed, 121 insertions(+) create mode 100644 roles/exim4/defaults/main.yaml create mode 100644 roles/exim4/handlers/main.yml create mode 100644 roles/exim4/tasks/main.yaml diff --git a/roles/exim4/defaults/main.yaml b/roles/exim4/defaults/main.yaml new file mode 100644 index 0000000..10ce171 --- /dev/null +++ b/roles/exim4/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +sympa_transport: false diff --git a/roles/exim4/handlers/main.yml b/roles/exim4/handlers/main.yml new file mode 100644 index 0000000..db02fc9 --- /dev/null +++ b/roles/exim4/handlers/main.yml @@ -0,0 +1,11 @@ +--- +- name: update exim4 configuration + shell: rm /etc/exim4/update-exim4.conf.conf || true; dpkg-reconfigure exim4-config -f noninteractive; /usr/sbin/update-exim4.conf + +- name: update-exim4.conf + shell: /usr/sbin/update-exim4.conf + notify: restart exim4 + +- include: service.yaml + vars: + service_name: exim4 diff --git a/roles/exim4/tasks/main.yaml b/roles/exim4/tasks/main.yaml new file mode 100644 index 0000000..f0bccd4 --- /dev/null +++ b/roles/exim4/tasks/main.yaml @@ -0,0 +1,105 @@ + +- name: configure exim4-config + debconf: + name: 'exim4-config' + question: '{{ item.key }}' + vtype: 'string' + value: '{{ item.value }}' + with_dict: + exim4/dc_smarthost: '{{ stmp_relay }}' + exim4/dc_minimaldns: false + exim4/dc_postmaster: + exim4/dc_localdelivery: mbox format in /var/mail/ + exim4/dc_readhost: + exim4/dc_other_hostnames: '{{ ansible_hostname }}.lilik.it' + exim4/dc_relay_nets: + exim4/exim4-config-title: + exim4/no_config: false + exim4/mailname: '{{ ansible_hostname }}.lilik.it' + exim4/use_split_config: false + exim4/hide_mailname: false + exim4/dc_relay_domains: + notify: + - update exim4 configuration + - restart exim4 + +- name: configure exim4-config (sympa_transport) + debconf: + name: 'exim4-config' + question: '{{ item.key }}' + vtype: 'string' + value: '{{ item.value }}' + with_dict: + exim4/dc_eximconfig_configtype: mail sent by smarthost; received via SMTP or fetchmail + exim4/dc_local_interfaces: + when: sympa_transport | bool + notify: + - update exim4 configuration + - restart exim4 + + +- name: configure exim4-config (smarthost) + debconf: + name: 'exim4-config' + question: '{{ item.key }}' + vtype: 'string' + value: '{{ item.value }}' + with_dict: + exim4/dc_eximconfig_configtype: mail sent by smarthost; no local mail + exim4/dc_local_interfaces: 127.0.0.1 ; ::1 + when: not sympa_transport | bool + notify: + - update exim4 configuration + - restart exim4 + +- block: + - include: service.yaml + # static: yes # see static include issue: https://github.com/ansible/ansible/issues/13485 + vars: + service_name: exim4 + service_packages: + - exim4 + + - name: exim4 macro for sympa aliases + blockinfile: + dest: /etc/exim4/exim4.conf.localmacros + block: | + #-------------- + # Activating pipe transport in system_aliases router (pipes in /etc/aliases) + .ifndef SYSTEM_ALIASES_PIPE_TRANSPORT + SYSTEM_ALIASES_PIPE_TRANSPORT = address_pipe + .endif + .ifndef SYSTEM_ALIASES_USER + SYSTEM_ALIASES_USER = sympa + .endif + .ifndef SYSTEM_ALIASES_GROUP + SYSTEM_ALIASES_GROUP = sympa + .endif + #-------------- + create: yes + notify: + - update exim4 configuration + - restart exim4 + + - name: exim4 pipe for sympa aliases + blockinfile: + dest: /etc/exim4/exim4.conf.template + block: | + #-------------- + # Using alias pipe definitions for the Sympa lists in /etc/mail/sympa/aliases + sympa_aliases: + debug_print = "R: system_aliases for $local_part@$domain" + driver = redirect + domains = +local_domains + allow_fail + allow_defer + data = ${lookup{$local_part}lsearch{/etc/mail/sympa/aliases}} + user = sympa + group = sympa + pipe_transport = address_pipe + #-------------- + insertbefore: 'system_aliases:' + notify: + - update-exim4.conf + - restart exim4 + when: sympa_transport | bool diff --git a/roles/sympa/meta/main.yaml b/roles/sympa/meta/main.yaml index 140047c..9acd286 100644 --- a/roles/sympa/meta/main.yaml +++ b/roles/sympa/meta/main.yaml @@ -2,3 +2,6 @@ dependencies: - role: nginx parent_role_path: "sympa" + - role: exim4 + stmp_relay: "{{ hostvars['mail'].ansible_host }}" + sympa_transport: true