aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-03-05 19:57:25 +0800
committerAaron LI <aly@aaronly.me>2018-03-14 11:35:08 +0800
commitfb9e90d84ab1eb50c6f0702316a67bcad6db8524 (patch)
tree84492a7f195626a07ac566de343b957c7ae5150e
parentd9b877957c52789e494aeee1ffd4d3128dd9e597 (diff)
downloadansible-dfly-vps-fb9e90d84ab1eb50c6f0702316a67bcad6db8524.tar.bz2
vars: add "mail.user" for the virtual mail user info
-rw-r--r--host_vars/vultr5
-rw-r--r--roles/mail/tasks/main.yml12
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