From 1bd98dd13c46570bc164095cf5ffb50ede07056d Mon Sep 17 00:00:00 2001 From: Nemo Date: Sat, 1 Aug 2020 20:28:22 +0200 Subject: [PATCH] Disable client mail task when the server is a mail server --- roles/postfix/tasks/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/roles/postfix/tasks/main.yml b/roles/postfix/tasks/main.yml index 35395fa..6b5e91d 100644 --- a/roles/postfix/tasks/main.yml +++ b/roles/postfix/tasks/main.yml @@ -1,18 +1,20 @@ --- - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" + when: "'mail_server' not in group_names" - name: Ensure postfix is installed. package: name: postfix state: present + when: "'mail_server' not in group_names" - name: Update mail aliases. lineinfile: dest: "{{ aliases_config_file }}" line: "root: {{ alias_email }}" regexp: "^root:" - when: alias_email != "root" + when: alias_email != "root" and 'mail_server' not in group_names notify: update aliases - name: Update Postfix configuration. @@ -27,10 +29,12 @@ value: "{{ postfix_inet_protocols }}" - name: myhostname value: "{{ inventory_hostname }}" + when: "'mail_server' not in group_names" notify: restart postfix - name: Ensure postfix is started and enabled at boot. service: name: postfix enabled: "{{ postfix_service_enabled }}" + when: "'mail_server' not in group_names" notify: restart postfix