diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-04-12 18:11:07 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-04-12 18:11:07 +0300 |
commit | 5df713fefd62a8ef392944a39f35c4324a73b910 (patch) | |
tree | 7509f6e2cc208ee59fdf7687dce0e2d813df40db /roles/unix_users/tasks/main.yml | |
parent | 39e48621be51ac5a7173860c1985b40c74780279 (diff) | |
download | debian-ansible-5df713fefd62a8ef392944a39f35c4324a73b910.tar.gz |
Add a role to create Unix system users
Including setting authorized_keys, and passwordless sudo access.
Diffstat (limited to 'roles/unix_users/tasks/main.yml')
-rw-r--r-- | roles/unix_users/tasks/main.yml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/roles/unix_users/tasks/main.yml b/roles/unix_users/tasks/main.yml new file mode 100644 index 0000000..ad9095f --- /dev/null +++ b/roles/unix_users/tasks/main.yml @@ -0,0 +1,23 @@ +- name: create system users + with_items: "{{ unix_users }}" + user: + name: "{{ item.username }}" + comment: "{{ item.comment|default('unnamed user') }}" + shell: "{{ item.shell|default('/bin/bash') }}" + system: "{{ item.system|default('no') }}" + +- name: add keys to authorized_keys + with_items: "{{ unix_users }}" + authorized_key: + user: "{{ item.username }}" + key: "{{ lookup('file', authkeys_dir + '/' + item.username) }}" + +- name: give sudo access + with_items: "{{ unix_users }}" + when: "{{ item.sudo|default(False) }}" + copy: + content: "{{ item.username }} ALL=(ALL:ALL) NOPASSWD: ALL" + dest: "/etc/sudoers.d/{{ item.username }}" + owner: root + group: root + mode: 0600 |