✨: add smtp global relay
All checks were successful
ansible-lint / lint-everything (push) Successful in 1m31s
All checks were successful
ansible-lint / lint-everything (push) Successful in 1m31s
This commit is contained in:
9
inventory/host_vars/ks3370405.yml
Normal file
9
inventory/host_vars/ks3370405.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
web_hostname:
|
||||||
|
- host: mail-relay.mateu.be
|
||||||
|
|
||||||
|
allowed_smtp_ips: ["82.66.135.228", "80.67.179.200"]
|
||||||
|
|
||||||
|
global_smtp_relay_allowed_ips: "{{ allowed_smtp_ips }}"
|
||||||
|
ufw_allowed_smtp_ips: "{{ allowed_smtp_ips }}"
|
@@ -14,6 +14,8 @@ all:
|
|||||||
ansible_host: muse-HP-EliteBook-820-G2.home.arpa
|
ansible_host: muse-HP-EliteBook-820-G2.home.arpa
|
||||||
pinkypie:
|
pinkypie:
|
||||||
ansible_host: pinkypie.home.arpa
|
ansible_host: pinkypie.home.arpa
|
||||||
|
ks3370405:
|
||||||
|
ansible_host: ks3370405.kimsufi.com
|
||||||
|
|
||||||
router:
|
router:
|
||||||
hosts:
|
hosts:
|
||||||
@@ -24,6 +26,10 @@ physicalservers:
|
|||||||
frederica:
|
frederica:
|
||||||
serenor:
|
serenor:
|
||||||
|
|
||||||
|
webservers:
|
||||||
|
hosts:
|
||||||
|
ks3370405:
|
||||||
|
|
||||||
hypervisors:
|
hypervisors:
|
||||||
children:
|
children:
|
||||||
proxmox_nodes:
|
proxmox_nodes:
|
||||||
@@ -63,6 +69,7 @@ resticservers:
|
|||||||
|
|
||||||
disabled_loadbalanced_webservers:
|
disabled_loadbalanced_webservers:
|
||||||
hosts:
|
hosts:
|
||||||
|
ks3370405:
|
||||||
|
|
||||||
disabled_system:
|
disabled_system:
|
||||||
hosts:
|
hosts:
|
||||||
@@ -76,6 +83,7 @@ disabled_munin:
|
|||||||
baybay-ponay:
|
baybay-ponay:
|
||||||
muse-HP-EliteBook-820-G2:
|
muse-HP-EliteBook-820-G2:
|
||||||
pinkypie:
|
pinkypie:
|
||||||
|
ks3370405:
|
||||||
|
|
||||||
disabled_syslog:
|
disabled_syslog:
|
||||||
hosts:
|
hosts:
|
||||||
@@ -83,6 +91,7 @@ disabled_syslog:
|
|||||||
machinbox:
|
machinbox:
|
||||||
muse-HP-EliteBook-820-G2:
|
muse-HP-EliteBook-820-G2:
|
||||||
pinkypie:
|
pinkypie:
|
||||||
|
ks3370405:
|
||||||
|
|
||||||
# Those are not servers and should not be configured as such
|
# Those are not servers and should not be configured as such
|
||||||
disabled_server_conf:
|
disabled_server_conf:
|
||||||
|
7
playbooks/global_smtprelay.yml
Normal file
7
playbooks/global_smtprelay.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install & configure the global SMTP relay
|
||||||
|
hosts: ks3370405
|
||||||
|
roles:
|
||||||
|
- ufw
|
||||||
|
- global_smtp_relay
|
@@ -18,6 +18,8 @@
|
|||||||
import_playbook: firewall.yml
|
import_playbook: firewall.yml
|
||||||
- name: Run mail playbook
|
- name: Run mail playbook
|
||||||
import_playbook: mail.yml
|
import_playbook: mail.yml
|
||||||
|
- name: Run global_smtprelay playbook
|
||||||
|
import_playbook: global_smtprelay.yml
|
||||||
- name: Run xmpp playbook
|
- name: Run xmpp playbook
|
||||||
import_playbook: xmpp.yml
|
import_playbook: xmpp.yml
|
||||||
- name: Run webservers playbook
|
- name: Run webservers playbook
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Deploy smtp relay
|
- name: Deploy smtp relay
|
||||||
hosts: all:!disabled_server_conf:!machinbox:!mail
|
hosts: all:!disabled_server_conf:!machinbox:!mail:!ks3370405
|
||||||
diff: true
|
diff: true
|
||||||
roles:
|
roles:
|
||||||
- smtprelay
|
- smtprelay
|
||||||
|
6
roles/global_smtp_relay/handlers/main.yml
Normal file
6
roles/global_smtp_relay/handlers/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Restart postfix
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: postfix
|
||||||
|
state: restarted
|
||||||
|
enabled: true
|
15
roles/global_smtp_relay/tasks/main.yml
Normal file
15
roles/global_smtp_relay/tasks/main.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install postfix
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: postfix
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Put configuration
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: main.cf.j2
|
||||||
|
dest: /etc/postfix/main.cf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0o640"
|
||||||
|
notify: Restart postfix
|
29
roles/global_smtp_relay/templates/main.cf.j2
Normal file
29
roles/global_smtp_relay/templates/main.cf.j2
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
compatibility_level = 2
|
||||||
|
mail_owner = postfix
|
||||||
|
myhostname = mail-relay.mateu.be
|
||||||
|
myorigin = $myhostname
|
||||||
|
mydestination = $myhostname, localhost.$mydomain, localhost
|
||||||
|
unknown_local_recipient_reject_code = 550
|
||||||
|
mynetworks = 127.0.0.0/8, [::1]/128, 82.66.135.228, 80.67.179.200
|
||||||
|
sendmail_path = /usr/bin/sendmail
|
||||||
|
newaliases_path = /usr/bin/newaliases
|
||||||
|
mailq_path = /usr/bin/mailq
|
||||||
|
mailbox_size_limit = 104857600
|
||||||
|
message_size_limit = 104857600
|
||||||
|
inet_protocols = ipv4
|
||||||
|
## Référence de chiffrement TLS
|
||||||
|
# serveur SMTP
|
||||||
|
smtpd_tls_cert_file = /etc/x509/mail-relay.mateu.be/fullchain.cer
|
||||||
|
smtpd_tls_key_file = /etc/x509/mail-relay.mateu.be/mail-relay.mateu.be.key
|
||||||
|
smtpd_use_tls = yes
|
||||||
|
smtpd_tls_auth_only = yes
|
||||||
|
smtpd_tls_protocols = !SSLv2,!SSLv3
|
||||||
|
smtpd_tls_loglevel = 1
|
||||||
|
# client SMTP
|
||||||
|
smtp_tls_CApath = /etc/ssl/certs
|
||||||
|
smtp_tls_cert_file = /etc/x509/mail-relay.mateu.be/fullchain.cer
|
||||||
|
smtp_tls_key_file = /etc/x509/mail-relay.mateu.be/mail-relay.mateu.be.key
|
||||||
|
smtp_use_tls = yes
|
||||||
|
smtp_tls_protocols = !SSLv2,!SSLv3
|
||||||
|
smtp_tls_security_level = may
|
||||||
|
smtp_tls_loglevel = 1
|
2
roles/ufw/defaults/main.yml
Normal file
2
roles/ufw/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
ufw_allowed_smtp_ips: []
|
43
roles/ufw/tasks/main.yml
Normal file
43
roles/ufw/tasks/main.yml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install ufw
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: ufw
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Permit outgoing flows
|
||||||
|
community.general.ufw:
|
||||||
|
default: allow
|
||||||
|
direction: outgoing
|
||||||
|
|
||||||
|
- name: Deny incoming flows
|
||||||
|
community.general.ufw:
|
||||||
|
default: deny
|
||||||
|
direction: incoming
|
||||||
|
|
||||||
|
- name: Allow incoming SSH
|
||||||
|
community.general.ufw:
|
||||||
|
rule: allow
|
||||||
|
port: ssh
|
||||||
|
proto: tcp
|
||||||
|
|
||||||
|
- name: Allow incoming HTTP
|
||||||
|
community.general.ufw:
|
||||||
|
rule: allow
|
||||||
|
port: http
|
||||||
|
proto: tcp
|
||||||
|
|
||||||
|
- name: Allow incoming SMTP
|
||||||
|
community.general.ufw:
|
||||||
|
rule: allow
|
||||||
|
port: smtp
|
||||||
|
src: "{{ item }}"
|
||||||
|
loop: "{{ ufw_allowed_smtp_ips }}"
|
||||||
|
|
||||||
|
- name: Set logging
|
||||||
|
community.general.ufw:
|
||||||
|
logging: "on"
|
||||||
|
|
||||||
|
- name: Enable UFW
|
||||||
|
community.general.ufw:
|
||||||
|
state: enabled
|
Reference in New Issue
Block a user