# Load distro-specific variables
- include_vars: "{{ ansible_distribution | lower }}.yml"
  tags: always

- block:
  - include_tasks: copy_certificates.yml

  - block:
    - include_tasks: install_postfix.yml
    - include_tasks: configure_postfix.yml
    when: 
      - postfix is defined
      - postfix == true

  - block:
    - include_tasks: install_dovecot.yml
    - include_tasks: configure_dovecot.yml
    when:
      - dovecot is defined
      - dovecot == true

  - block:
    - include_tasks: install_fetchmail.yml
    - include_tasks: configure_fetchmail.yml
    when:
      - fetchmail is defined
      - fetchmail == true

  rescue:
    - set_fact: task_failed=true