blob: f32893aed6ddfac47300de15e77f269f1c5d8de4 (
plain)
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
69
70
71
72
73
74
75
76
|
---
- name: Apt upgrade, update
ansible.builtin.apt:
update_cache: true
upgrade: "dist"
- name: Set a hostname specifying strategy
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
use: systemd
- name: Install dependencies
ansible.builtin.apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- systemd-timesyncd
- systemd-resolved
- vim
- git
- rsync
state: latest
update_cache: true
notify:
- Enable systemd-timesyncd
## DNS
- name: Configure systemd-resolved
ansible.builtin.include_tasks:
file: "systemd-resolved.yml"
## SSH
- name: Copy sshd_config
ansible.builtin.copy:
src: files/sshd_config
dest: /etc/ssh/sshd_config
owner: root
group: root
mode: u=rw,g=r,o=r
notify:
- Restart sshd
- name: Copy authorized keys
ansible.builtin.copy:
src: files/authorized_keys
dest: /root/.ssh/authorized_keys
owner: root
group: root
## FAIL2BAN
- name: Install Fail2Ban
ansible.builtin.apt:
name: fail2ban
state: present
notify:
- Enable fail2ban
## FIREWALL
- name: Install ufw
ansible.builtin.apt:
name: ufw
state: present
- name: Allow ssh from rfc1918 networks
loop: "{{ rfc1918_networks }}"
community.general.ufw:
rule: allow
name: "OpenSSH"
from: "{{ item }}"
state: "enabled"
notify:
- Reload ufw
|