diff --git a/README.md b/README.md index b72f72a..7f8d54d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,20 @@ # ansible_role_exim4 -Ansible role to configure exim4 that it will send mail via external smtp server. (smarthost) +Ansible role to configure exim4. +By default you can tell exim4 that it will send mail via smarthost. -This role is a work in proggress! +To do this you have at leaset set the smarthost FQDN in the variable: ``exim4__dc_smarthost:``. + + Example Playbook: +---------------- +``` +- name: run exim4 role + hosts: localhost + roles: + - {role: dansible_role_exim, tags: exim4} + vars: + exim4__dc_smarthost: mx01.example.com +``` Testing ---------- diff --git a/defaults/main.yml b/defaults/main.yml index 016ddec..84eb67e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,22 @@ --- exim4__state: present +# please set the smarthost you wnt to use to send mails +exim4__dc_smarthost: "{{sansible_fqdn }}" + +# you can adjust the other exim4 settings, if you want +exim4__dc_eximconfig_configtype: 'satellite' +exim4__dc_other_hostnames: "{{ hostname }}" +exim4__dc_local_interfaces: '127.0.0.1 ; ::1' +exim4__dc_readhost: "{{ hostname }}" +exim4__dc_relay_domains: '' +exim4__dc_minimaldns: false +exim4__dc_relay_nets: '' +exim4__CFILEMODE: '644' +exim4__dc_use_split_config: 'false' +exim4__dc_hide_mailname: 'true' +exim4__dc_mailname_in_oh: 'true' +exim4__dc_localdelivery: 'mail_spool' + # should we do a version check? (recomended) submodules_versioncheck: false diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..da547b8 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: systemctl restart exim4 + become: true + ansible.builtin.systemd: + name: "{{ exim4__daemon }}" + state: restarted diff --git a/tasks/configuration.yml b/tasks/configuration.yml new file mode 100644 index 0000000..c8c6224 --- /dev/null +++ b/tasks/configuration.yml @@ -0,0 +1,10 @@ +--- +- name: Configure exim4 (Debian) + become: true + ansible.builtin.template: + src: 'templates/exim4.conf.j2' + dest: "{{ exim4__configuration_file }}" + mode: 0644 + owner: root + group: root + notify: systemctl restart exim4 diff --git a/tasks/main.yml b/tasks/main.yml index 61bd596..a4cd32a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,3 +15,12 @@ - name: exim4 installation ansible.builtin.include_tasks: installation.yml + +- name: exim4 configuration + ansible.builtin.include_tasks: configuration.yml + +- name: systemctl start exim4 + become: true + ansible.builtin.systemd: + name: "{{ exim4__daemon }}" + state: started diff --git a/templates/exim4.conf.j2 b/templates/exim4.conf.j2 new file mode 100644 index 0000000..5adb289 --- /dev/null +++ b/templates/exim4.conf.j2 @@ -0,0 +1,16 @@ +# exim4 config file +# {{ ansible_managed }} +# {{ exim4__configuration_file }} +dc_eximconfig_configtype='{{ exim4__dc_eximconfig_configtype }}' +dc_other_hostnames='{{ exim4__dc_other_hostnames }}' +dc_local_interfaces='{{ exim4__dc_local_interfaces }}' +dc_readhost='{{ exim4__dc_readhost }}' +dc_relay_domains='{{ exim4__dc_relay_domains }}' +dc_minimaldns='{{ exim4__dc_minimaldns|ternary('true', 'false') }}' +dc_relay_nets='{{ exim4__dc_relay_nets }}' +dc_smarthost='{{ exim4__dc_smarthost }}' +CFILEMODE='{{ exim4__CFILEMODE }}' +dc_use_split_config='{{ exim4__dc_use_split_config|ternary('true', 'false') }}' +dc_hide_mailname='{{ exim4__dc_hide_mailname|ternary('true', 'false') }}' +dc_mailname_in_oh='{{ exim4__dc_mailname_in_oh|ternary('true', 'false') }}' +dc_localdelivery='{{ exim4__dc_localdelivery }}'