- name: Install exim packages apt: name: exim4 state: present - name: Prepare exim configuration lineinfile: dest: /etc/exim4/update-exim4.conf.conf regexp: "{{ item.regexp }}" line: "{{ item.line }}" state: present mode: 0644 with_items: - regexp: '^dc_eximconfig_configtype' line: "dc_eximconfig_configtype='satellite'" - regexp: '^dc_other_hostnames' line: "dc_other_hostnames='{{ ansible_fqdn }}'" - regexp: '^dc_local_interfaces' line: "dc_local_interfaces='127.0.0.1'" - regexp: '^dc_readhost' line: "dc_readhost='{{ ansible_fqdn }}'" - regexp: '^dc_relay_domains' line: "dc_relay_domains=''" - regexp: '^dc_minimaldns' line: "dc_minimaldns='false'" - regexp: '^dc_relay_nets' line: "dc_relay_nets=''" - regexp: '^dc_smarthost' line: "dc_smarthost='{{ smtp_server }}'" - regexp: '^CFILEMODE' line: "CFILEMODE='644'" - regexp: '^dc_use_split_config' line: "dc_use_split_config='false'" - regexp: '^dc_hide_mailname' line: "dc_hide_mailname='true'" - regexp: '^dc_mailname_in_oh' line: "dc_mailname_in_oh='true'" - regexp: '^dc_localdelivery' line: "dc_localdelivery='mail_spool'" notify: restart-exim register: exim_config - name: Update exim configuration command: update-exim4.conf when: exim_config.changed - name: Sending mail to verify relay host configuration works shell: > echo "If you see this message, relayhost on {{ ansible_fqdn }} has been configured correctly." \ | mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ sysadmin_mail }}" when: exim_config.changed