-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuser-play.yml
34 lines (33 loc) · 865 Bytes
/
user-play.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
- hosts: all
gather_facts: no
tasks:
- name: Wait for system to become reachable
wait_for_connection:
- hosts: all
tasks:
- name: enable password-auth
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^PasswordAuthentication"
line: "PasswordAuthentication yes"
state: present
notify:
- restart sshd
- name: create user
user:
name: "{{ user }}"
group: "sudo"
#group: "admin"
shell: /bin/bash
# password: "{{ password }}"
- name: change password
shell: echo "{{ user }}:{{ password }}" | chpasswd
- name: Allow 'admin' group to have passwordless sudo
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%sudo'
line: '%sudo ALL=(ALL) NOPASSWD: ALL'
handlers:
- name: restart sshd
service: name=sshd state=restarted