forked from liontechacademy/ansible-playbook-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
07-users.ymal
33 lines (33 loc) · 912 Bytes
/
07-users.ymal
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
- hosts: dev
become: yes
remote_user: colins
# vars:
# ansible_ssh_private_key_file: "/home/devopsmasterjan2023/.ssh/ansible"
tasks:
- name: Create Systems admin User
user:
name: desmond
create_home: true
shell: /bin/bash
comment: "desmond Management Account"
expires: -1
password: "{{ 'DevOps@2020' | password_hash('sha512','A512') }}"
- name: Setup Sudo Access for Devops User
copy:
dest: /etc/sudoers.d/desmond
content: 'desmond ALL=(ALL) NOPASSWD: ALL'
validate: /usr/sbin/visudo -cf %s
- name: Disable Password Authentication
lineinfile:
dest=/etc/ssh/sshd_config
regexp='^PasswordAuthentication'
line="PasswordAuthentication yes"
state=present
backup=yes
notify:
- restart ssh
handlers:
- name: restart ssh
service:
name=sshd
state=restarted