- name: Install postfix packages
  apt: pkg={{ item }} install_recommends=no state=installed update_cache=yes
  with_items:
    - postfix
    - ca-certificates
  when: with_postfix

- name: Install mail aliases file
  template: src=aliases.j2 dest=/etc/aliases owner=root group=root mode=0644
  notify:
    - Regenerate aliases cache
  when: with_postfix or with_mail_aliases

- name: Install postfix main configuration
  template: src=postfix/main.cf.j2 dest=/etc/postfix/main.cf owner=root group=root mode=0644
  notify:
    - Restart postfix
  when: with_postfix