ansible-edda/playbooks/roles/system/mail/tasks/main.yml

80 lines
1.8 KiB
YAML
Raw Normal View History

- 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
- 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
- name: "update aliases"
ansible.builtin.command:
cmd: "newaliases"
when:
2022-12-08 23:19:54 +01:00
system_mail_aliases.changed
- 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
- 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
- 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
- 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
- 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