diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2016-09-18 17:55:33 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2016-09-18 17:55:33 +0200 |
commit | a4ecc629b38e9d9d4cf918d6095112347c141e55 (patch) | |
tree | 654def79ff5bab9a947887ee2ce2942ac3082d7d /roles | |
parent | 87dc808939fbc740c3742e10ce4d23a4c7099c07 (diff) |
Postfix: ensure common aliases are present.
Diffstat (limited to 'roles')
-rw-r--r-- | roles/amavis/tasks/main.yml | 10 | ||||
-rw-r--r-- | roles/common/tasks/clamav.yml | 10 | ||||
-rw-r--r-- | roles/common/tasks/mail.yml | 11 |
3 files changed, 28 insertions, 3 deletions
diff --git a/roles/amavis/tasks/main.yml b/roles/amavis/tasks/main.yml index c061d09..d4298b8 100644 --- a/roles/amavis/tasks/main.yml +++ b/roles/amavis/tasks/main.yml @@ -13,40 +13,50 @@ - pax - binutils - p7zip-full - unrar-free - arj - nomarch - zoo - ripole - cabextract - unar - tnef notify: - Restart Amavis - name: Add 'clamav' to the group 'amavis' user: name=clamav groups=amavis append=yes notify: - Restart ClamAV - Restart Amavis +- name: Add an 'amavis' alias + lineinfile: dest=/etc/aliases create=yes + regexp="^amavis{{':'}} " + line="amavis{{':'}} root" + +- name: Compile the static local Postfix database + postmap: cmd=postalias src=/etc/aliases db=cdb + owner=root group=root + mode=0644 + - name: Create directory /var/lib/dkim file: path=/var/lib/dkim state=directory owner=root group=root mode=0755 when: "'out' in group_names" tags: - genkey - name: Generate a private key for DKIM signing command: genkeypair.sh dkim --privkey=/var/lib/dkim/20140703.fripost.org.key -t rsa -b 1024 register: dkim changed_when: dkim.rc == 0 failed_when: dkim.rc > 1 when: "'out' in group_names" notify: - Restart Amavis - Publish the public key to the DNS zone tags: - genkey diff --git a/roles/common/tasks/clamav.yml b/roles/common/tasks/clamav.yml index 3579d31..1c68598 100644 --- a/roles/common/tasks/clamav.yml +++ b/roles/common/tasks/clamav.yml @@ -2,20 +2,30 @@ apt: pkg={{ item }} with_items: - clamav - clamav-daemon - clamav-freshclam - name: Configure FreshClam template: src=etc/clamav/freshclam.conf.j2 dest=/etc/clamav/freshclam.conf owner=clamav group=adm mode=0444 tags: freshclam notify: - Restart freshclam - name: Start ClamAV service: name={{ item }} state=started with_items: - clamav-daemon - clamav-freshclam + +- name: Add a 'clamav' alias + lineinfile: dest=/etc/aliases create=yes + regexp="^clamav{{':'}} " + line="clamav{{':'}} root" + +- name: Compile the static local Postfix database + postmap: cmd=postalias src=/etc/aliases db=cdb + owner=root group=root + mode=0644 diff --git a/roles/common/tasks/mail.yml b/roles/common/tasks/mail.yml index 6f690e6..1877f21 100644 --- a/roles/common/tasks/mail.yml +++ b/roles/common/tasks/mail.yml @@ -19,39 +19,44 @@ file: src=../postfix/dynamicmaps.cf dest=/etc/postfix-{{ postfix_instance[item].name }}/dynamicmaps.cf owner=root group=root state=link force=yes register: r2 with_items: "{{ postfix_instance.keys() | intersect(group_names) | list }}" notify: - Restart Postfix - name: Configure Postfix template: src=etc/postfix/{{ item }}.j2 dest=/etc/postfix/{{ item }} owner=root group=root mode=0644 with_items: - main.cf - master.cf notify: - Reload Postfix -- name: Add a 'root' alias +- name: Add some common aliases lineinfile: dest=/etc/aliases create=yes - regexp="^root{{':'}} " - line="root{{':'}} root@fripost.org" + regexp='^{{ item.src }}{{':'}} ' + line='{{ item.src }}{{':'}} {{ item.dst }}' + with_items: + - { src: mailer-daemon, dst: 'postmaster' } + - { src: postmaster, dst: 'root' } + - { src: nobody, dst: 'root' } + - { src: root, dst: 'root@fripost.org' } - name: Compile the static local Postfix database postmap: cmd=postalias src=/etc/aliases db=cdb owner=root group=root mode=0644 # We're using CDB - name: Delete /etc/aliases.db file: path=/etc/aliases.db state=absent - name: Start Postfix service: name=postfix state=started when: not (r1.changed or r2.changed) - meta: flush_handlers |