-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathusers.yml
51 lines (51 loc) · 1.23 KB
/
users.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
- hosts: docs-2020
become: yes
gather_facts: no
vars:
ansible_python_interpreter: '/usr/bin/python'
users:
- name: znz
github_user: znz
- name: hsbt
github_user: hsbt
- name: okkez
github_user: okkez
- name: shugo
github_user: shugo
- name: sorah
github_user: sorah
tasks:
- name: 'Add user'
user:
name: '{{ item.name }}'
create_home: yes
shell: '/bin/bash'
groups: 'sudo'
append: yes
loop: '{{ users }}'
- name: 'Create .ssh'
file:
path: '/home/{{ item.name }}/.ssh'
state: directory
mode: '0755'
owner: '{{ item.name }}'
group: '{{ item.name }}'
loop: '{{ users }}'
- name: 'Download ssh public keys'
get_url:
url: 'https://github.com/{{ item.github_user }}.keys'
dest: '/home/{{ item.name }}/.ssh/authorized_keys'
mode: '0644'
owner: '{{ item.name }}'
group: '{{ item.name }}'
loop: '{{ users }}'
- name: 'Allow passwordless sudo'
lineinfile:
dest: /etc/sudoers.d/local-users
create: yes
state: present
regexp: '^{{ item.name }} '
line: '{{ item.name }} ALL=(ALL) NOPASSWD:ALL'
validate: 'visudo -cf %s'
loop: '{{ users }}'