---

# role to installs postfix mainserver on "our" systems.

# required vars in data/hosts/...
#   postfix_smtp_relay_host
#   postfix_smtp_hostname
#   postfix_smtp_mailname

- name: install postfix
  tags: postfix
  become: true
  ansible.builtin.package:
    name: postfix
    state: present

- name: configure postfix
  tags: postfix
  become: true
  ansible.builtin.template:
    src: main.cf.j2
    dest: /etc/postfix/main.cf
  notify: reload postfix.service

# This is a dependecy from pypyroutinecheck
- name: create mailname file
  tags: postfix
  become: true
  ansible.builtin.copy:
    content: "{{ postfix_smtp_mailname }}"
    dest: /etc/mailname
  notify: reload postfix.service

- name: remove exim4 from debian minimal installation
  tags: postfix
  become: true
  ansible.builtin.package:
    name:
      - exim4
      - exim4-base
      - exim4-config
      - exim4-daemon-light
    state: absent

