Compare commits
222 Commits
08477a4962
...
master
Author | SHA1 | Date | |
---|---|---|---|
de32bdbf33 | |||
a56802c8bb | |||
c269796d99 | |||
43249b4aff | |||
cf7209506c | |||
68c91699d2 | |||
8da5bc81af | |||
fb9417908e | |||
52f7e7e153 | |||
85fb26bf52 | |||
e924d3e33c | |||
ca386aa414 | |||
5bd2bd584b | |||
dce0aefec1 | |||
6193aa097a | |||
32b2473c6c | |||
8fb0ebb6fb | |||
a769494bc7 | |||
71a205a1a4 | |||
e9a88a7494 | |||
eed480b853 | |||
95f4eae305 | |||
43b95bc129 | |||
e157e89934 | |||
fa35d4a77c | |||
2af9b58d9c | |||
42214db06e | |||
8887c47c2c | |||
ed25955111 | |||
42a6dc18e5 | |||
f23fa80a30 | |||
d3b6348480 | |||
68613a253a | |||
de361fa8b6 | |||
22c43ec52b | |||
a53b27a8fd | |||
0a7746d60c | |||
45020413f2 | |||
51ad299afd | |||
e52f901c38 | |||
d2339e5d93 | |||
519f636b1b | |||
1b79e081ef | |||
8b2c2f1047 | |||
baeb499aa1 | |||
569c4d09a2 | |||
7eafd343cb | |||
2eaa562dbf | |||
0bf5d05c25 | |||
b6a30feab9 | |||
603f906d37 | |||
77a184b054 | |||
af0f09b8b0 | |||
89c4c3baf0 | |||
490f6f9e39 | |||
bf6d01f2d2 | |||
043cab21f5 | |||
dee3cc5dc6 | |||
d0ec4c175e | |||
9b1109ca8b | |||
188175cb0b | |||
ba26e2725a | |||
3a4e849592 | |||
6800a75f86 | |||
95e3332f80 | |||
d83c801db1 | |||
9b50274e36 | |||
8795639cbb | |||
0c7aee832c | |||
4e1833bbbf | |||
3c883cdded | |||
21a7c54b96 | |||
9500cbc866 | |||
025cf6e6dd | |||
a37694f9c3 | |||
41da78f5f9 | |||
ecea6b238b | |||
41753eab2e | |||
0ec240eae5 | |||
331cb2e7b4 | |||
85e0b9f978 | |||
21f0843995 | |||
a72e23456e | |||
90f86cd7d1 | |||
1cdb3f168e | |||
8980bef64f | |||
b1650d3058 | |||
085b8dc4ce | |||
1dbc17d35f | |||
763d83323f | |||
44b25bdcfb | |||
e24b51e3da | |||
5a5155d8e2 | |||
2ccad60ea2 | |||
ae645735b5 | |||
47a651147d | |||
a63f359d6f | |||
bac7dbda24 | |||
b2ace001f7 | |||
3595d3d694 | |||
92b53d7177 | |||
1417856dd6 | |||
c8aece5513 | |||
f6a02be7b7 | |||
ecbabfe165 | |||
58d0700520 | |||
20a215737c | |||
0e8e0b4e86 | |||
590f20de67 | |||
f7ffff3b8d | |||
1a886ad9d4 | |||
752f7bb80d | |||
ecdfdd483a | |||
5e198281cb | |||
edcbafcc2e | |||
ec38eeca21 | |||
b65e387d7d | |||
85f640d49e | |||
cfe6fc0be4 | |||
03f62c876c | |||
45bcc63b43 | |||
ca1aa3dc5e | |||
b7d81dc75e | |||
ef3cf7ba63 | |||
bb24e31bea | |||
0f84c63806 | |||
4391478805 | |||
e2c74a0515 | |||
b5edfdc4ad | |||
292454450d | |||
173b96abba | |||
b0faddb9a7 | |||
e9e875d420 | |||
c9fe2f5d83 | |||
87f57020bc | |||
95cb1fdf31 | |||
df2510a74f | |||
db242db222 | |||
a1212faaec | |||
ef91be03ec | |||
b9f37b2d5b | |||
2776cfcadf | |||
69917c65e6 | |||
ab047ee852 | |||
2139bf02a2 | |||
31868f3b16 | |||
645128198e | |||
231bc6752e | |||
a3deafec54 | |||
df477801d4 | |||
8b295da3a3 | |||
beb1f6a308 | |||
22f815e00b | |||
5262e1b825 | |||
5fb55ed552 | |||
9f5b8e72f4 | |||
5c5e8578b7 | |||
0d29e1fde5 | |||
833c87cede | |||
d8acd0a697 | |||
67e0f3cc1b | |||
5d2d1be654 | |||
cfd20456ac | |||
ad4dac649e | |||
66cea8c669 | |||
f9e48a438a | |||
35503d6cbd | |||
7e71ede2e5 | |||
87dc0c17d2 | |||
6f81234410 | |||
ae0852bd6c | |||
b372b9d28d | |||
130a1b6704 | |||
e0aeabddf3 | |||
404021807b | |||
c1961307c9 | |||
eddd055380 | |||
080cbfdf91 | |||
94d50a5072 | |||
473bedc5e9 | |||
ce9cfdeef5 | |||
75d7aad012 | |||
49102eb285 | |||
fffe7adbfd | |||
e41e2b83d5 | |||
4a08e9491c | |||
c0dc56c6a1 | |||
0f8a98d7cc | |||
40d8c376b2 | |||
057bc2ee71 | |||
7260da8acd | |||
2aad89e80a | |||
ca48208928 | |||
5004338638 | |||
464c9fecb1 | |||
63ae9e9a6a | |||
e6a722704a | |||
e425c703eb | |||
adadd086b6 | |||
adc69f07d5 | |||
9a21122da6 | |||
9fde754dcb | |||
e62a35af50 | |||
ba96e12495 | |||
ec8cf56996 | |||
82b9949865 | |||
f05a32cc25 | |||
fbd5bb72ef | |||
50878bb950 | |||
9f88f210f0 | |||
c628326ac5 | |||
5cfc600b37 | |||
0407a0de22 | |||
e5920136c0 | |||
2410f56221 | |||
667ccf6ce9 | |||
c52f9be563 | |||
40aab44dec | |||
aefa493b14 | |||
2762ec51ce | |||
3b2e727510 | |||
6835593fc3 |
22
.drone.yml
Normal file
22
.drone.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: ansible
|
||||
|
||||
steps:
|
||||
- name: ansible nightly run
|
||||
image: alpinelinux/ansible
|
||||
environment:
|
||||
ANSIBLE_HOST_KEY_CHECKING: "False"
|
||||
ANSIBLE_PRIVATE_KEY_FILE: "/drone/src/id_rsa"
|
||||
ANSIBLE_CONFIG: "/drone/src/ansible.cfg"
|
||||
CLOUDFLARE_TOKEN:
|
||||
from_secret: CLOUDFLARE_TOKEN
|
||||
SSH_KEY:
|
||||
from_secret: SSH_KEY
|
||||
commands:
|
||||
- echo "$SSH_KEY" > $PWD/id_rsa
|
||||
- chmod 0600 $PWD/id_rsa
|
||||
- ansible-galaxy collection install -r requirements.yaml
|
||||
- ansible-playbook -i inventory.yaml nightly.yaml
|
||||
...
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.vault_password_file
|
||||
venv/
|
||||
venv/
|
||||
.DS_Store
|
||||
|
6
ansible.cfg
Normal file
6
ansible.cfg
Normal file
@ -0,0 +1,6 @@
|
||||
[ssh_connection]
|
||||
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
|
||||
[defaults]
|
||||
forks=10
|
||||
pipelining = True
|
||||
strategy = free
|
@ -1,8 +0,0 @@
|
||||
---
|
||||
- name: "Deploy basic webhost with Docker"
|
||||
hosts: keycloak
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- docker
|
||||
- webserver
|
8
group_vars/all.yaml
Normal file
8
group_vars/all.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_become: true
|
||||
ansible_user: ansible@intra.tormakris.dev
|
||||
#ansible_user: ansible
|
||||
allowedranges:
|
||||
- 192.168.69.0/24
|
||||
- 192.168.1.0/24
|
||||
...
|
@ -1,2 +1,4 @@
|
||||
---
|
||||
default_gateway: "192.168.69.254"
|
||||
netplan:
|
||||
default_gateway: "192.168.69.253"
|
||||
...
|
||||
|
@ -1,2 +1,4 @@
|
||||
---
|
||||
default_gateway: "192.168.69.1"
|
||||
netplan:
|
||||
default_gateway: "192.168.69.253"
|
||||
...
|
||||
|
8
host_vars/backup.yaml
Normal file
8
host_vars/backup.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: backup.intra.tormakris.dev
|
||||
servicename: mckay
|
||||
backup:
|
||||
host: oniel.tormakristof.eu
|
||||
internal: false
|
||||
basedir: /mnt/backupstore
|
||||
...
|
8
host_vars/bitwarden.yaml
Normal file
8
host_vars/bitwarden.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: bitwarden.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "bitwarden.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: false
|
||||
https: false
|
||||
...
|
8
host_vars/cloudlog.yaml
Normal file
8
host_vars/cloudlog.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: cloudlog.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "cloudlog.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: false
|
||||
https: false
|
||||
...
|
3
host_vars/drone-runner.yaml
Normal file
3
host_vars/drone-runner.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
ansible_host: drone-runner.intra.tormakris.dev
|
||||
...
|
8
host_vars/drone.yaml
Normal file
8
host_vars/drone.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: drone.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "drone.kmlabz.com"
|
||||
port: 8080
|
||||
bigrequests: false
|
||||
https: false
|
||||
...
|
20
host_vars/git.yaml
Normal file
20
host_vars/git.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
ansible_host: git.intra.tormakris.dev
|
||||
servicename: git
|
||||
backup:
|
||||
folder: "/home/service-user"
|
||||
tarfolder: "gitea docker-compose.yml"
|
||||
host: backup.intra.tormakris.dev
|
||||
internal: true
|
||||
prearecommand: ""
|
||||
basedir: /mnt/backupstore
|
||||
firewall:
|
||||
- port: "2222"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
webserver:
|
||||
- domain: "git.kmlabz.com"
|
||||
port: 8080
|
||||
bigrequests: false
|
||||
https: false
|
||||
...
|
8
host_vars/guacamole.yaml
Normal file
8
host_vars/guacamole.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: guacamole.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "guacamole.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: false
|
||||
https: false
|
||||
...
|
8
host_vars/librespeed.yaml
Normal file
8
host_vars/librespeed.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: librespeed.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "speedtest.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: true
|
||||
https: false
|
||||
...
|
16
host_vars/matrix.yaml
Normal file
16
host_vars/matrix.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
ansible_host: matrix.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "matrix.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: true
|
||||
https: false
|
||||
- domain: "chat.tormakristof.eu"
|
||||
port: 8181
|
||||
bigrequests: true
|
||||
https: false
|
||||
firewall:
|
||||
- port: "9000"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
...
|
8
host_vars/monitoring.yaml
Normal file
8
host_vars/monitoring.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: monitoring.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "grafana.tormakristof.eu"
|
||||
port: 8181
|
||||
bigrequests: false
|
||||
https: false
|
||||
...
|
28
host_vars/neko.yaml
Normal file
28
host_vars/neko.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
---
|
||||
ansible_host: zelenka.intra.tormakris.dev
|
||||
firewall:
|
||||
- port: "ssh"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
- port: "http"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
- port: "https"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
- port: "59000:59009"
|
||||
proto: udp
|
||||
interface: "eth0"
|
||||
- port: "3478"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
- port: "3478"
|
||||
proto: any
|
||||
interface: "eth0"
|
||||
- port: "5349"
|
||||
proto: any
|
||||
interface: "eth0"
|
||||
- port: "9101"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
...
|
8
host_vars/nextcloud.yaml
Normal file
8
host_vars/nextcloud.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: nextcloud.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "nextcloud.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: true
|
||||
https: false
|
||||
...
|
12
host_vars/nexus.yaml
Normal file
12
host_vars/nexus.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
ansible_host: nexus.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "nexus.kmlabz.com"
|
||||
port: 8080
|
||||
bigrequests: true
|
||||
https: false
|
||||
- domain: "registry.kmlabz.com"
|
||||
port: 4269
|
||||
bigrequests: true
|
||||
https: false
|
||||
...
|
24
host_vars/openvpn.yaml
Normal file
24
host_vars/openvpn.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
ansible_host: openvpn.intra.tormakris.dev
|
||||
firewall:
|
||||
- port: "1194"
|
||||
proto: udp
|
||||
interface: "eth0"
|
||||
- port: "1194"
|
||||
proto: udp
|
||||
interface: "eth1"
|
||||
netplan:
|
||||
default_gateway: ""
|
||||
additionalinterfaces:
|
||||
- name: "eth1"
|
||||
dhcp4: false
|
||||
dhcp6: false
|
||||
addresses:
|
||||
- "2001:738:2001:207f:0:211:211:23/64"
|
||||
gateway6: "fe80::"
|
||||
denydns: true
|
||||
- name: "eth2"
|
||||
dhcp4: true
|
||||
dhcp6: false
|
||||
denydns: true
|
||||
...
|
18
host_vars/plex.yaml
Normal file
18
host_vars/plex.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
ansible_host: plex.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "plex.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: true
|
||||
https: false
|
||||
netplan:
|
||||
default_gateway: "192.168.69.254"
|
||||
additionalinterfaces:
|
||||
- name: "eth1"
|
||||
dhcp4: false
|
||||
dhcp6: false
|
||||
denydns: true
|
||||
addresses:
|
||||
- '2001:738:2001:207f:0:211:211:31/64'
|
||||
gateway6: 'fe80::'
|
||||
...
|
18
host_vars/postgres.yaml
Normal file
18
host_vars/postgres.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
ansible_host: postgres.intra.tormakris.dev
|
||||
servicename: postgres
|
||||
firewall:
|
||||
- port: "5432"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
- port: "9187"
|
||||
proto: tcp
|
||||
interface: "eth0"
|
||||
backup:
|
||||
folder: "/var/lib/postgresql/backup"
|
||||
tarfolder: "backup"
|
||||
host: backup.intra.tormakris.dev
|
||||
internal: true
|
||||
prearecommand: "time ( sudo -u postgres pg_dumpall > /var/lib/postgresql/backup/postgres.sql )"
|
||||
basedir: /mnt/backupstore
|
||||
...
|
3
host_vars/smtp.yaml
Normal file
3
host_vars/smtp.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
ansible_host: smtp.intra.tormakris.dev
|
||||
...
|
@ -1,2 +0,0 @@
|
||||
---
|
||||
backupscript_name: "test-backupscript.sh"
|
8
host_vars/unbound.yaml
Normal file
8
host_vars/unbound.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: unbound.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "dns.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: true
|
||||
https: true
|
||||
...
|
12
host_vars/vikunja.yaml
Normal file
12
host_vars/vikunja.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
ansible_host: vikunja.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "vikunja.tormakristof.eu"
|
||||
port: 8081
|
||||
bigrequests: false
|
||||
https: false
|
||||
additionallocations:
|
||||
- https: false
|
||||
port: 8080
|
||||
location: '~* ^/(api|dav|\.well-known)/'
|
||||
...
|
3
host_vars/webgateway.yaml
Normal file
3
host_vars/webgateway.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
ansible_host: apache.intra.tormakris.dev
|
||||
...
|
8
host_vars/ytmirror.yaml
Normal file
8
host_vars/ytmirror.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
ansible_host: ytmirror.intra.tormakris.dev
|
||||
webserver:
|
||||
- domain: "yt.tormakristof.eu"
|
||||
port: 8080
|
||||
bigrequests: false
|
||||
https: false
|
||||
...
|
84
infra.yaml
Normal file
84
infra.yaml
Normal file
@ -0,0 +1,84 @@
|
||||
---
|
||||
- name: "Deploy basic webhost with Docker"
|
||||
hosts: dockerwebhosts
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- docker
|
||||
- webserver
|
||||
- internalsmtp
|
||||
|
||||
- name: "Deploy database server base"
|
||||
hosts: postgres
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- backupscript
|
||||
- customfirewall
|
||||
|
||||
- name: "Deploy basic Docker host to drone-runner"
|
||||
hosts: drone-runner
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- docker
|
||||
- internalsmtp
|
||||
|
||||
- name: "Deploy gitea in Docker"
|
||||
hosts: git
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- docker
|
||||
- webserver
|
||||
- internalsmtp
|
||||
- backupscript
|
||||
- customfirewall
|
||||
|
||||
- name: "Setup neko"
|
||||
hosts: neko
|
||||
roles:
|
||||
- common
|
||||
- docker
|
||||
- customfirewall
|
||||
- internalsmtp
|
||||
|
||||
- name: "Deploy smtpgateway to smtp.intra.tormakris.dev"
|
||||
hosts: smtp
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- smtpgateway
|
||||
|
||||
- name: "Deploy managed web gateway"
|
||||
hosts: webgateway
|
||||
roles:
|
||||
- common
|
||||
- webgateway
|
||||
- internalsmtp
|
||||
|
||||
- name: "Deploy backup server"
|
||||
hosts: backup
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- internalsmtp
|
||||
- backupscript
|
||||
- backuphost
|
||||
|
||||
- name: "Deploy OpenVPN server"
|
||||
hosts: openvpn
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- openvpn
|
||||
- customfirewall
|
||||
- internalsmtp
|
||||
|
||||
- name: "Deploy Game server"
|
||||
hosts: gameservers
|
||||
roles:
|
||||
- netplan
|
||||
- common
|
||||
- internalsmtp
|
||||
...
|
@ -1,20 +1,55 @@
|
||||
---
|
||||
all:
|
||||
vars:
|
||||
ansible_become: true
|
||||
ansible_user: tormakris
|
||||
children:
|
||||
woolsey:
|
||||
hosts:
|
||||
neko:
|
||||
ansible_host: zelenka.stargate.internal
|
||||
drone:
|
||||
ansible_host: drone.stargate.internal
|
||||
keycloak:
|
||||
ansible_host: keycloak.stargate.internal
|
||||
sonar:
|
||||
ansible_host: sonar.stargate.internal
|
||||
swagger:
|
||||
ansible_host: swagger.stargate.internal
|
||||
matrix:
|
||||
drone-runner:
|
||||
ansible_host: drone-runner.stargate.internal
|
||||
smtp:
|
||||
webgateway:
|
||||
openvpn:
|
||||
nexus:
|
||||
git:
|
||||
postgres:
|
||||
monitoring:
|
||||
ytmirror:
|
||||
cloudlog:
|
||||
unbound:
|
||||
mckay:
|
||||
hosts:
|
||||
guacamole:
|
||||
bitwarden:
|
||||
nextcloud:
|
||||
backup:
|
||||
librespeed:
|
||||
plex:
|
||||
dockerwebhosts:
|
||||
hosts:
|
||||
matrix:
|
||||
drone:
|
||||
guacamole:
|
||||
bitwarden:
|
||||
nexus:
|
||||
nextcloud:
|
||||
monitoring:
|
||||
ytmirror:
|
||||
librespeed:
|
||||
plex:
|
||||
cloudlog:
|
||||
nightlydocker:
|
||||
hosts:
|
||||
matrix:
|
||||
guacamole:
|
||||
bitwarden:
|
||||
nexus:
|
||||
nextcloud:
|
||||
monitoring:
|
||||
ytmirror:
|
||||
librespeed:
|
||||
plex:
|
||||
cloudlog:
|
||||
gameservers:
|
||||
hosts:
|
||||
...
|
||||
|
@ -1,7 +0,0 @@
|
||||
---
|
||||
- name: "Setup neko"
|
||||
hosts: neko
|
||||
roles:
|
||||
- common
|
||||
- docker
|
||||
- neko
|
22
nightly.yaml
Normal file
22
nightly.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: "Deploy basic webhost with Docker"
|
||||
hosts: nightlydocker
|
||||
roles:
|
||||
- common
|
||||
- webserver
|
||||
- internalsmtp
|
||||
|
||||
- name: "Deploy smtpgateway to smtp.intra.tormakris.dev"
|
||||
hosts: smtp
|
||||
roles:
|
||||
- common
|
||||
- smtpgateway
|
||||
|
||||
- name: "Deploy backup server"
|
||||
hosts: backup
|
||||
roles:
|
||||
- common
|
||||
- internalsmtp
|
||||
- backupscript
|
||||
- backuphost
|
||||
...
|
6
realmd.yaml
Normal file
6
realmd.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: "Deploy basic webhost with Docker"
|
||||
hosts: all
|
||||
roles:
|
||||
- realmd
|
||||
...
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
collections:
|
||||
- ansible.posix
|
||||
- community.general
|
||||
- community.general
|
||||
...
|
||||
|
1
roles/backuphost/files/authorized_keys
Normal file
1
roles/backuphost/files/authorized_keys
Normal file
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCqSr3e/u2WtarrtKFhcj2E4MM/NpfREVxKnBO66HRoAUmjtNNMqS4O0OKlTLAKTFiftKeBfuvxtvdFXROXBAHekL0ff2DOuWz7k0IQjJd51x31FdVFUJZB2zk+UJENiJxwyqlQudJc7LYkztJyULfb0CYIkunTFO+fjZOUNrflrqe0JcLIgcuQqsi0gLwiQ+giWlZstdCGOq2ziqi5ZVi2Rhsgi1Lb4UsiO2B8dkxFiJMBkG+YvLl1EwZ6m9j8O92FsCsqbfoPIdcgR3XCzogSdjvKM72yKBEKs1hgGR6ajVkagWEOWXs8PC9toBcyZYt2GLncvyO1TnFDnPbecOdloifVDI23Osi+cFuOzLyi5CLs+sXaJNz1EOwlXwKhanqvCf+h11UKV7GuCjtlf6f8qOPtpTGgtOQnFie/jyNYBlcj2abNNPK5JaWtT4voY3GzpeYMV9c+bKgeS4r/7OqDn8Wpf8swWdwlGn0fBjwrVjEgAzwOH8XhHhQFGrNZbq0= root@backup-target
|
4
roles/backuphost/files/ssh_config
Normal file
4
roles/backuphost/files/ssh_config
Normal file
@ -0,0 +1,4 @@
|
||||
Host oniel.tormakristof.eu
|
||||
HostName oniel.tormakristof.eu
|
||||
User backup
|
||||
IdentityFile ~/.ssh/id_rsa
|
29
roles/backuphost/tasks/main.yaml
Normal file
29
roles/backuphost/tasks/main.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
# TODO: Make backup user part of AD
|
||||
---
|
||||
- name: "Add backup user"
|
||||
user:
|
||||
name: backup
|
||||
comment: Backup user
|
||||
shell: /bin/bash
|
||||
|
||||
- name: Create .ssh directory of backup user
|
||||
file:
|
||||
path: /home/backup/.ssh
|
||||
state: directory
|
||||
|
||||
- name: Copy authorized_keys
|
||||
copy:
|
||||
src: authorized_keys
|
||||
dest: /home/backup/.ssh/authorized_keys
|
||||
mode: 0600
|
||||
owner: backup
|
||||
group: backup
|
||||
|
||||
- name: Copy ssh config
|
||||
copy:
|
||||
src: ssh_config
|
||||
dest: /home/backup/.ssh/config
|
||||
mode: 0600
|
||||
owner: backup
|
||||
group: backup
|
||||
...
|
7
roles/backupscript/defaults/main.yaml
Normal file
7
roles/backupscript/defaults/main.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
backup:
|
||||
host: backup.intra.tormakris.dev
|
||||
internal: true
|
||||
prearecommand: ""
|
||||
basedir: /mnt/backupstore
|
||||
...
|
@ -1,9 +0,0 @@
|
||||
[Unit]
|
||||
Description=Backup application data
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/bash /opt/backupscript.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=backup.target
|
@ -1,5 +0,0 @@
|
||||
[Unit]
|
||||
Description=Script based backup for VMs
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
Description=Backup VMs
|
||||
|
||||
[Timer]
|
||||
OnBootSec=10min
|
||||
OnCalendar=Sun *-*-* 00:00:00
|
||||
Unit=backup.target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
4
roles/backupscript/files/ssh_config
Normal file
4
roles/backupscript/files/ssh_config
Normal file
@ -0,0 +1,4 @@
|
||||
Host backup backup.intra.tormakris.dev
|
||||
HostName backup.intra.tormakris.dev
|
||||
User backup
|
||||
IdentityFile ~/.ssh/id_rsa
|
@ -1 +0,0 @@
|
||||
echo "true"
|
@ -1,47 +1,22 @@
|
||||
---
|
||||
- name: Copy backupscript to target
|
||||
- name: "Generate backupscript"
|
||||
template:
|
||||
src: backupscript.sh
|
||||
dest: /etc/cron.weekly/backupscript
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0700'
|
||||
|
||||
- name: Create .ssh directory of root user
|
||||
file:
|
||||
path: /root/.ssh
|
||||
state: directory
|
||||
|
||||
- name: Copy ssh config
|
||||
copy:
|
||||
src: "{{ backupscript_name }}"
|
||||
dest: /opt/backupscript.sh
|
||||
mode: 700
|
||||
owner: service-user
|
||||
|
||||
- name: Copy backup-script.service to target
|
||||
copy:
|
||||
src: backup-script.service
|
||||
dest: /usr/lib/systemd/system/backup-script.service
|
||||
mode: 644
|
||||
owner: service-user
|
||||
|
||||
- name: Copy backup.target to target
|
||||
copy:
|
||||
src: backup.target
|
||||
dest: /usr/lib/systemd/system/backup.target
|
||||
mode: 644
|
||||
owner: service-user
|
||||
|
||||
- name: Copy backup.timer to target
|
||||
copy:
|
||||
src: backup.timer
|
||||
dest: /usr/lib/systemd/system/backup.timer
|
||||
mode: 644
|
||||
owner: service-user
|
||||
|
||||
- name: Enable backup-script.service and reload systemd daemon
|
||||
when: ansible_service_mgr == "systemd"
|
||||
ansible.builtin.systemd:
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
name: backup-script.service
|
||||
|
||||
- name: Enable backup.target
|
||||
when: ansible_service_mgr == "systemd"
|
||||
ansible.builtin.systemd:
|
||||
enabled: yes
|
||||
name: backup.target
|
||||
|
||||
- name: Enable backup.timer
|
||||
when: ansible_service_mgr == "systemd"
|
||||
ansible.builtin.systemd:
|
||||
enabled: yes
|
||||
name: backup.timer
|
||||
src: ssh_config
|
||||
dest: /root/.ssh/config
|
||||
mode: 0600
|
||||
owner: root
|
||||
group: root
|
||||
...
|
||||
|
18
roles/backupscript/templates/backupscript.sh
Normal file
18
roles/backupscript/templates/backupscript.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# {{ansible_managed}}
|
||||
|
||||
{% if backup.prearecommand is defined and backup.prearecommand|length > 0 %}
|
||||
{{backup.prearecommand}}
|
||||
{% endif %}
|
||||
|
||||
{% if backup.internal %}
|
||||
|
||||
time ( rsync -azP --delete {{backup.folder}} backup@{{backup.host}}:{{backup.basedir}}/{{servicename}}/staging )
|
||||
|
||||
time ( ssh backup@{{backup.host}} 'tar -zcvf {{backup.basedir}}/{{servicename}}/{{servicename}}-$(date +"%Y-%m-%d").tar.gz -C {{backup.basedir}}/{{servicename}}/staging {{backup.tarfolder}}' )
|
||||
|
||||
{% else %}
|
||||
|
||||
time ( rsync -azPr --delete --prune-empty-dirs --include "*/" --include="*.tar.gz" --include="*.sql" --include="*.zip" --exclude="*" {{backup.basedir}}/ backup@{{backup.host}}:/mnt/backup/{{servicename}} )
|
||||
|
||||
{% endif %}
|
@ -1,7 +1,8 @@
|
||||
---
|
||||
# defaults file for timedatectl
|
||||
timedatectl_timeservers: ['noc-a.sch.bme.hu', 'noc-b.sch.bme.hu']
|
||||
timedatectl_timeservers: ['time.intra.tormakris.dev']
|
||||
|
||||
timedatectl_timeservers_fallback: ['time.bme.hu']
|
||||
timedatectl_timeservers_fallback: ['time.kfki.hu']
|
||||
|
||||
timedatectl_timezone: 'Europe/Budapest'
|
||||
...
|
||||
|
1
roles/common/files/authorized_keys
Normal file
1
roles/common/files/authorized_keys
Normal file
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDFkYMmPYQ8hs6D5tuTt+sEofoMd2GTXyS97mh8maXmets3eS8iMm2W4Pppaqj9lMIsYdDX0BZvbmuQa+iNKchj6HJPtvdx2Rhus1UGn74iy/NtgogWFHL9YEYILzc5lBqotV5o3z/wRMfSwqnVwYBZ7OI+LJenwf76bIUm6lVqyh2Qh9/wWOyGpUVitDpUVi/h2J3xZf8Z2r1vHFdMHJygrrKn3C4vsZobHJ48iq8QWj1vwfMavq6dgJtiS4/WUTvHuzjfHdyyO7akBM66Ul41UlGG5iqkIKTIzLECXPPWWe/vCIcumkeMxtoY0pxpsgKu1kgqhNs8Q+hgF/H+lIlXtzsZ5gKUwhS7sUNejNywaMjcOUVvnRVXh3FaH9t8HK7mGouaN7q+ghNbMKLlxueP5mpgzK+APaRcNjA/4JyXN750l22xM6YQkxqOeuK5FS/TVmn2H6otaxGrfGz1sfYyynvWSMqpNStuCjCYfEHBLqPKX5tpG8z/gGNa/51CQvM= tormakris@woolsey.tormakris.dev
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- name: run Timedatectl
|
||||
command: timedatectl set-ntp true
|
||||
...
|
||||
|
@ -1,4 +1,11 @@
|
||||
---
|
||||
- name: "Use custom Ubuntu mirror"
|
||||
replace:
|
||||
path: /etc/apt/sources.list
|
||||
regexp: 'http://hu.archive.ubuntu.com'
|
||||
replace: 'https://mirrors.sth.sze.hu'
|
||||
backup: yes
|
||||
|
||||
- name: "Remove Ubuntu bloatware"
|
||||
apt:
|
||||
state: absent
|
||||
@ -35,3 +42,6 @@
|
||||
- tcpdump
|
||||
- xxd
|
||||
- git
|
||||
- ncdu
|
||||
- cron
|
||||
...
|
||||
|
@ -2,7 +2,8 @@
|
||||
- name: clean motd
|
||||
file:
|
||||
state: touch
|
||||
owner: tormakris
|
||||
group: tormakris
|
||||
owner: tormakris@intra.tormakris.dev
|
||||
group: domain users@intra.tormakris.dev
|
||||
mode: "0644"
|
||||
path: /home/tormakris/.hushlogin
|
||||
path: /home/tormakris@intra.tormakris.dev/.hushlogin
|
||||
...
|
||||
|
@ -10,4 +10,4 @@
|
||||
content: "network: {config: disabled}"
|
||||
dest: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
|
||||
force: no
|
||||
|
||||
...
|
||||
|
@ -6,4 +6,6 @@
|
||||
- include_tasks: ufw.yaml
|
||||
- include_tasks: user-ops.yaml
|
||||
- include_tasks: ssh-security-settings.yaml
|
||||
- include_tasks: timesync.yaml
|
||||
- include_tasks: timesync.yaml
|
||||
- include_tasks: node-exporter.yaml
|
||||
...
|
||||
|
21
roles/common/tasks/node-exporter.yaml
Normal file
21
roles/common/tasks/node-exporter.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: "Install node exporter"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- prometheus-node-exporter
|
||||
|
||||
- name: Allow node-exporter via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: 9100
|
||||
proto: tcp
|
||||
src: 192.168.69.0/24
|
||||
|
||||
- name: Enable and restart exporter daemon
|
||||
service:
|
||||
name: prometheus-node-exporter
|
||||
state: restarted
|
||||
enabled: yes
|
||||
...
|
@ -15,4 +15,5 @@
|
||||
- /var/snap
|
||||
- /var/lib/snapd
|
||||
- "/home/{{ ansible_user }}/snap"
|
||||
when: ansible_distribution == "Ubuntu"
|
||||
when: ansible_distribution == "Ubuntu"
|
||||
...
|
||||
|
@ -1,10 +1,4 @@
|
||||
---
|
||||
- name: Disable password authentication
|
||||
replace:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: 'PasswordAuthentication yes'
|
||||
replace: 'PasswordAuthentication no'
|
||||
|
||||
- name: Disable root authentication
|
||||
replace:
|
||||
path: /etc/ssh/sshd_config
|
||||
@ -23,18 +17,8 @@
|
||||
regexp: '#AddressFamily any'
|
||||
replace: 'AddressFamily inet'
|
||||
|
||||
- name: Check if AllowUsers is defined
|
||||
lineinfile:
|
||||
state: absent
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: "^AllowUsers"
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: checkallowusers
|
||||
|
||||
- name: Define AllowUsers if undefined
|
||||
lineinfile:
|
||||
state: present
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "AllowUsers tormakris ansible service-user"
|
||||
when: checkallowusers.found == 0
|
||||
- name: "Restart sshd"
|
||||
service:
|
||||
name: sshd
|
||||
state: restarted
|
||||
...
|
||||
|
@ -12,7 +12,8 @@
|
||||
|
||||
- name: Reastart timesyncd to apply changes
|
||||
when: ansible_service_mgr == "systemd"
|
||||
ansible.builtin.systemd:
|
||||
systemd:
|
||||
state: restarted
|
||||
daemon_reload: yes
|
||||
name: systemd-timesyncd
|
||||
...
|
||||
|
@ -18,3 +18,6 @@
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: ssh
|
||||
src: "{{ item }}"
|
||||
with_items: "{{ allowedranges }}"
|
||||
...
|
||||
|
@ -1,11 +1,38 @@
|
||||
---
|
||||
- name: "Add service user"
|
||||
ansible.builtin.user:
|
||||
name: service-user
|
||||
comment: Service user
|
||||
- name: Create .ssh directory of ansible user
|
||||
file:
|
||||
path: /home/ansible@intra.tormakris.dev/.ssh
|
||||
state: directory
|
||||
owner: ansible@intra.tormakris.dev
|
||||
group: domain users@intra.tormakris.dev
|
||||
|
||||
- name: Copy authorized_keys
|
||||
copy:
|
||||
src: authorized_keys
|
||||
dest: /home/ansible@intra.tormakris.dev/.ssh/authorized_keys
|
||||
mode: 0600
|
||||
owner: ansible@intra.tormakris.dev
|
||||
group: domain users@intra.tormakris.dev
|
||||
|
||||
- name: Check if group is present in sudoers
|
||||
lineinfile:
|
||||
state: absent
|
||||
path: /etc/sudoers
|
||||
regexp: "^%linuxadmins"
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: checksudoers
|
||||
|
||||
- name: Define group in sudoers
|
||||
lineinfile:
|
||||
state: present
|
||||
path: /etc/sudoers
|
||||
line: "%linuxadmins@intra.tormakris.dev ALL=(ALL) NOPASSWD: ALL"
|
||||
when: checksudoers.found == 0
|
||||
|
||||
- name: "Update authorized_keys of tormakris"
|
||||
ansible.posix.authorized_key:
|
||||
user: tormakris
|
||||
user: tormakris@intra.tormakris.dev
|
||||
state: present
|
||||
key: https://static.tormakristof.eu/ssh.keys
|
||||
...
|
||||
|
3
roles/common/templates/jfrog.conf.template
Normal file
3
roles/common/templates/jfrog.conf.template
Normal file
@ -0,0 +1,3 @@
|
||||
machine tormakris.jfrog.io
|
||||
login apt
|
||||
password {{ artifactory_password }}
|
10
roles/customfirewall/tasks/main.yaml
Normal file
10
roles/customfirewall/tasks/main.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: Apply custom ufw rules
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
direction: "in"
|
||||
port: "{{item.port}}"
|
||||
proto: "{{item.proto}}"
|
||||
interface: "{{item.interface}}"
|
||||
with_items: "{{ firewall }}"
|
||||
...
|
@ -1,3 +1,7 @@
|
||||
{
|
||||
"userland-proxy": false
|
||||
"userland-proxy": false,
|
||||
"dns": [
|
||||
"192.168.69.3",
|
||||
"192.168.69.18"
|
||||
]
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
dest: /etc/docker/daemon.json
|
||||
mode: 644
|
||||
owner: root
|
||||
group: backup
|
||||
|
||||
- name: Enable and restart Docker daemon
|
||||
service:
|
||||
@ -21,8 +22,15 @@
|
||||
enabled: yes
|
||||
|
||||
- name: "Add service user to docker group"
|
||||
ansible.builtin.user:
|
||||
name: service-user
|
||||
comment: Service user
|
||||
user:
|
||||
name: service-user@intra.tormakris.dev
|
||||
groups: docker
|
||||
append: yes
|
||||
|
||||
- name: Allow docker exporter via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "4194"
|
||||
proto: tcp
|
||||
src: 192.168.69.0/24
|
||||
...
|
||||
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
postfix_relayhost: 'smtp.stargate.internal'
|
||||
postfix_relayhost: 'smtp.intra.tormakris.dev'
|
||||
|
||||
external_domain: 'kmlabz.com'
|
||||
external_domain: 'tormakris.dev'
|
||||
...
|
||||
|
15
roles/internalsmtp/files/prometheus-postfix-exporter
Normal file
15
roles/internalsmtp/files/prometheus-postfix-exporter
Normal file
@ -0,0 +1,15 @@
|
||||
# Private log file from Postfix to read and truncate. Configured in
|
||||
# /etc/rsyslog.d/prometheus-postfix-exporter.conf
|
||||
POSTFIXLOGFILE=/var/log/mail.log
|
||||
|
||||
# Extra arguments for the daemon.
|
||||
ARGS=''
|
||||
|
||||
# Prometheus-postfix-exporter supports the following options:
|
||||
# --postfix.showq_path string
|
||||
# Path at which Postfix places its showq socket.
|
||||
# (default "/var/spool/postfix/public/showq")
|
||||
# --web.listen-address string
|
||||
# Address to listen on for web interface and telemetry. (default ":9154")
|
||||
# --web.telemetry-path string
|
||||
# Path under which to expose metrics. (default "/metrics")
|
@ -16,3 +16,38 @@
|
||||
name: postfix
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: "Install postfix exporter"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- prometheus-postfix-exporter
|
||||
|
||||
- name: Copy postfix exporter config
|
||||
copy:
|
||||
src: prometheus-postfix-exporter
|
||||
dest: /etc/default/prometheus-postfix-exporter
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Add the prometheus user to postdrop group
|
||||
user:
|
||||
name: prometheus
|
||||
groups: postdrop
|
||||
append: yes
|
||||
|
||||
- name: Enable and restart exporter daemon
|
||||
service:
|
||||
name: prometheus-postfix-exporter
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Allow postfix exporter via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "9154"
|
||||
proto: tcp
|
||||
src: 192.168.69.0/24
|
||||
...
|
||||
|
@ -1,19 +0,0 @@
|
||||
---
|
||||
- name: "Install MariaDB via apt"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- mariadb-server
|
||||
|
||||
- name: Enable and restart MariaDB daemon
|
||||
service:
|
||||
name: mariadb
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Allow mysql port via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "3306"
|
||||
proto: tcp
|
@ -1,8 +0,0 @@
|
||||
---
|
||||
- name: Mount up device by UUID
|
||||
ansible.posix.mount:
|
||||
path: "{{ mountpoint_path }}"
|
||||
src: "UUID={{ mountpoint_uuid }}"
|
||||
fstype: "{{ mountpoint_fstype }}"
|
||||
opts: "{{ mountpoint_opts }}"
|
||||
state: mounted
|
@ -1,65 +0,0 @@
|
||||
---
|
||||
- name: "Install haproxy via apt"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- haproxy
|
||||
|
||||
- name: Enable haproxy
|
||||
service:
|
||||
name: haproxy
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: "Install certbot via apt"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- python3-certbot
|
||||
|
||||
- name: Reset ufw rules to default
|
||||
community.general.ufw:
|
||||
state: reset
|
||||
|
||||
- name: Enable ufw
|
||||
community.general.ufw:
|
||||
state: enabled
|
||||
|
||||
- name: Allow ssh via ufw from localnet
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
direction: in
|
||||
port: ssh
|
||||
from_ip: "192.168.69.0/24"
|
||||
interface: eth0
|
||||
|
||||
- name: Allow http via ufw from internet
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
direction: in
|
||||
port: http
|
||||
interface: eth1
|
||||
|
||||
- name: Allow https via ufw from internet
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
direction: in
|
||||
port: https
|
||||
interface: eth1
|
||||
|
||||
- name: Allow http via ufw from internet
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
direction: in
|
||||
port: http
|
||||
interface: eth1
|
||||
|
||||
- name: Allow neko ports via ufw from internet
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
direction: in
|
||||
port: 52000:52100
|
||||
proto: udp
|
||||
interface: eth1
|
4
roles/netplan/defaults/main.yaml
Normal file
4
roles/netplan/defaults/main.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
netplan:
|
||||
additionalinterfaces: []
|
||||
...
|
@ -2,4 +2,5 @@
|
||||
- name: "netplanapply"
|
||||
command: netplan apply
|
||||
async: 45
|
||||
poll: 0
|
||||
poll: 0
|
||||
...
|
||||
|
@ -14,3 +14,4 @@
|
||||
src: templates/netplan.yaml
|
||||
dest: /etc/netplan/00-static.yaml
|
||||
notify: netplanapply
|
||||
...
|
||||
|
@ -6,6 +6,36 @@ network:
|
||||
{{ ansible_default_ipv4.interface }}:
|
||||
dhcp4: true
|
||||
dhcp-identifier: mac
|
||||
{% if netplan.default_gateway is defined and netplan.default_gateway|length > 0 %}
|
||||
dhcp4-overrides:
|
||||
use-routes: false
|
||||
gateway4: {{default_gateway}}
|
||||
gateway4: {{netplan.default_gateway}}
|
||||
{% endif %}
|
||||
{% if netplan.additionalinterfaces is defined and netplan.additionalinterfaces|length > 0 %}
|
||||
{% for interface in netplan.additionalinterfaces %}
|
||||
{{ interface.name }}:
|
||||
dhcp4: {{ interface.dhcp4 }}
|
||||
dhcp6: {{ interface.dhcp6 }}
|
||||
dhcp-identifier: mac
|
||||
dhcp4-overrides:
|
||||
use-routes: false
|
||||
{% if interface.addresses is defined and interface.addresses|length > 0 %}
|
||||
addresses:
|
||||
{% for address in interface.addresses %}
|
||||
- {{address}}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if interface.gateway4 is defined and interface.gateway4|length > 0 %}
|
||||
gateway4: {{interface.gateway4}}
|
||||
{% endif %}
|
||||
{% if interface.gateway6 is defined and interface.gateway6|length > 0 %}
|
||||
gateway6: '{{interface.gateway6}}'
|
||||
{% endif %}
|
||||
{% if interface.denydns %}
|
||||
nameservers:
|
||||
addresses: []
|
||||
search: []
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
...
|
||||
|
64
roles/openvpn/tasks/main.yaml
Normal file
64
roles/openvpn/tasks/main.yaml
Normal file
@ -0,0 +1,64 @@
|
||||
---
|
||||
- name: "Install openvpn-server via apt"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- openvpn
|
||||
|
||||
- name : "Enable ipv4 forwarding via sysctl"
|
||||
ansible.posix.sysctl:
|
||||
name: net.ipv4.ip_forward
|
||||
value: '1'
|
||||
sysctl_set: yes
|
||||
state: present
|
||||
reload: yes
|
||||
|
||||
- name: Enable and restart openvpn daemon
|
||||
service:
|
||||
name: openvpn-server@stargate
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Check if AllowUsers is defined
|
||||
lineinfile:
|
||||
state: absent
|
||||
path: /etc/ufw/before.rules
|
||||
regexp: "^# START OPENVPN"
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: checkufwrules
|
||||
|
||||
- name: Insert openvpn iptables rules
|
||||
blockinfile:
|
||||
path: /etc/ufw/before.rules
|
||||
block: |
|
||||
# START OPENVPN RULES
|
||||
# NAT table rules
|
||||
*nat
|
||||
-F
|
||||
:POSTROUTING ACCEPT [0:0]
|
||||
# Allow traffic from OpenVPN client to everywhere
|
||||
-A POSTROUTING -s 192.168.37.0/24 -o eth0 -j MASQUERADE
|
||||
-A POSTROUTING -s 192.168.37.0/24 -o eth2 -j MASQUERADE
|
||||
COMMIT
|
||||
*filter
|
||||
-A ufw-before-input -i tun+ -j ACCEPT
|
||||
-A ufw-before-forward -i tun+ -j ACCEPT
|
||||
-A ufw-before-forward -i tun+ -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A ufw-before-forward -i eth0 -o tun+ -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A ufw-before-forward -i tun+ -o eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A ufw-before-forward -i eth2 -o tun+ -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
COMMIT
|
||||
# END OPENVPN RULES
|
||||
|
||||
- name: Reload ufw
|
||||
community.general.ufw:
|
||||
state: reloaded
|
||||
|
||||
- name: Apply custom ufw rules
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
direction: "in"
|
||||
interface: tun0
|
||||
...
|
@ -1,19 +0,0 @@
|
||||
---
|
||||
- name: "Install PostgreSQL via apt"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- postgresql
|
||||
|
||||
- name: Enable and restart PostgreSQL daemon
|
||||
service:
|
||||
name: postgresql
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Allow postgresql port via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "5432"
|
||||
proto: tcp
|
94
roles/realmd/tasks/main.yaml
Normal file
94
roles/realmd/tasks/main.yaml
Normal file
@ -0,0 +1,94 @@
|
||||
---
|
||||
- name: "Install realmd and dependencies"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- realmd
|
||||
- sssd
|
||||
- sssd-tools
|
||||
- libnss-sss
|
||||
- libpam-sss
|
||||
- adcli
|
||||
- samba-common-bin
|
||||
- oddjob
|
||||
- oddjob-mkhomedir
|
||||
- packagekit
|
||||
|
||||
- name: Check if computer is joined to domain
|
||||
lineinfile:
|
||||
state: absent
|
||||
path: /etc/sssd/sssd.conf
|
||||
line: "^ad_access_filter"
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: checkjoined
|
||||
|
||||
- name: "Get join password from local environment variable"
|
||||
set_fact:
|
||||
join_passw: "{{ lookup('env', 'JOIN_PASSW') }}"
|
||||
delegate_to: localhost
|
||||
when: checkjoined.found == 0
|
||||
|
||||
- name: Join to AD with realmd
|
||||
shell:
|
||||
cmd: echo {{ join_passw }} | realm join -v -U tormakris_admin intra.tormakris.dev
|
||||
when: checkjoined.found == 0
|
||||
|
||||
- name: Enable pam homedir create on first logon
|
||||
command:
|
||||
cmd: pam-auth-update --enable mkhomedir
|
||||
|
||||
- name: Check if ad_gpo_access_control is disabled
|
||||
lineinfile:
|
||||
state: absent
|
||||
path: /etc/sssd/sssd.conf
|
||||
regexp: "^ad_gpo_access_control"
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: checkadgpoac
|
||||
|
||||
- name: Set ad_gpo_access_control to disabled
|
||||
lineinfile:
|
||||
state: present
|
||||
path: /etc/sssd/sssd.conf
|
||||
line: "ad_gpo_access_control = disabled"
|
||||
when: checkadgpoac.found == 0
|
||||
|
||||
- name: Check if ad_access_filter is set
|
||||
lineinfile:
|
||||
state: absent
|
||||
path: /etc/sssd/sssd.conf
|
||||
regexp: "^ad_access_filter"
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: checkadaf
|
||||
|
||||
- name: Set ad_gpo_access_control to disabled
|
||||
lineinfile:
|
||||
state: present
|
||||
path: /etc/sssd/sssd.conf
|
||||
line: "ad_access_filter = memberOf=CN=LinuxUsers,OU=Service Groups,DC=intra,DC=tormakris,DC=dev"
|
||||
when: checkadaf.found == 0
|
||||
|
||||
- name: "Restart sssd"
|
||||
service:
|
||||
name: sssd
|
||||
state: restarted
|
||||
|
||||
- name: Check if group is presend in sudoers
|
||||
lineinfile:
|
||||
state: absent
|
||||
path: /etc/sudoers
|
||||
regexp: "^%linuxadmins"
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: checksudoers
|
||||
|
||||
- name: Define group in sudoers
|
||||
lineinfile:
|
||||
state: present
|
||||
path: /etc/sudoers
|
||||
line: "%linuxadmins@intra.tormakris.dev ALL=(ALL) NOPASSWD: ALL"
|
||||
when: checksudoers.found == 0
|
||||
...
|
@ -1,5 +1,4 @@
|
||||
---
|
||||
postfix_relayhost: 'smtp.sendgrid.net'
|
||||
external_domain: 'kmlabz.com'
|
||||
username: lofasz
|
||||
password: lofasz
|
||||
postfix_relayhost: 'tormakris-dev.mail.protection.outlook.com'
|
||||
external_domain: 'tormakris.dev'
|
||||
...
|
||||
|
15
roles/smtpgateway/files/prometheus-postfix-exporter
Normal file
15
roles/smtpgateway/files/prometheus-postfix-exporter
Normal file
@ -0,0 +1,15 @@
|
||||
# Private log file from Postfix to read and truncate. Configured in
|
||||
# /etc/rsyslog.d/prometheus-postfix-exporter.conf
|
||||
POSTFIXLOGFILE=/var/log/mail.log
|
||||
|
||||
# Extra arguments for the daemon.
|
||||
ARGS=''
|
||||
|
||||
# Prometheus-postfix-exporter supports the following options:
|
||||
# --postfix.showq_path string
|
||||
# Path at which Postfix places its showq socket.
|
||||
# (default "/var/spool/postfix/public/showq")
|
||||
# --web.listen-address string
|
||||
# Address to listen on for web interface and telemetry. (default ":9154")
|
||||
# --web.telemetry-path string
|
||||
# Path under which to expose metrics. (default "/metrics")
|
@ -6,22 +6,14 @@
|
||||
name:
|
||||
- postfix
|
||||
|
||||
- name: Install Postfix SASL credentials
|
||||
template:
|
||||
src: templates/sasl_passwd
|
||||
mode: 600
|
||||
dest: /etc/postfix/sasl_passwd
|
||||
|
||||
- name: Install Postfix mail gateway config
|
||||
template:
|
||||
src: templates/main.cf
|
||||
dest: /etc/postfix/main.cf
|
||||
|
||||
- name: Build /etc/mailname
|
||||
shell: hostname --fqdn > /etc/mailname
|
||||
|
||||
- name: Build hashtable of SASL creds
|
||||
command: postmap /etc/postfix/sasl_passwd
|
||||
shell:
|
||||
cmd: "hostname --fqdn > /etc/mailname"
|
||||
|
||||
- name: Restart Postfix
|
||||
service:
|
||||
@ -32,4 +24,40 @@
|
||||
- name: Allow smtp port via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: smtp
|
||||
port: smtp
|
||||
src: 192.168.69.0/24
|
||||
|
||||
- name: "Install postfix exporter"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- prometheus-postfix-exporter
|
||||
|
||||
- name: Copy exporter config
|
||||
copy:
|
||||
src: prometheus-postfix-exporter
|
||||
dest: /etc/default/prometheus-postfix-exporter
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Add the prometheus user to postdrop group
|
||||
user:
|
||||
name: prometheus
|
||||
groups: postdrop
|
||||
append: yes
|
||||
|
||||
- name: Enable and restart exporter daemon
|
||||
service:
|
||||
name: prometheus-postfix-exporter
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Allow postfix exporter via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "9154"
|
||||
proto: tcp
|
||||
src: 192.168.69.0/24
|
||||
...
|
||||
|
@ -14,10 +14,6 @@ smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
|
||||
smtpd_tls_security_level=may
|
||||
|
||||
smtp_tls_CApath=/etc/ssl/certs
|
||||
smtp_sasl_auth_enable = yes
|
||||
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
|
||||
smtp_sasl_security_options = noanonymous
|
||||
smtp_sasl_tls_security_options = noanonymous
|
||||
smtp_tls_security_level = encrypt
|
||||
header_size_limit = 4096000
|
||||
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
|
||||
@ -29,8 +25,8 @@ alias_maps = hash:/etc/aliases
|
||||
alias_database = hash:/etc/aliases
|
||||
myorigin = /etc/mailname
|
||||
mydestination = {{ansible_hostname}}.{{external_domain}}, $myhostname, {{ansible_hostname}}, localhost.localdomain, localhost
|
||||
relayhost = {{postfix_relayhost}}
|
||||
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
|
||||
relayhost = [{{postfix_relayhost}}]
|
||||
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 {{ansible_default_ipv4.network}}/24
|
||||
mailbox_size_limit = 0
|
||||
recipient_delimiter = +
|
||||
inet_interfaces = all
|
||||
|
@ -1 +0,0 @@
|
||||
[{{postfix_relayhost}}:587 {{username}}:{{password}}
|
63
roles/webgateway/files/nginx.conf
Normal file
63
roles/webgateway/files/nginx.conf
Normal file
@ -0,0 +1,63 @@
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
14
roles/webgateway/files/prometheus-nginx-exporter
Normal file
14
roles/webgateway/files/prometheus-nginx-exporter
Normal file
@ -0,0 +1,14 @@
|
||||
ARGS="-nginx.scrape-uri http://127.0.0.1:8080/stub_status"
|
||||
|
||||
# Prometheus-nginx-exporter supports the following options:
|
||||
# -nginx.plus
|
||||
# Start the exporter for NGINX Plus. By default, the exporter is started
|
||||
# for NGINX.
|
||||
# -nginx.scrape-uri string
|
||||
# A URI for scraping NGINX or NGINX Plus metrics.
|
||||
# For NGINX, the stub_status page must be available through the URI.
|
||||
# For NGINX Plus -- the API. (default "http://127.0.0.1:8080/stub_status")
|
||||
# -web.listen-address string
|
||||
# An address to listen on for web interface and telemetry. (default ":9113")
|
||||
# -web.telemetry-path string
|
||||
# A path under which to expose metrics. (default "/metrics"
|
@ -1,18 +1,12 @@
|
||||
---
|
||||
- name: "Install Apache via apt"
|
||||
- name: "Install nginx via apt"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- apache2
|
||||
|
||||
# TODO: Felmasolni a templatelt konfigokat es bekapcsolni oket
|
||||
|
||||
- name: Enable and restart Apache2 daemon
|
||||
service:
|
||||
name: apache2
|
||||
state: restarted
|
||||
enabled: yes
|
||||
- nginx
|
||||
- python3-certbot
|
||||
- python3-certbot-nginx
|
||||
|
||||
- name: Allow http port via ufw
|
||||
community.general.ufw:
|
||||
@ -23,3 +17,104 @@
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: https
|
||||
|
||||
- name: Copy default nginx config
|
||||
copy:
|
||||
src: nginx.conf
|
||||
dest: /etc/nginx/nginx.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Enable and restart nginx daemon
|
||||
service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Generate certificate for all proxied domains
|
||||
command:
|
||||
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
|
||||
with_items: "{{ proxy }}"
|
||||
|
||||
- name: Generate certificate for all static sites
|
||||
command:
|
||||
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
|
||||
with_items: "{{ static }}"
|
||||
|
||||
- name: Generate certificate for all redirect sites
|
||||
command:
|
||||
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
|
||||
with_items: "{{ redirect }}"
|
||||
|
||||
- name: "Generate certbot script"
|
||||
template:
|
||||
src: certbot.sh
|
||||
dest: /etc/cron.weekly/certbot
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0700'
|
||||
|
||||
- name: "Generate nginx configuration"
|
||||
template:
|
||||
src: nginx.conf
|
||||
dest: /etc/nginx/nginx.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Validate nginx configuration
|
||||
command:
|
||||
cmd: nginx -t
|
||||
|
||||
- name: Reload nginx after configuration change
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
|
||||
- name: "Remove any existing static file directories"
|
||||
file:
|
||||
path: "{{ item.directory }}"
|
||||
state: absent
|
||||
with_items: "{{ static }}"
|
||||
|
||||
- name: "Checkout static websites from git"
|
||||
git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ item.directory }}"
|
||||
with_items: "{{ static }}"
|
||||
|
||||
- name: "Remove .git directory from static websites"
|
||||
file:
|
||||
path: "{{ item.directory }}/.git"
|
||||
state: absent
|
||||
with_items: "{{ static }}"
|
||||
|
||||
- name: "Install nginx exporter"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- prometheus-nginx-exporter
|
||||
|
||||
- name: Copy nginx exporter config
|
||||
copy:
|
||||
src: prometheus-nginx-exporter
|
||||
dest: /etc/default/prometheus-nginx-exporter
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Enable and restart exporter daemon
|
||||
service:
|
||||
name: prometheus-nginx-exporter
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Allow nginx exporter via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: 9113
|
||||
proto: tcp
|
||||
src: 192.168.69.0/24
|
||||
...
|
||||
|
12
roles/webgateway/templates/certbot.sh
Normal file
12
roles/webgateway/templates/certbot.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
# {{ansible_managed}}
|
||||
certbot renew --nginx --cert-name tormakristof.eu
|
||||
{% for proxysite in proxy %}
|
||||
certbot renew --nginx --cert-name {{ proxysite.domain }}
|
||||
{% endfor %}
|
||||
{% for staticsite in static %}
|
||||
certbot renew --nginx --cert-name {{ staticsite.domain }}
|
||||
{% endfor %}
|
||||
{% for redirectsite in redirect %}
|
||||
certbot renew --nginx --cert-name {{ redirectsite.domain }}
|
||||
{% endfor %}
|
152
roles/webgateway/templates/nginx.conf
Normal file
152
roles/webgateway/templates/nginx.conf
Normal file
@ -0,0 +1,152 @@
|
||||
# {{ ansible_managed }}
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
server_names_hash_bucket_size 64;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
gzip on;
|
||||
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-MS-Proxy webgateway.intra.tormakris.dev;
|
||||
proxy_set_header X-MS-Forwarded-Client-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_ssl_server_name on;
|
||||
client_body_buffer_size 128k;
|
||||
proxy_connect_timeout 90;
|
||||
proxy_send_timeout 120;
|
||||
proxy_read_timeout 300;
|
||||
proxy_buffer_size 128k;
|
||||
proxy_buffers 4 256k;
|
||||
proxy_busy_buffers_size 256k;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
server_tokens off;
|
||||
|
||||
server {
|
||||
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
{%- for proxysite in proxy -%}
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name {{ proxysite.domain }};
|
||||
proxy_ssl_name {{ proxysite.domain }};
|
||||
ssl_certificate /etc/letsencrypt/live/{{ proxysite.domain }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ proxysite.domain }}/privkey.pem;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
{%- if proxysite.bigrequests %}
|
||||
client_max_body_size 8G;
|
||||
{%- endif %}
|
||||
location /{
|
||||
proxy_pass https://{{ proxysite.ip }};
|
||||
{%- if proxysite.ignorecert %}
|
||||
proxy_ssl_verify off;
|
||||
{%- endif %}
|
||||
}
|
||||
location /metrics{
|
||||
proxy_pass https://{{ proxysite.ip }};
|
||||
allow 192.168.69.0/24;
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
||||
{%- endfor -%}
|
||||
|
||||
{%- for staticsite in static -%}
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name {{ staticsite.domain }};
|
||||
ssl_certificate /etc/letsencrypt/live/{{ staticsite.domain }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ staticsite.domain }}/privkey.pem;
|
||||
root {{ staticsite.directory }};
|
||||
location /{
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
|
||||
{%- endfor -%}
|
||||
|
||||
{%- for redirectsite in redirect -%}
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name {{ redirectsite.domain }};
|
||||
ssl_certificate /etc/letsencrypt/live/{{ redirectsite.domain }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ redirectsite.domain }}/privkey.pem;
|
||||
return 301 {{ redirectsite.destination }};
|
||||
}
|
||||
|
||||
{%- endfor -%}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name tormakristof.eu;
|
||||
ssl_certificate /etc/letsencrypt/live/tormakristof.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/tormakristof.eu/privkey.pem;
|
||||
root /var/www/tormakristof.eu;
|
||||
location /{
|
||||
return 301 https://www.tormakristof.eu;
|
||||
}
|
||||
location /.well-known{
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location /.well-known/webfinger {
|
||||
return 301 https://mastodon.tormakristof.eu$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
|
||||
location /stub_status {
|
||||
stub_status;
|
||||
allow 127.0.0.1;
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
}
|
26
roles/webgateway/vars/main.yaml
Normal file
26
roles/webgateway/vars/main.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
proxy:
|
||||
- {domain: bitwarden.tormakristof.eu, ip: bitwarden.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||
- {domain: nextcloud.tormakristof.eu, ip: nextcloud.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||
- {domain: drone.kmlabz.com, ip: drone.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||
- {domain: git.kmlabz.com, ip: git.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||
- {domain: guacamole.tormakristof.eu, ip: guacamole.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||
- {domain: matrix.tormakristof.eu, ip: matrix.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||
- {domain: chat.tormakristof.eu, ip: matrix.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||
- {domain: nexus.kmlabz.com, ip: nexus.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||
- {domain: registry.kmlabz.com, ip: nexus.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||
- {domain: fs.tormakristof.eu, ip: adfs.intra.tormakris.dev, bigrequests: false, ignorecert: true}
|
||||
- {domain: certauth.fs.tormakristof.eu, ip: adfs.intra.tormakris.dev, bigrequests: false, ignorecert: true}
|
||||
- {domain: grafana.tormakristof.eu, ip: monitoring.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||
- {domain: yt.tormakristof.eu, ip: ytmirror.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||
- {domain: speedtest.tormakristof.eu, ip: librespeed.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||
- {domain: plex.tormakristof.eu, ip: plex.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||
- {domain: neko.tormakristof.eu, ip: vzelenka.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||
- {domain: cloudlog.tormakristof.eu, ip: cloudlog.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||
- {domain: dns.tormakristof.eu, ip: unbound.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||
|
||||
static:
|
||||
[]
|
||||
|
||||
redirect:
|
||||
[]
|
||||
...
|
6
roles/webserver/defaults/main.yaml
Normal file
6
roles/webserver/defaults/main.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
webserver:
|
||||
- domain: "_"
|
||||
port: 8080
|
||||
bigrequests: false
|
||||
https: false
|
||||
...
|
@ -1,17 +0,0 @@
|
||||
<IfModule mod_ssl.c>
|
||||
<VirtualHost _default_:443>
|
||||
ServerAdmin webmaster@kmlabz.com
|
||||
|
||||
DocumentRoot /var/www/html
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
|
||||
SSLEngine on
|
||||
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
|
||||
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
|
||||
|
||||
ProxyPass "/" "http://127.0.0.1:8080/" retry=1 acquire=3000 timeout=600 Keepalive=On
|
||||
ProxyPassReverse "/" "http://127.0.0.1:8080/"
|
||||
</VirtualHost>
|
||||
</IfModule>
|
72
roles/webserver/files/nginx.conf
Normal file
72
roles/webserver/files/nginx.conf
Normal file
@ -0,0 +1,72 @@
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
server {
|
||||
root /var/www/html;
|
||||
server_name _;
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
|
||||
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
|
||||
location /{
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
}
|
14
roles/webserver/files/prometheus-nginx-exporter
Normal file
14
roles/webserver/files/prometheus-nginx-exporter
Normal file
@ -0,0 +1,14 @@
|
||||
ARGS="-nginx.scrape-uri http://127.0.0.1:8888/stub_status"
|
||||
|
||||
# Prometheus-nginx-exporter supports the following options:
|
||||
# -nginx.plus
|
||||
# Start the exporter for NGINX Plus. By default, the exporter is started
|
||||
# for NGINX.
|
||||
# -nginx.scrape-uri string
|
||||
# A URI for scraping NGINX or NGINX Plus metrics.
|
||||
# For NGINX, the stub_status page must be available through the URI.
|
||||
# For NGINX Plus -- the API. (default "http://127.0.0.1:8080/stub_status")
|
||||
# -web.listen-address string
|
||||
# An address to listen on for web interface and telemetry. (default ":9113")
|
||||
# -web.telemetry-path string
|
||||
# A path under which to expose metrics. (default "/metrics"
|
@ -1,28 +1,98 @@
|
||||
---
|
||||
- name: "Install Apache via apt"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- apache2
|
||||
|
||||
- name: Upload site config to destination
|
||||
copy:
|
||||
src: apache-site.conf
|
||||
dest: /etc/apache2/sites-available/site.conf
|
||||
mode: 644
|
||||
owner: root
|
||||
|
||||
- name: Enable site
|
||||
command: a2ensite site.conf
|
||||
|
||||
- name: Enable and restart Apache2 daemon
|
||||
service:
|
||||
name: apache2
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Allow https port via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: https
|
||||
src: "{{ item }}"
|
||||
with_items: "{{ allowedranges }}"
|
||||
|
||||
- name: "Install Nginx via apt"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- nginx
|
||||
- python3-certbot
|
||||
- python3-certbot-dns-cloudflare
|
||||
|
||||
- name: Copy default nginx config
|
||||
copy:
|
||||
src: nginx.conf
|
||||
dest: /etc/nginx/nginx.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Enable and restart nginx daemon
|
||||
service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: "Get Cloudflare token from local environment variable"
|
||||
set_fact:
|
||||
cloudflare_token: "{{ lookup('env', 'CLOUDFLARE_TOKEN') }}"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: "Render Cloudflare Certbot plugin configuration"
|
||||
template:
|
||||
src: cf-creds.ini
|
||||
dest: /root/cf-creds.ini
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0600
|
||||
|
||||
- name: Generate certificate for all server instances
|
||||
shell:
|
||||
cmd: certbot certonly --non-interactive --agree-tos -m iam@tormakristof.eu --dns-cloudflare --dns-cloudflare-credentials /root/cf-creds.ini -d {{item.domain}}
|
||||
with_items: "{{ webserver }}"
|
||||
|
||||
- name: "Generate certbot script"
|
||||
template:
|
||||
src: certbot.sh
|
||||
dest: /etc/cron.weekly/certbot
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0700'
|
||||
|
||||
- name: "Generate nginx configuration"
|
||||
template:
|
||||
src: nginx.conf
|
||||
dest: /etc/nginx/nginx.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Reload nginx daemon
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
|
||||
- name: "Install nginx exporter"
|
||||
apt:
|
||||
update_cache: yes
|
||||
state: present
|
||||
name:
|
||||
- prometheus-nginx-exporter
|
||||
|
||||
- name: Allow nginx exporter via ufw
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: 9113
|
||||
proto: tcp
|
||||
src: 192.168.69.0/24
|
||||
|
||||
- name: Copy nginx exporter config
|
||||
copy:
|
||||
src: prometheus-nginx-exporter
|
||||
dest: /etc/default/prometheus-nginx-exporter
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Enable and restart exporter daemon
|
||||
service:
|
||||
name: prometheus-nginx-exporter
|
||||
state: restarted
|
||||
enabled: yes
|
||||
...
|
||||
|
5
roles/webserver/templates/certbot.sh
Normal file
5
roles/webserver/templates/certbot.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
# {{ansible_managed}}
|
||||
{% for server in webserver %}
|
||||
certbot renew --dns-cloudflare --dns-cloudflare-credentials /root/cf-creds.ini 10 --cert-name {{ server.domain }}
|
||||
{% endfor %}
|
4
roles/webserver/templates/cf-creds.ini
Normal file
4
roles/webserver/templates/cf-creds.ini
Normal file
@ -0,0 +1,4 @@
|
||||
# Cloudflare API token used by Certbot
|
||||
# {{ ansible_managed }}
|
||||
dns_cloudflare_email = tormakristof@outlook.com
|
||||
dns_cloudflare_api_key = {{ cloudflare_token }}
|
118
roles/webserver/templates/nginx.conf
Normal file
118
roles/webserver/templates/nginx.conf
Normal file
@ -0,0 +1,118 @@
|
||||
# {{ansible_managed}}
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
server_names_hash_bucket_size 64;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
gzip on;
|
||||
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-MS-Proxy webgateway.intra.tormakris.dev;
|
||||
proxy_set_header X-MS-Forwarded-Client-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
client_body_buffer_size 128k;
|
||||
proxy_connect_timeout 90;
|
||||
proxy_send_timeout 120;
|
||||
proxy_read_timeout 300;
|
||||
proxy_buffer_size 128k;
|
||||
proxy_buffers 4 256k;
|
||||
proxy_busy_buffers_size 256k;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
server_tokens off;
|
||||
|
||||
server {
|
||||
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
{% for server in webserver %}
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name {{ server.domain }};
|
||||
ssl_certificate /etc/letsencrypt/live/{{ server.domain }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ server.domain }}/privkey.pem;
|
||||
{% if server.bigrequests %}
|
||||
client_max_body_size 8G;
|
||||
{% endif %}
|
||||
location /{
|
||||
{% if server.https %}
|
||||
proxy_pass https://127.0.0.1:{{ server.port }};
|
||||
{% else %}
|
||||
proxy_pass http://127.0.0.1:{{ server.port }};
|
||||
{% endif %}
|
||||
}
|
||||
location /metrics{
|
||||
{%- if server.https %}
|
||||
proxy_pass https://127.0.0.1:{{ server.port }};
|
||||
{% else %}
|
||||
proxy_pass http://127.0.0.1:{{ server.port }};
|
||||
{% endif %}
|
||||
allow 192.168.69.0/24;
|
||||
deny all;
|
||||
}
|
||||
{% if server.additionallocations is defined %}
|
||||
{% for location in server.additionallocations %}
|
||||
location {{location.location}}{
|
||||
{% if location.https %}
|
||||
proxy_pass https://127.0.0.1:{{ location.port }};
|
||||
{% else %}
|
||||
proxy_pass http://127.0.0.1:{{ location.port }};
|
||||
{% endif %}
|
||||
}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
{%- endfor -%}
|
||||
|
||||
server {
|
||||
listen 8888;
|
||||
|
||||
location /stub_status {
|
||||
stub_status;
|
||||
allow 127.0.0.1;
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
}
|
5
run.sh
5
run.sh
@ -1,4 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
ansible-galaxy collection install -r requirements.yaml
|
||||
ansible-playbook --ask-become-pass -i inventory.yaml test.yaml
|
||||
#ansible-playbook --ask-become-pass --ask-pass -i inventory.yaml $1
|
||||
ANSIBLE_CONFIG="$SCRIPT_DIR/ansible.cfg" ansible-playbook -i inventory.yaml $1
|
||||
|
8
webserver-refresh.yaml
Normal file
8
webserver-refresh.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: "Deploy managed web gateway"
|
||||
hosts: webgateway
|
||||
roles:
|
||||
- common
|
||||
- webgateway
|
||||
- internalsmtp
|
||||
...
|
Reference in New Issue
Block a user