infra/roles/exim/tasks/main.yml

85 lines
2.1 KiB
YAML

---
- name: Install exim4 packages
apt:
name: exim4-daemon-light
state: present
cache_valid_time: 86400
- name: Exim macros
copy:
dest: /etc/exim4/conf.d/main/000_mdk_macros
owner: root
group: root
mode: 0644
content: |
REMOTE_SMTP_SMARTHOST_HOSTS_REQUIRE_TLS = *
REMOTE_SMTP_SMARTHOST_PROTOCOL = smtps
# MAIN_LOG_SELECTOR = +all
notify: restart exim4
- name: Exim wild rewrite
copy:
dest: /etc/exim4/conf.d/rewrite/99_mdk_rewrite
owner: root
group: root
mode: 0644
content: |
*@+local_domains "${lookup{${local_part}}wildlsearch{/etc/email-addresses}\
{$value}fail}" Ffrs
*@ETC_MAILNAME "${lookup{${local_part}}wildlsearch{/etc/email-addresses}\
{$value}fail}" Ffrs
notify: restart exim4
- name: Exim email addresses
copy:
dest: /etc/email-addresses
owner: root
group: root
mode: 0644
content: |
*: {{ smtp_username }}
notify: restart exim4
- name: Exim smarthost password
copy:
dest: /etc/exim4/passwd.client
owner: root
group: Debian-exim
mode: 0640
content: |
{{ smtp_host }}:{{ smtp_username }}:{{ smtp_password }}
notify: restart exim4
- name: Exim smarthost config
copy:
dest: /etc/exim4/update-exim4.conf.conf
owner: root
group: root
mode: 0644
content: |
dc_eximconfig_configtype='smarthost'
dc_other_hostnames='{{ inventory_hostname_short }}'
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='{{ smtp_host }}::{{ smtp_port }}'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'
register: update_exim4_conf_conf
- name: Exim generate config
when: update_exim4_conf_conf is changed
command: update-exim4.conf
notify: restart exim4
- name: Alias for root
lineinfile:
path: /etc/aliases
line: "root: {{ alias_for_root }}"