Restart postfix service via systemd

The mta-sts service already uses Restart=on-failure
This commit is contained in:
phil 2023-11-03 21:37:22 +01:00
parent 53f2925435
commit ec695da167
6 changed files with 17 additions and 37 deletions

View file

@ -1,9 +0,0 @@
# Managed by Ansible
check process mta-sts-daemon
matching "/usr/bin/python3 /usr/bin/mta-sts-daemon"
group mailserver
start program = "/usr/sbin/service postfix-mta-sts-resolver start"
stop program = "/usr/sbin/service postfix-mta-sts-resolver stop"
if 2 restarts within 3 cycles then timeout
if failed host 127.0.0.1 port 8461 for 3 cycles then restart

View file

@ -1,7 +0,0 @@
# Managed by Ansible
check process postfix with pidfile /var/spool/postfix/pid/master.pid
group mailserver
start program = "/usr/sbin/service postfix@- start"
stop program = "/usr/sbin/service postfix@- stop"
if failed port 25 protocol smtp with timeout 15 seconds for 3 cycles then restart

View file

@ -0,0 +1,4 @@
# Ansible managed
[Service]
Restart=always

View file

@ -4,6 +4,10 @@
name: rsyslog name: rsyslog
state: restarted state: restarted
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true
- name: reload postfix - name: reload postfix
ansible.builtin.service: ansible.builtin.service:
name: postfix name: postfix
@ -14,11 +18,6 @@
name: postfix name: postfix
state: restarted state: restarted
- name: reload monit
ansible.builtin.service:
name: monit
state: reloaded
- name: Get certificate - name: Get certificate
command: dehydrated --cron -g command: dehydrated --cron -g
delegate_to: "{{ gateway_host }}" delegate_to: "{{ gateway_host }}"

View file

@ -1,20 +1,4 @@
--- ---
- name: "Monitoring | Enable Monit monitoring for Postfix"
ansible.builtin.copy:
src: monit/postfix
dest: /etc/monit/conf-enabled/postfix
mode: "0644"
notify: reload monit
when: "'monit' in ansible_facts.packages"
- name: "Monitoring | Enable Monit Monitoring for MTA-STS"
ansible.builtin.copy:
src: monit/mta-sts-daemon
dest: /etc/monit/conf-enabled/mta-sts-daemon
mode: "0644"
notify: reload monit
when: "'monit' in ansible_facts.packages and postfix_type == 'internet'"
- name: "Monitoring | Setup cron job for pflogsum" - name: "Monitoring | Setup cron job for pflogsum"
ansible.builtin.cron: ansible.builtin.cron:
name: "Daily pflogsum statistics" name: "Daily pflogsum statistics"

View file

@ -79,3 +79,12 @@
path: "{{ postfix_dhparam_file }}" path: "{{ postfix_dhparam_file }}"
size: 4096 size: 4096
when: postfix_type == "internet" when: postfix_type == "internet"
- name: "Postfix | Copy systemd override"
ansible.builtin.copy:
src: systemd/override.conf
dest: /etc/systemd/postfix@-.service.d/override.conf
mode: "0644"
notify:
- Reload systemd
- restart postfix