diff --git a/postfix/README.md b/postfix/README.md new file mode 100644 index 00000000..9b76d369 --- /dev/null +++ b/postfix/README.md @@ -0,0 +1,16 @@ +# Postfix + +Install Postfix + +## Tasks + +Minimal configuration is in `tasks/main.yml`. + +## Available variables + +Main variables are : + +* `postfix_hostname` : hostname for Postfix ; +* `postfix_slow_transport` : enable customization for delivrability. + +The full list of variables (with default values) can be found in `defaults/main.yml`. diff --git a/postfix/defaults/main.yml b/postfix/defaults/main.yml new file mode 100644 index 00000000..7bbdea43 --- /dev/null +++ b/postfix/defaults/main.yml @@ -0,0 +1,3 @@ +--- +postfix_hostname: "{{ ansible_fqdn }}" +postfix_slow: False diff --git a/postfix/handlers/main.yml b/postfix/handlers/main.yml new file mode 100644 index 00000000..ee3eb141 --- /dev/null +++ b/postfix/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: restart postfix + service: + name: postfix + state: restarted + diff --git a/postfix/tasks/main.yml b/postfix/tasks/main.yml new file mode 100644 index 00000000..d5926a63 --- /dev/null +++ b/postfix/tasks/main.yml @@ -0,0 +1,28 @@ +- name: ensure packages are installed + apt: + name: '{{ item }}' + state: present + with_items: + - postfix + - mailgraph + +- name: check if main.cf is default + shell: egrep -v "^(myhostname|mydestination|mailbox_command)" /etc/postfix/main.cf | md5sum - + changed_when: False + #check_mode: no (for migration to Ansible 2.2) + always_run: yes + register: default_main_cf + +- name: create minimal main.cf + template: + src: evolinux_main.cf.j2 + dest: /etc/postfix/main.cf + owner: root + group: root + mode: 0644 + force: yes + when: default_main_cf.stdout == "5450c05d65878e99dad696c7c722e511 -" + notify: restart postfix + +- meta: flush_handlers + diff --git a/postfix/templates/evolinux_main.cf.j2 b/postfix/templates/evolinux_main.cf.j2 new file mode 100644 index 00000000..429e6602 --- /dev/null +++ b/postfix/templates/evolinux_main.cf.j2 @@ -0,0 +1,15 @@ +smtpd_banner = $myhostname ESMTP mail server +biff = no +append_dot_mydomain = no +myhostname = {{ postfix_hostname }} +alias_maps = hash:/etc/aliases +alias_database = hash:/etc/aliases +myorigin = $myhostname +mydestination = $myhostname localhost.localdomain localhost +relayhost = +mynetworks = 127.0.0.0/8 +mailbox_size_limit = 0 +recipient_delimiter = + +inet_interfaces = all +inet_protocols = ipv4 +disable_vrfy_command = yes