summaryrefslogtreecommitdiff
path: root/roles/unix_users/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/unix_users/tasks/main.yml')
-rw-r--r--roles/unix_users/tasks/main.yml21
1 files changed, 13 insertions, 8 deletions
diff --git a/roles/unix_users/tasks/main.yml b/roles/unix_users/tasks/main.yml
index 00c49fd..e181054 100644
--- a/roles/unix_users/tasks/main.yml
+++ b/roles/unix_users/tasks/main.yml
@@ -1,3 +1,8 @@
+- name: "check unix_users_version"
+ shell: |
+ [ "{{ unix_users_version }}" = "2" ] || \
+ (echo "Unexpected version {{ unix_users_version }}" 1>&2; exit 1)
+
- name: create system users
with_items: "{{ unix_users }}"
user:
@@ -5,6 +10,13 @@
comment: "{{ item.comment|default('unnamed user') }}"
shell: "{{ item.shell|default('/bin/bash') }}"
system: "{{ item.system|default('no') }}"
+
+- name: add users to additional groups
+ with_items: "{{ unix_users }}"
+ when: item.groups is defined
+ user:
+ name: "{{ item.username }}"
+ groups: "{{ item.groups }}"
- name: set password for users
with_items: "{{ unix_users }}"
@@ -43,14 +55,7 @@
group: "{{ item.username }}"
mode: 0600
-- name: add keys to authorized_keys (deprecated way)
- with_items: "{{ unix_users }}"
- when: authkeys_dir != None
- authorized_key:
- user: "{{ item.username }}"
- key: "{{ lookup('file', authkeys_dir + '/' + item.username) }}"
-
-- name: add keys to authorized_keys (new way)
+- name: add keys to authorized_keys
with_items: "{{ unix_users }}"
when: item.authorized_keys is defined
authorized_key: