84 lines
1.6 KiB
YAML
84 lines
1.6 KiB
YAML
---
|
|
|
|
- name: packages are installed
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: present
|
|
with_items:
|
|
- postfix
|
|
- mailgraph
|
|
tags:
|
|
- packages
|
|
- postfix
|
|
|
|
- name: main.cf is configured
|
|
lineinfile:
|
|
dest: /etc/postfix/main.cf
|
|
regexp: "^#? *{{ item.key }} *="
|
|
line: "{{ item.key }} = {{ item.value }}"
|
|
with_items:
|
|
- { key: "myorigin", value: "/etc/mailname" }
|
|
- { key: "disable_vrfy_command", value: "yes" }
|
|
notify: reload postfix
|
|
tags:
|
|
- postfix
|
|
|
|
- name: fetch users list
|
|
shell: getent passwd | cut -d":" -f 1 | grep -v root
|
|
register: non_root_users_list
|
|
changed_when: False
|
|
tags:
|
|
- postfix
|
|
|
|
- name: each user is aliased to root
|
|
lineinfile:
|
|
dest: /etc/aliases
|
|
regexp: "^{{ item }}:.*"
|
|
line: "{{ item }}: root"
|
|
with_items: "{{ non_root_users_list.stdout_lines }}"
|
|
notify: newaliases
|
|
tags:
|
|
- postfix
|
|
|
|
- name: additional users address aliased to root
|
|
lineinfile:
|
|
dest: /etc/aliases
|
|
regexp: "^{{ item }}:.*"
|
|
line: "{{ item }}: root"
|
|
with_items:
|
|
- postmaster
|
|
- abuse
|
|
- mailer-daemon
|
|
notify: newaliases
|
|
tags:
|
|
- postfix
|
|
|
|
- name: root alias is configured
|
|
lineinfile:
|
|
dest: /etc/aliases
|
|
regexp: "^root:"
|
|
line: "root: {{ postfix_alias_email or general_alert_email | mandatory }}"
|
|
notify: newaliases
|
|
tags:
|
|
- postfix
|
|
|
|
- name: exim4 is absent
|
|
apt:
|
|
name: "{{ item }}"
|
|
purge: yes
|
|
state: absent
|
|
with_items:
|
|
- exim4
|
|
- exim4-base
|
|
- exim4-config
|
|
- exim4-daemon-light
|
|
when: postfix_remove_exim
|
|
tags:
|
|
- packages
|
|
- postfix
|
|
|
|
- include: slow_transports.yml
|
|
when: postfix_slow_transports_enabled
|
|
tags:
|
|
- postfix
|