51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
---
|
|
- 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" and 'mail_server' not in group_names
|
|
notify: update aliases
|
|
|
|
- name: Update mailname file.
|
|
copy:
|
|
dest: "/etc/mailname"
|
|
content: "{{ inventory_hostname }}\n"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
when: ansible_distribution == 'Debian' and 'mail_server' not in group_names
|
|
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 }}"
|
|
- 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
|