---

- name: Install postfix
  yum:
    name:
      - postfix
      - cyrus-sasl-plain
  when: ansible_os_family == 'RedHat'

- name: Install postfix
  apt:
    name:
      - postfix
      - libsasl2-modules
  when: ansible_os_family == 'Debian'

- name: Deploy configuration
  template: src=main.cf.j2 dest=/etc/postfix/main.cf mode=644 owner=root group=root
  notify: restart postfix

- name: Deploy Relay authentication map
  template: src=relay_auth.j2 dest=/etc/postfix/relay_auth mode=600 owner=root group=root
  notify: rehash relay_auth

- name: Handle postfix port
  iptables_raw:
    name: postfix_ports
    state: "{{ (postfix_src_ip is defined and postfix_src_ip | length > 0 and postfix_networking) | ternary('present','absent') }}"
    rules: "-A INPUT -m state --state NEW -p tcp -m multiport --dports {{ postfix_ports | default(['25']) | join(',') }} -s {{ postfix_src_ip | join(',') }} -j ACCEPT"
  when: iptables_manage | default(True)

- name: start and enable the service
  service: name=postfix state=started enabled=yes

...