-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup_User.yaml
35 lines (29 loc) · 1.02 KB
/
Setup_User.yaml
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
---
- name: Initial User setup on dev machine. Ensure 2 user exist, and both are no password sudo
hosts: all
become: yes
tasks:
# Nothing should create file with sudo or wheel group.
# So no need to make my account part of sudo if I just grant it everything
# - name: Make sure dev user is created
# user:
# name: "{{ dev_user }}"
# # group: "{{ dev_user }}"
# append: yes
# groups: "sudo"
# create_home: yes
- name: Ensure sudoer file is set to also load sudoer.d
lineinfile:
path: /etc/sudoers
state: present
# Newer version of sudo will come with @includedir , the # is more backward compatible.
line: "#includedir /etc/sudoers.d"
validate: "/usr/sbin/visudo -cf %s"
- name: Add dev user to sudo
lineinfile:
path: /etc/sudoers.d/{{ dev_user }}
line: "{{ dev_user }} ALL=(ALL) NOPASSWD: ALL"
state: present
mode: 0640
create: yes
validate: 'visudo -cf %s'