forked from Netz39_Admin/netz39-infra-ansible
Add users role from ffmd-backend
This commit is contained in:
parent
28a372eaa2
commit
07081437fd
1 changed files with 40 additions and 0 deletions
40
roles/users/tasks/main.yml
Normal file
40
roles/users/tasks/main.yml
Normal file
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
|
||||
- name: Ensure sudo is installed
|
||||
package:
|
||||
name:
|
||||
- sudo
|
||||
state: present
|
||||
|
||||
- name: Configure group sudo for sudoers without password
|
||||
lineinfile:
|
||||
path: /etc/sudoers
|
||||
state: present
|
||||
regexp: '^%sudo\s'
|
||||
line: '%sudo ALL=(ALL) NOPASSWD: ALL'
|
||||
validate: /usr/sbin/visudo -cf %s
|
||||
|
||||
- name: Add users | create users' shell and home dir
|
||||
user:
|
||||
name: "{{ item.logname }}"
|
||||
shell: /bin/bash
|
||||
createhome: yes
|
||||
comment: "{{ item.viewname }}"
|
||||
with_items: "{{ users }}"
|
||||
|
||||
- name: Add authorized keys for user
|
||||
authorized_key:
|
||||
user: "{{ item.0.logname }}"
|
||||
key: "{{ item.1 }}"
|
||||
state: present
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- ssh_pub
|
||||
|
||||
- name: Place user in sudo group
|
||||
user:
|
||||
name: "{{ item.logname }}"
|
||||
groups: sudo
|
||||
append: yes
|
||||
when: item.sudo == true
|
||||
with_items: "{{ users }}"
|
Loading…
Reference in a new issue