infra/roles/postfix/tasks/postfix.yml

65 lines
1.1 KiB
YAML

---
- name: install packages
apt:
name:
- postfix
- mailutils
- libsasl2-modules
state: latest
update_cache: yes
when: not skip_apt|default(false)|bool
notify:
- restart postfix
tags:
- packages
- name: set /etc/mailname
copy:
content: "{{ item }}"
dest: /etc/mailname
with_items:
- "{{ inventory_hostname }}"
tags:
- hostname
- name: template config
template:
src: "{{ item }}.j2"
dest: "/etc/postfix/{{ item }}"
owner: root
group: root
mode: 0644
notify:
- restart postfix
with_items:
- main.cf
- master.cf
- name: cleanup files
file:
path: "/etc/postfix/{{ item }}"
state: absent
with_items:
- canonical
- canonical.db
- sasl
- sasl_passwd
- sasl_passwd.db
- name: template aliases
template:
src: aliases.j2
dest: /etc/aliases
notify: newaliases
- name: template postfix restart cron job
template:
src: restart_postfix-cron.j2
dest: /etc/cron.d/restart_postfix
owner: root
group: root
mode: 0600
tags:
- cron
- cron-postfix