-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.yaml
154 lines (134 loc) · 4.62 KB
/
setup.yaml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---
- name: Setup citizen alpha
hosts: all
tasks:
- name: Update apt cache
apt:
update_cache: true
cache_valid_time: 7200
- name: Set timezone to Europe/Berlin
community.general.timezone:
name: Europe/Berlin
- name: Start and enable systemd-timesyncd
ansible.builtin.service:
name: systemd-timesyncd
enabled: true
state: started
- name: Add floating IP config
register: floating_ip_result
ansible.builtin.copy:
dest: /etc/network/interfaces.d/zz_citizenalpha
content: |
auto eth0:1
iface eth0:1 inet static
address 116.203.8.219
netmask 32
auto eth0:1
iface eth0:1 inet6 static
address 2a01:4f8:1c0c:813d::1
netmask 128
- name: Restart networking
when: floating_ip_result is changed
ansible.builtin.service:
name: networking
state: restarted
- name: Set root password
ansible.builtin.user:
name: root
password: $6$w/TX/ep8p7M1L16/$hbvDFKHBHkszVMKklFrq/YoahGu10XOS.crjeyhMped4mhOAmDz9d7wc.RYujl8DDOmcgt9xVqYoNn8qmVuks1 # yamllint disable-line
- name: Create custom sudo rule for user flokoe
ansible.builtin.copy:
content: "flokoe ALL=(ALL) NOPASSWD: ALL"
dest: /etc/sudoers.d/flokoe
mode: 0640
validate: visudo -cf %s
- name: Create user flokoe
ansible.builtin.user:
name: flokoe
password: "!"
shell: /usr/bin/bash
- name: Add ssh key to authorized_keys
ansible.posix.authorized_key:
user: flokoe
state: present
exclusive: true
key: "{{ lookup('file', 'files/flokoe.pub') }}"
- name: Install packages
ansible.builtin.apt:
state: present
update_cache: true
name:
- vim
- ca-certificates
- apt-transport-https
- python3-gi
- unattended-upgrades
- netavark
- aardvark-dns
- podman
- jq
- swaks
- libnet-ssleay-perl
- catatonit
- name: Enable auto upgrades
ansible.builtin.copy:
mode: 0640
dest: /etc/apt/apt.conf.d/20auto-upgrades
content: |
APT::Periodic::Enable "1";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "21";
- name: Configure unattended-upgrades
ansible.builtin.copy:
mode: 0640
dest: /etc/apt/apt.conf.d/50unattended-upgrades
backup: true
content: |
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
Unattended-Upgrade::MinimalSteps "true";
Unattended-Upgrade::InstallOnShutdown "true";
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Remove-New-Unused-Dependencies "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:17";
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename},label=Debian";
"origin=Debian,codename=${distro_codename},label=Debian-Security";
"origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
};
Unattended-Upgrade::Package-Blacklist {
};
- name: Hardening sshd
register: sshd_result
ignore_errors: true
ansible.builtin.copy:
mode: 0640
dest: /etc/ssh/sshd_config.d/zz_citizenalpha.conf
# yamllint disable rule:line-length
content: |
HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_rsa_key
KexAlgorithms [email protected],curve25519-sha256,[email protected],diffie-hellman-group-exchange-sha256
KbdInteractiveAuthentication no
MaxAuthTries 3
PasswordAuthentication no
PermitRootLogin no
X11Forwarding no
# yamllint enable
- name: Reload sshd
when: sshd_result is changed
ansible.builtin.service:
name: ssh
state: reloaded
- name: Create data dir for apps
ansible.builtin.file:
path: /data
state: directory
- name: Create data dir for apps
ansible.builtin.file:
path: /var/www
state: directory