-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuser.yml
43 lines (37 loc) · 994 Bytes
/
user.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
---
- hosts: server
become: true
vars:
admins:
- sven
- lars
tasks:
- name: install epel
package:
name: epel-release
when: ansible_os_family == "RedHat"
- name: install base tools
package:
name:
- vim
- zsh
- htop
- iotop
- name: create admin users
user:
name: '{{ item }}'
groups: '{% if ansible_os_family == "RedHat"%}wheel{% else %}sudo{% endif %}'
append: true
loop: '{{ admins }}'
- name: set up admin authorized keys
authorized_key:
user: '{{ item }}'
state: present
key: "{{ lookup('file', 'pub-keys/{{ item }}.pub') }}"
loop: '{{ admins }}'
- name: allow to sudo without a password
copy:
dest: /etc/sudoers.d/password-less-sudo
mode: 0600
content: '%{% if ansible_os_family == "RedHat"%}wheel{% else %}sudo{% endif %} ALL=(ALL) NOPASSWD: ALL'
force: yes