-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.yml
31 lines (28 loc) · 831 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
---
- name: Create groups and users on linux server
hosts: all
gather_facts: no
vars:
myuser: "nrathi"
mypassword: "password@123"
mygroup: "sysadmins"
tasks:
- name: Add group "{{ mygroup }}" to remote server
group:
name: "{{ mygroup }}"
gid: 2010
state: present
- name: Allow the bob user to run any commands as alice with sudo -u alice
community.general.sudoers:
name: "{{mygroup}}-sudoers"
state: present
group: "{{ mygroup }}"
commands: ALL
- name: Add user "{{ myuser }}" to remote server with sudo access
user:
name: "{{ myuser }}"
comment: "Privileged User"
uid: 2001
group: "{{ mygroup }}"
shell: /bin/bash
password: "{{ mypassword | password_hash('sha512') }}"