diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d843efe..61843e07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ The **patch** part changes incrementally at each release. * lxc: remove useless loop in apt execution * lxc: update our default template to be compatible with Debian 10 * lxc-php: refactor tasks for better maintainability +* lxc-php: Use OpenSMTPD for Stretch/Buster containers, and ssmtp for Jessie containers * lxc-solr: changed default Solr version to 8.4.1 * minifirewall: better alert5 activation * minifirewall: no http filtering by default diff --git a/lxc-php/tasks/mail_opensmtpd.yml b/lxc-php/tasks/mail_opensmtpd.yml new file mode 100644 index 00000000..5ed07082 --- /dev/null +++ b/lxc-php/tasks/mail_opensmtpd.yml @@ -0,0 +1,8 @@ +--- + +- name: Configure opensmtpd (in the container) + template: + src: smtpd.conf.j2 + dest: "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/smtpd.conf" + mode: "0644" + notify: "Restart opensmtpd" diff --git a/lxc-php/tasks/mail_ssmtp.yml b/lxc-php/tasks/mail_ssmtp.yml new file mode 100644 index 00000000..9e0465b7 --- /dev/null +++ b/lxc-php/tasks/mail_ssmtp.yml @@ -0,0 +1,7 @@ +--- + +- name: Configure ssmtp (in the container) + template: + src: ssmtp.conf.j2 + dest: "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/ssmtp/ssmtp.conf" + mode: "0644" diff --git a/lxc-php/tasks/misc.yml b/lxc-php/tasks/misc.yml index cfa78db0..96cd365d 100644 --- a/lxc-php/tasks/misc.yml +++ b/lxc-php/tasks/misc.yml @@ -1,26 +1,19 @@ --- -- name: Configure opensmtpd - template: - src: smtpd.conf.j2 - dest: "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/smtpd.conf" - mode: "0644" - notify: "Restart opensmtpd" - -- name: Copy using inline content - copy: - content: "{{ evolinux_hostname }}.{{ evolinux_domain }}\n" - dest: "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/mailname" - notify: "Restart opensmtpd" - -- name: Configure timezone +- name: Configure timezone for the container copy: remote_src: yes src: "/etc/timezone" dest: "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/timezone" -- name: Ensure containers root directory is 755 +- name: Ensure container's root directory is 755 file: path: "/var/lib/lxc/{{ lxc_php_version }}/rootfs" state: directory mode: '0755' + +- name: Configure mailname for the container + copy: + content: "{{ evolinux_hostname }}.{{ evolinux_domain }}\n" + dest: "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/mailname" + notify: "Restart opensmtpd" diff --git a/lxc-php/tasks/php56.yml b/lxc-php/tasks/php56.yml index 369495df..06220acf 100644 --- a/lxc-php/tasks/php56.yml +++ b/lxc-php/tasks/php56.yml @@ -16,3 +16,5 @@ - "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/php5/cli/conf.d/z-evolinux-defaults.ini" loop_control: loop_var: line_item + +- include: "mail_ssmtp.yml" diff --git a/lxc-php/tasks/php70.yml b/lxc-php/tasks/php70.yml index 932758f2..e049cf0c 100644 --- a/lxc-php/tasks/php70.yml +++ b/lxc-php/tasks/php70.yml @@ -16,3 +16,5 @@ - "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/php/7.0/cli/conf.d/z-evolinux-defaults.ini" loop_control: loop_var: line_item + +- include: "mail_opensmtd.yml" diff --git a/lxc-php/tasks/php73.yml b/lxc-php/tasks/php73.yml index ac6a9fea..b50460f3 100644 --- a/lxc-php/tasks/php73.yml +++ b/lxc-php/tasks/php73.yml @@ -16,3 +16,5 @@ - "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/php/7.3/cli/conf.d/z-evolinux-defaults.ini" loop_control: loop_var: line_item + +- include: "mail_opensmtd.yml" diff --git a/lxc-php/templates/ssmtp.conf.j2 b/lxc-php/templates/ssmtp.conf.j2 new file mode 100644 index 00000000..dafba814 --- /dev/null +++ b/lxc-php/templates/ssmtp.conf.j2 @@ -0,0 +1,21 @@ +# +# Config file for sSMTP sendmail +# +# The person who gets all mail for userids < 1000 +# Make this empty to disable rewriting. +root=postmaster + +# The place where the mail goes. The actual machine name is required no +# MX records are consulted. Commonly mailhosts are named mail.domain.com +mailhub=127.0.0.1 + +# Where will the mail seem to come from? +#rewriteDomain= + +# The full hostname +hostname={{ ansible_fqdn }} + +# Are users allowed to set their own From: address? +# YES - Allow the user to specify their own From: address +# NO - Use the system generated From: address +FromLineOverride=YES