From e6f243b079259ec541bde9168f9788a7a04d7fe4 Mon Sep 17 00:00:00 2001 From: Jason Rothstein Date: Sun, 10 Apr 2022 17:40:27 -0500 Subject: [PATCH] Single account file with email address as the username --- README.md | 1 + templates/Fedora/35/etc/dovecot/accounts | 5 +++++ templates/Fedora/35/etc/dovecot/local.conf | 2 +- vars/Fedora-35-default.yml | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 templates/Fedora/35/etc/dovecot/accounts diff --git a/README.md b/README.md index ba1ddde..6a43abc 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Role Variables | - | - | - | | dovecot_vhost | inventory_hostname | What mod_md certificate should be used for Dovecot | | dovecot_quota | 1G | Default mail quota for users of the system | +| dovecot_users | undefined | list of dictionary with the elements of email address and password (converted to CRYPT-SHA512) | Dependencies ------------ diff --git a/templates/Fedora/35/etc/dovecot/accounts b/templates/Fedora/35/etc/dovecot/accounts new file mode 100644 index 0000000..9a35d50 --- /dev/null +++ b/templates/Fedora/35/etc/dovecot/accounts @@ -0,0 +1,5 @@ +{% if defined dovecot_users and dovecot_users is iterable %} +{% foreach user in dovecot_users %} +{{ user.email }}:{{ user.password | password_hash('sha512') }}:::::: +{% endfor %} +{% %} diff --git a/templates/Fedora/35/etc/dovecot/local.conf b/templates/Fedora/35/etc/dovecot/local.conf index c7098c2..6fc17f8 100644 --- a/templates/Fedora/35/etc/dovecot/local.conf +++ b/templates/Fedora/35/etc/dovecot/local.conf @@ -14,7 +14,7 @@ mail_home = /var/spool/mail/%d/%u passdb { driver = passwd-file - args = username_format=%n scheme=SHA512-CRYPT /etc/dovecot/accounts/%d/etc/passwd + args = username_format=%n scheme=SHA512-CRYPT /etc/dovecot/accounts } userdb { driver = static diff --git a/vars/Fedora-35-default.yml b/vars/Fedora-35-default.yml index 4bd1a6e..a047005 100644 --- a/vars/Fedora-35-default.yml +++ b/vars/Fedora-35-default.yml @@ -87,6 +87,11 @@ template_list: src: '{{ ansible_distribution }}/{{ ansible_distribution_major_version }}/etc/dovecot/dovecot.conf' - dest: '/etc/dovecot/local.conf' src: '{{ ansible_distribution }}/{{ ansible_distribution_major_version }}/etc/dovecot/local.conf' + - dest: '/etc/dovecot/accounts' + group: 'dovecot' + mode: '0600' + owner: 'dovecot' + src: '{{ ansible_distribution }}/{{ ansible_distribution_major_version }}/etc/dovecot/accounts' - dest: '/usr/lib/systemd/system/dovecot-copytls.service' src: '{{ ansible_distribution }}/{{ ansible_distribution_major_version }}/usr/lib/systemd/system/dovecot-copytls.service' - dest: '/usr/lib/systemd/system/dovecot-copytls.timer'