forked from sandervanvugt/handson-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_users.yml
38 lines (37 loc) · 916 Bytes
/
setup_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
---
- name: create some users
hosts: file
vars_files:
- vars/users
- vars/groups
tasks:
- name: add groups
group:
name: "{{ item.groupname }}"
loop: "{{ usergroups }}"
- name: add users
user:
name: "{{ item.username }}"
groups: "{{ item.groups }}"
loop: "{{ users }}"
- name: add SSH public keys
authorized_key:
user: "{{ item.username }}"
key: "{{ lookup('file', 'files/'+ item.username + '/id_rsa.pub') }}"
loop: "{{ users }}"
- name: add sales group members to sudo
copy:
content: "%sales ALL=(ALL) NOPASSWD: ALL"
dest: /etc/sudoers.d/sales
mode: 0440
- name: disable root SSH login
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^PermitRootLogin"
line: "PermitRootLogin no"
notify: restart sshd
handlers:
- name: restart sshd
service:
name: sshd
state: restarted