2022-12-18 23:43:40 +01:00
|
|
|
---
|
2022-12-04 15:14:43 +01:00
|
|
|
- name: "configure mailname"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./mailname.j2"
|
|
|
|
dest: "/etc/mailname"
|
|
|
|
mode: 0644
|
2022-12-08 23:19:54 +01:00
|
|
|
register: system_mail_mailname
|
2022-12-04 15:14:43 +01:00
|
|
|
|
|
|
|
- name: "configure mailutils"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./mailutils.conf.j2"
|
|
|
|
dest: "/etc/mailutils.conf"
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: "install postfix"
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name:
|
|
|
|
- "postfix"
|
|
|
|
- "ca-certificates"
|
|
|
|
- "libsasl2-modules"
|
|
|
|
|
|
|
|
- name: "configure aliases"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./aliases.j2"
|
|
|
|
dest: "/etc/aliases"
|
|
|
|
mode: 0644
|
2022-12-08 23:19:54 +01:00
|
|
|
register: system_mail_aliases
|
2022-12-04 15:14:43 +01:00
|
|
|
|
|
|
|
- name: "update aliases"
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "newaliases"
|
|
|
|
when:
|
2022-12-08 23:19:54 +01:00
|
|
|
system_mail_aliases.changed
|
2022-12-04 15:14:43 +01:00
|
|
|
|
|
|
|
- name: "configure postfix"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./postfix/main.cf.j2"
|
|
|
|
dest: "/etc/postfix/main.cf"
|
|
|
|
mode: 0644
|
2022-12-08 23:19:54 +01:00
|
|
|
register: system_mail_postfix_conf
|
2022-12-04 15:14:43 +01:00
|
|
|
|
|
|
|
- name: "configure credentials"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./postfix/sasl_passwd.j2"
|
|
|
|
dest: "/etc/postfix/sasl_passwd"
|
|
|
|
mode: 0600
|
2022-12-08 23:19:54 +01:00
|
|
|
register: system_mail_postfix_credentials
|
2022-12-04 15:14:43 +01:00
|
|
|
|
|
|
|
- name: "create hash database"
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "postmap /etc/postfix/sasl_passwd"
|
|
|
|
when:
|
2022-12-08 23:19:54 +01:00
|
|
|
system_mail_postfix_credentials.changed
|
2022-12-04 15:14:43 +01:00
|
|
|
|
|
|
|
- name: "set hash database permissions"
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "/etc/postfix/sasl_passwd.db"
|
|
|
|
mode: 0600
|
|
|
|
|
|
|
|
- name: "enable postfix"
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "postfix"
|
|
|
|
enabled: true
|
|
|
|
|
|
|
|
- name: "start postfix"
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "postfix"
|
|
|
|
state: "started"
|
2022-12-08 23:19:54 +01:00
|
|
|
register: system_mail_postfix_start
|
2022-12-04 15:14:43 +01:00
|
|
|
|
|
|
|
- name: "restart postfix"
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "postfix"
|
|
|
|
state: "restarted"
|
|
|
|
when:
|
2022-12-08 23:19:54 +01:00
|
|
|
(system_mail_mailname.changed or
|
|
|
|
system_mail_aliases.changed or
|
|
|
|
system_mail_postfix_conf.changed or
|
|
|
|
system_mail_postfix_credentials.changed) and
|
|
|
|
not system_mail_postfix_start.changed
|