diff options
-rw-r--r-- | host_vars/vultr | 5 | ||||
-rw-r--r-- | roles/mail/tasks/main.yml | 12 |
2 files changed, 11 insertions, 6 deletions
diff --git a/host_vars/vultr b/host_vars/vultr index 9bf758c..7d83385 100644 --- a/host_vars/vultr +++ b/host_vars/vultr @@ -58,6 +58,11 @@ mail: domains: - liwt.net - aaronly.me + # Virtual mail user for local delivery (e.g., by Dovecot)) + user: + name: vmail + id: 5000 + home: /home/vmail dkim: selector: default bits: 2048 diff --git a/roles/mail/tasks/main.yml b/roles/mail/tasks/main.yml index 8bf6ff3..8191c0d 100644 --- a/roles/mail/tasks/main.yml +++ b/roles/mail/tasks/main.yml @@ -10,19 +10,19 @@ - dovecot-pigeonhole - name: group - check vmail group - command: pw groupshow vmail + command: pw groupshow {{ mail.user.name }} register: pw_cmd ignore_errors: true changed_when: false tags: vmail - name: group - create vmail group - command: pw groupadd vmail -g 5000 + command: pw groupadd {{ mail.user.name }} -g {{ mail.user.id }} when: pw_cmd.rc != 0 tags: vmail - name: user - check vmail user - command: pw usershow vmail + command: pw usershow {{ mail.user.name }} register: pw_cmd ignore_errors: true changed_when: false @@ -30,9 +30,9 @@ - name: user - create vmail user command: > - pw useradd vmail - -u 5000 -g vmail - -m -M 0700 -d "/home/vmail" + pw useradd {{ mail.user.name }} + -u {{ mail.user.id }} -g {{ mail.user.name }} + -m -M 0700 -d {{ mail.user.home }} -s /sbin/nologin -c "Virtual Mail User" when: pw_cmd.rc != 0 |