ansible-roles/evolinux-base/tasks/postfix.yml
Jérémy Lecour bc8858fc0a evolinux-base: improve hostname configuration
We can have a "real" hostname and domain, but also an "internal" hostnae 
and domain, used mostly for internal tools.
2018-08-16 16:17:34 +02:00

100 lines
2 KiB
YAML

---
- name: Postfix packages are installed
apt:
name: "{{ item }}"
state: present
with_items:
- postfix
- mailgraph
when: evolinux_postfix_packages
tags:
- packages
- postfix
- name: configure postfix myhostname
lineinfile:
dest: /etc/postfix/main.cf
state: present
line: "myhostname = {{ evolinux_fqdn }}"
regexp: '^myhostname'
notify: reload postfix
tags:
- postfix
- name: configure postfix mynetworks
lineinfile:
dest: /etc/postfix/main.cf
state: present
line: "mydestination = {{ [evolinux_fqdn, evolinux_internal_fqdn] | unique | join(' ') }} localhost.localdomain localhost"
regexp: '^mydestination'
notify: reload postfix
tags:
- postfix
- name: fetch users list
shell: getent passwd | cut -d":" -f 1 | grep -v root
check_mode: no
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
when: evolinux_postfix_users_alias_root
tags:
- postfix
- name: additional users address aliased to root
lineinfile:
dest: /etc/aliases
regexp: "^{{ item }}:.*"
line: "{{ item }}: root"
with_items:
- postmaster
- abuse
- mailer-daemon
- delay
- error
- bounce
notify: newaliases
when: evolinux_postfix_mailer_alias_root
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
when: evolinux_postfix_root_alias
tags:
- postfix
- meta: flush_handlers
- name: exim4 is absent
apt:
name: "{{ item }}"
purge: yes
state: absent
with_items:
- exim4
- exim4-base
- exim4-config
- exim4-daemon-light
when: evolinux_postfix_purge_exim
tags:
- packages
- postfix
- meta: flush_handlers