Initial commit
This commit is contained in:
7
roles/postfix-v4/defaults/main.yml
Normal file
7
roles/postfix-v4/defaults/main.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
mail_hostname: vm.nixnet.jke
|
||||
canonical_name: vm.nixnet.example.tld
|
||||
relay_host: email-smtp.eu-west-1.amazonaws.com
|
||||
relay_port: 465
|
||||
relay_user:
|
||||
relay_password:
|
||||
|
14
roles/postfix-v4/files/aliases
Normal file
14
roles/postfix-v4/files/aliases
Normal file
@@ -0,0 +1,14 @@
|
||||
postmaster: root
|
||||
nobody: root
|
||||
hostmaster: root
|
||||
usenet: root
|
||||
news: root
|
||||
webmaster: root
|
||||
www: root
|
||||
ftp: root
|
||||
abuse: root
|
||||
noc: root
|
||||
security: root
|
||||
root: jake
|
||||
jake: vm-mail@cyberinfo.se
|
||||
|
18
roles/postfix-v4/handlers/main.yml
Normal file
18
roles/postfix-v4/handlers/main.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
- name: Activate and restart Postfix
|
||||
service:
|
||||
name: postfix
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
||||
- name: Generate SASL
|
||||
command:
|
||||
cmd: /usr/sbin/postmap /etc/postfix/sasl_passwd
|
||||
|
||||
- name: Generate aliases
|
||||
command:
|
||||
cmd: /usr/sbin/postalias /etc/aliases
|
||||
|
||||
- name: Generate sender_canonical
|
||||
command:
|
||||
cmd: /usr/sbin/postmap /etc/postfix/sender_canonical
|
||||
|
3
roles/postfix-v4/meta/main.yml
Normal file
3
roles/postfix-v4/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
- role: update_cache
|
||||
|
6
roles/postfix-v4/tasks/configure-postfix.yml
Normal file
6
roles/postfix-v4/tasks/configure-postfix.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
- name: Configure Postfix
|
||||
template:
|
||||
src: main.cf.j2
|
||||
dest: /etc/postfix/main.cf
|
||||
notify: Activate and restart Postfix
|
||||
|
6
roles/postfix-v4/tasks/copy-aliases.yml
Normal file
6
roles/postfix-v4/tasks/copy-aliases.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
- name: Copy alisases
|
||||
copy:
|
||||
src: aliases
|
||||
dest: /etc/aliases
|
||||
notify: Generate aliases
|
||||
|
7
roles/postfix-v4/tasks/copy-postfix-auth.yml
Normal file
7
roles/postfix-v4/tasks/copy-postfix-auth.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
- name: Copy Postfix authentication
|
||||
template:
|
||||
src: sasl_passwd.j2
|
||||
dest: /etc/postfix/sasl_passwd
|
||||
mode: 0600
|
||||
notify: Generate SASL
|
||||
|
6
roles/postfix-v4/tasks/copy-sender-canonical.yml
Normal file
6
roles/postfix-v4/tasks/copy-sender-canonical.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
- name: Copy sender_canonical
|
||||
template:
|
||||
src: sender_canonical.j2
|
||||
dest: /etc/postfix/sender_canonical
|
||||
notify: Generate sender_canonical
|
||||
|
9
roles/postfix-v4/tasks/install-postfix.yml
Normal file
9
roles/postfix-v4/tasks/install-postfix.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
- name: Install Postfix and s-nail
|
||||
package:
|
||||
state: present
|
||||
name: "{{ item }}"
|
||||
with_items:
|
||||
- postfix
|
||||
- s-nail
|
||||
notify: Activate and restart Postfix
|
||||
|
15
roles/postfix-v4/tasks/main.yml
Normal file
15
roles/postfix-v4/tasks/main.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
- name: Check that a username and password is supplied
|
||||
assert:
|
||||
that:
|
||||
- (relay_user is defined) and (relay_user is not none)
|
||||
- (relay_password is defined) and
|
||||
(relay_password is not none)
|
||||
fail_msg: "'relay_user' and 'relay_password' must be set"
|
||||
success_msg: "username and password for relay is set"
|
||||
|
||||
- import_tasks: install-postfix.yml
|
||||
- import_tasks: configure-postfix.yml
|
||||
- import_tasks: copy-postfix-auth.yml
|
||||
- import_tasks: copy-aliases.yml
|
||||
- import_tasks: copy-sender-canonical.yml
|
||||
|
29
roles/postfix-v4/templates/main.cf.j2
Normal file
29
roles/postfix-v4/templates/main.cf.j2
Normal file
@@ -0,0 +1,29 @@
|
||||
biff = no
|
||||
append_dot_mydomain = no
|
||||
compatibility_level = 2
|
||||
myhostname = {{ mail_hostname }}
|
||||
alias_maps = hash:/etc/aliases
|
||||
alias_database = hash:/etc/aliases
|
||||
myorigin = {{ mail_hostname }}
|
||||
mydestination = $myhostname, {{ mail_hostname }}, localhost
|
||||
relayhost = [{{ relay_host }}]:{{ relay_port }}
|
||||
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
|
||||
mailbox_size_limit = 0
|
||||
recipient_delimiter = +
|
||||
inet_interfaces = localhost
|
||||
inet_protocols = all
|
||||
|
||||
# enable SASL authentication
|
||||
smtp_sasl_auth_enable = yes
|
||||
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
|
||||
smtp_sasl_security_options = noanonymous
|
||||
smtp_sasl_tls_security_options = noanonymous
|
||||
|
||||
# Enable STARTTLS encryption
|
||||
smtp_use_tls = yes
|
||||
smtp_tls_wrappermode = yes
|
||||
smtp_tls_security_level = encrypt
|
||||
|
||||
# Setup sender canonical mapping
|
||||
sender_canonical_maps = hash:/etc/postfix/sender_canonical
|
||||
|
2
roles/postfix-v4/templates/sasl_passwd.j2
Normal file
2
roles/postfix-v4/templates/sasl_passwd.j2
Normal file
@@ -0,0 +1,2 @@
|
||||
[{{ relay_host }}]:{{ relay_port }} {{ relay_user }}:{{ relay_password }}
|
||||
|
3
roles/postfix-v4/templates/sender_canonical.j2
Normal file
3
roles/postfix-v4/templates/sender_canonical.j2
Normal file
@@ -0,0 +1,3 @@
|
||||
root root@{{ canonical_name }}
|
||||
jake jake@{{ canonical_name }}
|
||||
|
Reference in New Issue
Block a user