From 074ee7f1f1e01af7fa9fef81d19dc2f2f525b905 Mon Sep 17 00:00:00 2001 From: rubenb Date: Mon, 16 Oct 2023 13:48:20 +0200 Subject: [PATCH] exim changes --- .../base-config-debian-os/defaults/main.yaml | 14 +++ .../base-config-debian-os/handlers/main.yaml | 7 +- .../base-config-debian-os/tasks/main.yaml | 89 +++++++++++++------ .../base-config-debian-os/vars/main.yaml | 3 + 4 files changed, 85 insertions(+), 28 deletions(-) create mode 100644 linux/base-config-debian/roles/base-config-debian-os/defaults/main.yaml diff --git a/linux/base-config-debian/roles/base-config-debian-os/defaults/main.yaml b/linux/base-config-debian/roles/base-config-debian-os/defaults/main.yaml new file mode 100644 index 0000000..1df9485 --- /dev/null +++ b/linux/base-config-debian/roles/base-config-debian-os/defaults/main.yaml @@ -0,0 +1,14 @@ +--- +exim_dc_eximconfig_configtype: satellite +dc_other_hostnames: "{{ ansible_nodename }}" +dc_local_interfaces: 127.0.0.1 +dc_readhost: "{{ ansible_nodename }}" +dc_relay_domains: "" +dc_minimaldns: false +dc_relay_nets: "" +dc_smarthost: smtp.verdnatura.es +CFILEMODE: 644 +dc_use_split_config: false +dc_hide_mailname: true +dc_mailname_in_oh: true +dc_localdelivery: mail_spool \ No newline at end of file diff --git a/linux/base-config-debian/roles/base-config-debian-os/handlers/main.yaml b/linux/base-config-debian/roles/base-config-debian-os/handlers/main.yaml index 1652709..86ff873 100644 --- a/linux/base-config-debian/roles/base-config-debian-os/handlers/main.yaml +++ b/linux/base-config-debian/roles/base-config-debian-os/handlers/main.yaml @@ -1,5 +1,6 @@ -# apply reconfig and restart exim4 service to apply changes -- name: apply reconfig +--- +# restart exim4 service to apply changes +- name: restart exim4 service: - name: exim4 + name: "{{ exim_daemon }}" state: restarted diff --git a/linux/base-config-debian/roles/base-config-debian-os/tasks/main.yaml b/linux/base-config-debian/roles/base-config-debian-os/tasks/main.yaml index 88ced3a..df825bd 100644 --- a/linux/base-config-debian/roles/base-config-debian-os/tasks/main.yaml +++ b/linux/base-config-debian/roles/base-config-debian-os/tasks/main.yaml @@ -52,33 +52,72 @@ # Reconfigure relayhost smtp to smtp.verdnatura.es - name: reconfigure relayhost to smtp.verdnatura.es - debconf: - name: exim4-config - question: "{{ item.name }}" - value: "{{ item.value }}" - vtype: string - loop: - - name: exim4/dc_smarthost - value: smtp.verdnatura.es - - name: exim4/dc_local_interfaces - value: "" - - name: exim4/dc_minimaldns - value: 'false' - - name: exim4/dc_readhost - value: "{{ ansible_nodename }}" # var to define survey(encuesta) - - name: exim4/dc_other_hostnames - value: "" - - name: exim4/dc_eximconfig_configtype - value: "mail sent by smarthost; no local mail" - - name: exim4/mailname - value: "{{ ansible_nodename }}" # var to define survey(encuesta) - - name: exim4/use_split_config - value: 'false' + lineinfile: + dest: "{{ exim_configuration_file }}" + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" + state: present + mode: 0644 + with_items: + - regexp: '^dc_eximconfig_configtype' + line: "dc_eximconfig_configtype='{{ exim_dc_eximconfig_configtype }}'" + - regexp: '^dc_other_hostnames' + line: "dc_other_hostnames='{{ dc_other_hostnames }}'" + - regexp: '^dc_local_interfaces' + line: "dc_local_interfaces='{{ dc_local_interfaces }}'" + - regexp: '^dc_readhost' + line: "dc_readhost='{{ dc_readhost }}'" + - regexp: '^dc_relay_domains' + line: "dc_relay_domains='{{ dc_relay_domains }}'" + - regexp: '^dc_minimaldns' + line: "dc_minimaldns='{{ dc_minimaldns }}'" + - regexp: '^dc_relay_nets' + line: "dc_relay_nets='{{ dc_relay_nets }}'" + - regexp: '^dc_smarthost' + line: "dc_smarthost='{{ dc_smarthost }}'" + - regexp: '^CFILEMODE' + line: "CFILEMODE='{{ CFILEMODE }}'" + - regexp: '^dc_use_split_config' + line: "dc_use_split_config='{{ dc_use_split_config }}'" + - regexp: '^dc_hide_mailname' + line: "dc_hide_mailname='{{ dc_hide_mailname }}'" + - regexp: '^dc_mailname_in_oh' + line: "dc_mailname_in_oh='{{ dc_mailname_in_oh }}'" + - regexp: '^dc_localdelivery' + line: "dc_localdelivery='{{ dc_localdelivery }}'" + notify: restart exim4 +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# DONT WORK :( +#- name: reconfigure relayhost to smtp.verdnatura.es +# debconf: +# name: exim4-config +# question: "{{ item.name }}" +# value: "{{ item.value }}" +# vtype: string +# loop: +# - name: exim4/dc_smarthost +# value: smtp.verdnatura.es +# - name: exim4/dc_local_interfaces +# value: "" +# - name: exim4/dc_minimaldns +# value: 'false' +# - name: exim4/dc_readhost +# value: "{{ ansible_nodename }}" # var to define survey(encuesta) +# - name: exim4/dc_other_hostnames +# value: "" +# - name: exim4/dc_eximconfig_configtype +# value: "mail sent by smarthost; no local mail" +# - name: exim4/mailname +# value: "{{ ansible_nodename }}" # var to define survey(encuesta) +# - name: exim4/use_split_config +# value: 'false' +# # generate master config -- name: generate master config - command: update-exim4.conf - notify: apply reconfig +#- name: generate master config +# command: update-exim4.conf +# notify: apply reconfig +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Send mail to verify relay-host #- name: sending mail to verify exim4 config works diff --git a/linux/base-config-debian/roles/base-config-debian-os/vars/main.yaml b/linux/base-config-debian/roles/base-config-debian-os/vars/main.yaml index e69de29..a2499d3 100644 --- a/linux/base-config-debian/roles/base-config-debian-os/vars/main.yaml +++ b/linux/base-config-debian/roles/base-config-debian-os/vars/main.yaml @@ -0,0 +1,3 @@ +--- +exim_configuration_file: /etc/exim4/update-exim4.conf.conf +exim_daemon: exim4 \ No newline at end of file