From 37486a58240a5a6b3730b05b27267d0268fc3846 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Thu, 13 Oct 2022 15:37:22 +0300 Subject: [PATCH] Add dbmail users management --- tasks/configure_dbmail_users.yml | 16 ++++++++++++++++ tasks/main.yml | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tasks/configure_dbmail_users.yml diff --git a/tasks/configure_dbmail_users.yml b/tasks/configure_dbmail_users.yml new file mode 100644 index 0000000..3858e61 --- /dev/null +++ b/tasks/configure_dbmail_users.yml @@ -0,0 +1,16 @@ +--- +- name: Ensure user accounts are present + shell: "dbmail-users -a {{ item.username }}" + loop: "{{ dbmail_users }}" + +- name: Set user accounts password + shell: "dbmail-users -c {{ item.username }} -w {{ item.password}} -p {{ item.password_type | default('sha512') }}" + loop: "{{ dbmail_users }}" + +- name: Link user accounts with emails + shell: "dbmail-users -c {{ item.username }} -s {{ item.email }}" + loop: "{{ dbmail_users }}" + +- name: Set user accounts quota + shell: "dbmail-users -c {{ item.username }} -m {{ item.quota }}" + loop: "{{ dbmail_users }}" \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index d8dcd8f..e579561 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,4 +17,7 @@ - name: Ensure certificates are configured include_tasks: configure_certificates.yml - when: dbmail_configuration['POP']['tls_port'] > 0 or dbmail_configuration['IMAP']['tls_port'] > 0 or dbmail_configuration['SIEVE']['tls_port'] > 0 \ No newline at end of file + when: dbmail_configuration['POP']['tls_port'] > 0 or dbmail_configuration['IMAP']['tls_port'] > 0 or dbmail_configuration['SIEVE']['tls_port'] > 0 + +- name: Ensure user's are configured in dbmail + include_tasks: configure_dbmail_users.yml \ No newline at end of file