Importing exim4 role to better personalize it.

This commit is contained in:
Julien Palard 2022-01-30 10:38:39 +01:00
parent 4843d59bbb
commit ebc25d7bbd
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
10 changed files with 154 additions and 0 deletions

21
roles/exim4/LICENSE.txt Executable file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Tobias Schifftner, ambimax® GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,18 @@
---
exim4_sendonly_fqdn: '{{ ansible_fqdn }}'
exim4_sendonly_enable_tls: true
exim4_sendonly_smarthost: ''
exim4_sendonly_username: ''
exim4_sendonly_password: ''
exim4_sendonly_email_addresses: []
# root: 'your@email.com'
exim4_sendonly_email_aliases: []
# - regexp: '^root:'
# line: 'root: your@email.com'
exim4_sendonly_apt_packages:
- exim4-daemon-light
- mailutils

View File

@ -0,0 +1,6 @@
---
- name: restart exim4
service:
name: 'exim4'
state: restarted
enabled: yes

View File

@ -0,0 +1,42 @@
---
- name: Configure exim4
notify: restart exim4
template:
src: 'update-exim4.conf.conf'
dest: /etc/exim4/update-exim4.conf.conf
- name: Update mailname
notify: restart exim4
copy:
content: '{{ exim4_sendonly_fqdn }}'
dest: '/etc/mailname'
- name: Define email aliases
notify: restart exim4
lineinfile:
dest: /etc/aliases
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items: '{{ exim4_sendonly_email_aliases }}'
when: exim4_sendonly_email_aliases|length
- name: Define email addresses
notify: restart exim4
template:
src: 'email-addresses.j2'
dest: '/etc/email-addresses'
when: exim4_sendonly_email_addresses|length
- name: Set auth for relay host
notify: restart exim4
template:
src: 'passwd.client'
dest: '/etc/exim4/passwd.client'
- name: Enable TLS
notify: restart exim4
template:
src: 'exim4.conf.localmacros'
dest: '/etc/exim4/exim4.conf.localmacros'
when: exim4_sendonly_enable_tls

View File

@ -0,0 +1,6 @@
---
- name: Install exim4 packages
apt:
name: '{{ exim4_sendonly_apt_packages }}'
state: present
cache_valid_time: 86400

17
roles/exim4/tasks/main.yml Executable file
View File

@ -0,0 +1,17 @@
---
- name: Install exim4
include: install.yml
tags: ['exim4-sendonly-install']
- name: Configure exim4
include: configure.yml
tags: ['exim4-sendonly-configure']
- name: Start exim4
service:
name: exim4
state: started
enabled: true
changed_when: false
tags: ['always']

View File

@ -0,0 +1,3 @@
{% for user, email in exim4_sendonly_email_addresses.items() %}
{{ user }}: {{ email }}
{% endfor %}

View File

@ -0,0 +1 @@
MAIN_TLS_ENABLE = 1

View File

@ -0,0 +1,10 @@
# password file used when the local exim is authenticating to a remote
# host as a client.
#
# see exim4_passwd_client(5) for more documentation
#
# Example:
### target.mail.server.example:login:password
{% if exim4_sendonly_username != '' %}
*:{{ exim4_sendonly_username }}:{{ exim4_sendonly_password }}
{% endif %}

View File

@ -0,0 +1,30 @@
# /etc/exim4/update-exim4.conf.conf
#
# Edit this file and /etc/mailname by hand and execute update-exim4.conf
# yourself or use 'dpkg-reconfigure exim4-config'
#
# Please note that this is _not_ a dpkg-conffile and that automatic changes
# to this file might happen. The code handling this will honor your local
# changes, so this is usually fine, but will break local schemes that mess
# around with multiple versions of the file.
#
# update-exim4.conf uses this file to determine variable values to generate
# exim configuration macros for the configuration file.
#
# Most settings found in here do have corresponding questions in the
# Debconf configuration, but not all of them.
#
# This is a Debian specific file
dc_eximconfig_configtype="{{ 'internet' if exim4_sendonly_smarthost == '' else 'satellite' }}"
dc_other_hostnames='{{ ansible_hostname }}; localhost.localdomain; localhost'
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='{{ exim4_sendonly_smarthost }}'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'