-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigurenode.yml
69 lines (59 loc) · 1.6 KB
/
configurenode.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
- hosts: all
become: true
vars_files:
- ./group_vars/vars.yml
tasks:
- name: Install aptitude
apt:
name: aptitude
state: latest
update_cache: true
- name: Setup passwordless sudo
lineinfile:
path: /etc/sudoers
state: present
regexp: '^%sudo'
line: '%sudo ALL=(ALL) NOPASSWD: ALL'
validate: '/usr/sbin/visudo -cf %s'
- name: Create a new regular user with sudo privileges
user:
name: "{{ work_user }}"
state: present
groups: sudo
append: true
create_home: true
- name: Remove MOTD Ubuntu News
ansible.builtin.lineinfile:
path: /etc/default/motd-news
regexp: "^ENABLED"
line: "ENABLED=0"
- name: Set authorized key for remote user
ansible.posix.authorized_key:
user: "{{ work_user }}"
state: present
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
- name: Disable password authentication for root
lineinfile:
path: /etc/ssh/sshd_config
state: present
regexp: '^#?PermitRootLogin'
line: 'PermitRootLogin no'
- name: Update apt and install required system packages
apt:
pkg:
- bat
- curl
- vim
- git
- ufw
state: latest
update_cache: true
- name: UFW - Allow SSH connections
community.general.ufw:
rule: allow
name: OpenSSH
- name: UFW - Enable and deny by default
community.general.ufw:
state: enabled
default: deny