forked from evolix/ansible-roles
postfix: split main task into minimal and packmail
This commit is contained in:
parent
a3744bbe59
commit
0cdae8b246
|
@ -1,21 +1,4 @@
|
||||||
- name: ensure packages are installed
|
---
|
||||||
apt:
|
|
||||||
name: '{{ item }}'
|
|
||||||
state: present
|
|
||||||
with_items:
|
|
||||||
- postfix
|
|
||||||
- mailgraph
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: ensure ldap packages are installed
|
|
||||||
apt:
|
|
||||||
name: "postfix-ldap"
|
|
||||||
state: present
|
|
||||||
when: postfix_packmail == True
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: check if main.cf is default
|
- name: check if main.cf is default
|
||||||
shell: grep -v -E "^(myhostname|mydestination|mailbox_command)" /etc/postfix/main.cf | md5sum -
|
shell: grep -v -E "^(myhostname|mydestination|mailbox_command)" /etc/postfix/main.cf | md5sum -
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
@ -24,130 +7,11 @@
|
||||||
tags:
|
tags:
|
||||||
- postfix
|
- postfix
|
||||||
|
|
||||||
- block:
|
- include: minimal.yml
|
||||||
|
when: postfix_packmail == False
|
||||||
|
|
||||||
- name: create minimal main.cf
|
- include: packmail.yml
|
||||||
template:
|
|
||||||
src: evolinux_main.cf.j2
|
|
||||||
dest: /etc/postfix/main.cf
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
force: yes
|
|
||||||
when: postfix_packmail != True
|
|
||||||
notify: restart postfix
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: create packmail main.cf
|
|
||||||
template:
|
|
||||||
src: packmail_main.cf.j2
|
|
||||||
dest: /etc/postfix/main.cf
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
force: yes
|
|
||||||
when: postfix_packmail == True
|
when: postfix_packmail == True
|
||||||
notify: restart postfix
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
when: postfix_force_main_cf == True or
|
|
||||||
default_main_cf.stdout == "5450c05d65878e99dad696c7c722e511 -" or
|
|
||||||
default_main_cf.stdout == "30022953f1f61f002bfb72e163ecb27e -"
|
|
||||||
|
|
||||||
- name: deploy packmail master.cf
|
|
||||||
template:
|
|
||||||
src: packmail_master.cf.j2
|
|
||||||
dest: /etc/postfix/master.cf
|
|
||||||
mode: "0644"
|
|
||||||
when: postfix_packmail == True
|
|
||||||
notify: restart postfix
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: copy default filter files
|
|
||||||
copy:
|
|
||||||
src: filter
|
|
||||||
dest: "/etc/postfix/{{ item }}"
|
|
||||||
force: no
|
|
||||||
with_items:
|
|
||||||
- virtual
|
|
||||||
- client.access
|
|
||||||
- client.access_local
|
|
||||||
- header_kill
|
|
||||||
- header_kill_local
|
|
||||||
- recipient.access
|
|
||||||
- recipient.access_local
|
|
||||||
- sa-blacklist.access
|
|
||||||
- sender.access
|
|
||||||
- sender.access_local
|
|
||||||
- spamd.cidr
|
|
||||||
when: postfix_packmail == True
|
|
||||||
register: postfix_copy_filter
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: postmap filter files
|
|
||||||
command: "postmap /etc/postfix/{{ item }}"
|
|
||||||
with_items:
|
|
||||||
- virtual
|
|
||||||
- client.access
|
|
||||||
- client.access_local
|
|
||||||
- header_kill
|
|
||||||
- header_kill_local
|
|
||||||
- recipient.access
|
|
||||||
- recipient.access_local
|
|
||||||
- sa-blacklist.access
|
|
||||||
- sender.access
|
|
||||||
- sender.access_local
|
|
||||||
- spamd.cidr
|
|
||||||
when: postfix_packmail == True and postfix_copy_filter.changed
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: deploy ldap postfix config
|
|
||||||
template:
|
|
||||||
src: "{{ item }}.j2"
|
|
||||||
dest: "/etc/postfix/{{ item }}"
|
|
||||||
mode: "0644"
|
|
||||||
with_items:
|
|
||||||
- virtual_aliases.cf
|
|
||||||
- virtual_domains.cf
|
|
||||||
- virtual_mailboxes.cf
|
|
||||||
when: postfix_packmail == True
|
|
||||||
notify: restart postfix
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: copy spam.sh script
|
|
||||||
copy:
|
|
||||||
src: spam.sh
|
|
||||||
dest: /usr/share/scripts/spam.sh
|
|
||||||
mode: "0700"
|
|
||||||
when: postfix_packmail == True
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: enable spam.sh cron
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/cron.d/spam
|
|
||||||
line: "42 * * * * /usr/share/scripts/spam.sh"
|
|
||||||
create: yes
|
|
||||||
state: present
|
|
||||||
mode: "0640"
|
|
||||||
when: postfix_packmail == True
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- name: update antispam list
|
|
||||||
command: /usr/share/scripts/spam.sh
|
|
||||||
changed_when: false
|
|
||||||
when: postfix_packmail == True
|
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
||||||
- include: slow_transport.yml
|
- include: slow_transport.yml
|
||||||
when: postfix_slow_transport_include
|
when: postfix_slow_transport_include
|
||||||
tags:
|
|
||||||
- postfix
|
|
||||||
|
|
24
postfix/tasks/minimal.yml
Normal file
24
postfix/tasks/minimal.yml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
- name: ensure packages are installed
|
||||||
|
apt:
|
||||||
|
name: '{{ item }}'
|
||||||
|
state: present
|
||||||
|
with_items:
|
||||||
|
- postfix
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: create minimal main.cf
|
||||||
|
template:
|
||||||
|
src: evolinux_main.cf.j2
|
||||||
|
dest: /etc/postfix/main.cf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
force: yes
|
||||||
|
notify: restart postfix
|
||||||
|
when: postfix_force_main_cf == True or
|
||||||
|
default_main_cf.stdout == "5450c05d65878e99dad696c7c722e511 -" or
|
||||||
|
default_main_cf.stdout == "30022953f1f61f002bfb72e163ecb27e -"
|
||||||
|
tags:
|
||||||
|
- postfix
|
111
postfix/tasks/packmail.yml
Normal file
111
postfix/tasks/packmail.yml
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
---
|
||||||
|
- name: ensure packages are installed
|
||||||
|
apt:
|
||||||
|
name: '{{ item }}'
|
||||||
|
state: present
|
||||||
|
with_items:
|
||||||
|
- postfix
|
||||||
|
- postfix-ldap
|
||||||
|
- mailgraph
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: create packmail main.cf
|
||||||
|
template:
|
||||||
|
src: packmail_main.cf.j2
|
||||||
|
dest: /etc/postfix/main.cf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
force: yes
|
||||||
|
notify: restart postfix
|
||||||
|
when: postfix_force_main_cf == True or
|
||||||
|
default_main_cf.stdout == "5450c05d65878e99dad696c7c722e511 -" or
|
||||||
|
default_main_cf.stdout == "30022953f1f61f002bfb72e163ecb27e -"
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: deploy packmail master.cf
|
||||||
|
template:
|
||||||
|
src: packmail_master.cf.j2
|
||||||
|
dest: /etc/postfix/master.cf
|
||||||
|
mode: "0644"
|
||||||
|
notify: restart postfix
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: copy default filter files
|
||||||
|
copy:
|
||||||
|
src: filter
|
||||||
|
dest: "/etc/postfix/{{ item }}"
|
||||||
|
force: no
|
||||||
|
with_items:
|
||||||
|
- virtual
|
||||||
|
- client.access
|
||||||
|
- client.access_local
|
||||||
|
- header_kill
|
||||||
|
- header_kill_local
|
||||||
|
- recipient.access
|
||||||
|
- recipient.access_local
|
||||||
|
- sa-blacklist.access
|
||||||
|
- sender.access
|
||||||
|
- sender.access_local
|
||||||
|
- spamd.cidr
|
||||||
|
register: postfix_copy_filter
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: postmap filter files
|
||||||
|
command: "postmap /etc/postfix/{{ item }}"
|
||||||
|
with_items:
|
||||||
|
- virtual
|
||||||
|
- client.access
|
||||||
|
- client.access_local
|
||||||
|
- header_kill
|
||||||
|
- header_kill_local
|
||||||
|
- recipient.access
|
||||||
|
- recipient.access_local
|
||||||
|
- sa-blacklist.access
|
||||||
|
- sender.access
|
||||||
|
- sender.access_local
|
||||||
|
- spamd.cidr
|
||||||
|
when: postfix_copy_filter.changed
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: deploy ldap postfix config
|
||||||
|
template:
|
||||||
|
src: "{{ item }}.j2"
|
||||||
|
dest: "/etc/postfix/{{ item }}"
|
||||||
|
mode: "0644"
|
||||||
|
with_items:
|
||||||
|
- virtual_aliases.cf
|
||||||
|
- virtual_domains.cf
|
||||||
|
- virtual_mailboxes.cf
|
||||||
|
notify: restart postfix
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: copy spam.sh script
|
||||||
|
copy:
|
||||||
|
src: spam.sh
|
||||||
|
dest: /usr/share/scripts/spam.sh
|
||||||
|
mode: "0700"
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: enable spam.sh cron
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/cron.d/spam
|
||||||
|
line: "42 * * * * /usr/share/scripts/spam.sh"
|
||||||
|
create: yes
|
||||||
|
state: present
|
||||||
|
mode: "0640"
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
|
- name: update antispam list
|
||||||
|
command: /usr/share/scripts/spam.sh
|
||||||
|
changed_when: false
|
||||||
|
tags:
|
||||||
|
- postfix
|
|
@ -5,6 +5,8 @@
|
||||||
regexp: "^slow "
|
regexp: "^slow "
|
||||||
line: "slow unix - - n - - smtp"
|
line: "slow unix - - n - - smtp"
|
||||||
notify: restart postfix
|
notify: restart postfix
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
||||||
- name: list of providers for slow transport
|
- name: list of providers for slow transport
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -21,3 +23,5 @@
|
||||||
- "hotmail.fr slow:"
|
- "hotmail.fr slow:"
|
||||||
- "hotmail.com slow:"
|
- "hotmail.com slow:"
|
||||||
notify: postmap transport
|
notify: postmap transport
|
||||||
|
tags:
|
||||||
|
- postfix
|
||||||
|
|
Loading…
Reference in a new issue