2020-07-12 15:38:50 +02:00
|
|
|
---
|
|
|
|
- name: Include OS-specific variables.
|
|
|
|
include_vars: "{{ ansible_os_family }}.yml"
|
2020-08-01 20:28:22 +02:00
|
|
|
when: "'mail_server' not in group_names"
|
2020-07-12 15:38:50 +02:00
|
|
|
|
|
|
|
- name: Ensure postfix is installed.
|
|
|
|
package:
|
|
|
|
name: postfix
|
|
|
|
state: present
|
2020-08-01 20:28:22 +02:00
|
|
|
when: "'mail_server' not in group_names"
|
2020-07-12 15:38:50 +02:00
|
|
|
|
|
|
|
- name: Update mail aliases.
|
|
|
|
lineinfile:
|
|
|
|
dest: "{{ aliases_config_file }}"
|
|
|
|
line: "root: {{ alias_email }}"
|
|
|
|
regexp: "^root:"
|
2020-08-01 20:28:22 +02:00
|
|
|
when: alias_email != "root" and 'mail_server' not in group_names
|
2020-07-12 15:38:50 +02:00
|
|
|
notify: update aliases
|
|
|
|
|
|
|
|
- name: Update Postfix configuration.
|
|
|
|
lineinfile:
|
|
|
|
dest: "{{ postfix_config_file }}"
|
|
|
|
line: "{{ item.name }} = {{ item.value }}"
|
|
|
|
regexp: "^{{ item.name }} ="
|
|
|
|
with_items:
|
|
|
|
- name: inet_interfaces
|
|
|
|
value: "{{ postfix_inet_interfaces }}"
|
|
|
|
- name: inet_protocols
|
|
|
|
value: "{{ postfix_inet_protocols }}"
|
2020-07-22 11:33:26 +02:00
|
|
|
- name: myhostname
|
|
|
|
value: "{{ inventory_hostname }}"
|
2020-08-01 20:28:22 +02:00
|
|
|
when: "'mail_server' not in group_names"
|
2020-07-12 15:38:50 +02:00
|
|
|
notify: restart postfix
|
|
|
|
|
|
|
|
- name: Ensure postfix is started and enabled at boot.
|
|
|
|
service:
|
|
|
|
name: postfix
|
|
|
|
enabled: "{{ postfix_service_enabled }}"
|
2020-08-01 20:28:22 +02:00
|
|
|
when: "'mail_server' not in group_names"
|
2020-07-12 15:38:50 +02:00
|
|
|
notify: restart postfix
|