Compare commits
141 Commits
2776cfcadf
...
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 |
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
|
||||||
|
...
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
.vault_password_file
|
.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,4 +1,8 @@
|
|||||||
---
|
---
|
||||||
ansible_become: true
|
ansible_become: true
|
||||||
ansible_user: ansible
|
ansible_user: ansible@intra.tormakris.dev
|
||||||
|
#ansible_user: ansible
|
||||||
|
allowedranges:
|
||||||
|
- 192.168.69.0/24
|
||||||
|
- 192.168.1.0/24
|
||||||
...
|
...
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
netplan:
|
netplan:
|
||||||
default_gateway: "192.168.69.254"
|
default_gateway: "192.168.69.253"
|
||||||
...
|
...
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
netplan:
|
netplan:
|
||||||
default_gateway: "192.168.69.1"
|
default_gateway: "192.168.69.253"
|
||||||
...
|
...
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
---
|
---
|
||||||
ansible_host: bitwarden.intra.tormakris.dev
|
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
|
||||||
|
...
|
@ -1,3 +1,8 @@
|
|||||||
---
|
---
|
||||||
ansible_host: drone.intra.tormakris.dev
|
ansible_host: drone.intra.tormakris.dev
|
||||||
|
webserver:
|
||||||
|
- domain: "drone.kmlabz.com"
|
||||||
|
port: 8080
|
||||||
|
bigrequests: false
|
||||||
|
https: false
|
||||||
...
|
...
|
||||||
|
@ -12,4 +12,9 @@ firewall:
|
|||||||
- port: "2222"
|
- port: "2222"
|
||||||
proto: tcp
|
proto: tcp
|
||||||
interface: "eth0"
|
interface: "eth0"
|
||||||
|
webserver:
|
||||||
|
- domain: "git.kmlabz.com"
|
||||||
|
port: 8080
|
||||||
|
bigrequests: false
|
||||||
|
https: false
|
||||||
...
|
...
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
---
|
---
|
||||||
ansible_host: guacamole.intra.tormakris.dev
|
ansible_host: guacamole.intra.tormakris.dev
|
||||||
|
webserver:
|
||||||
|
- domain: "guacamole.tormakristof.eu"
|
||||||
|
port: 8080
|
||||||
|
bigrequests: false
|
||||||
|
https: false
|
||||||
...
|
...
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
ansible_host: keycloak.intra.tormakris.dev
|
|
||||||
...
|
|
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
|
||||||
|
...
|
@ -6,21 +6,23 @@ firewall:
|
|||||||
interface: "eth0"
|
interface: "eth0"
|
||||||
- port: "http"
|
- port: "http"
|
||||||
proto: tcp
|
proto: tcp
|
||||||
interface: "eth1"
|
interface: "eth0"
|
||||||
- port: "https"
|
- port: "https"
|
||||||
proto: tcp
|
proto: tcp
|
||||||
interface: "eth1"
|
interface: "eth0"
|
||||||
- port: "ssh"
|
- port: "59000:59009"
|
||||||
proto: tcp
|
|
||||||
interface: "eth1"
|
|
||||||
- port: "59000:59049"
|
|
||||||
proto: udp
|
proto: udp
|
||||||
interface: "eth1"
|
interface: "eth0"
|
||||||
netplan:
|
- port: "3478"
|
||||||
default_gateway: ""
|
proto: tcp
|
||||||
additionalinterfaces:
|
interface: "eth0"
|
||||||
- name: "eth1"
|
- port: "3478"
|
||||||
dhcp4: true
|
proto: any
|
||||||
dhcp6: true
|
interface: "eth0"
|
||||||
denydns: true
|
- port: "5349"
|
||||||
|
proto: any
|
||||||
|
interface: "eth0"
|
||||||
|
- port: "9101"
|
||||||
|
proto: tcp
|
||||||
|
interface: "eth0"
|
||||||
...
|
...
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
---
|
---
|
||||||
ansible_host: nextcloud.intra.tormakris.dev
|
ansible_host: nextcloud.intra.tormakris.dev
|
||||||
|
webserver:
|
||||||
|
- domain: "nextcloud.tormakristof.eu"
|
||||||
|
port: 8080
|
||||||
|
bigrequests: true
|
||||||
|
https: false
|
||||||
...
|
...
|
||||||
|
@ -3,6 +3,10 @@ ansible_host: nexus.intra.tormakris.dev
|
|||||||
webserver:
|
webserver:
|
||||||
- domain: "nexus.kmlabz.com"
|
- domain: "nexus.kmlabz.com"
|
||||||
port: 8080
|
port: 8080
|
||||||
|
bigrequests: true
|
||||||
|
https: false
|
||||||
- domain: "registry.kmlabz.com"
|
- domain: "registry.kmlabz.com"
|
||||||
port: 4269
|
port: 4269
|
||||||
|
bigrequests: true
|
||||||
|
https: false
|
||||||
...
|
...
|
||||||
|
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::'
|
||||||
|
...
|
@ -5,6 +5,9 @@ firewall:
|
|||||||
- port: "5432"
|
- port: "5432"
|
||||||
proto: tcp
|
proto: tcp
|
||||||
interface: "eth0"
|
interface: "eth0"
|
||||||
|
- port: "9187"
|
||||||
|
proto: tcp
|
||||||
|
interface: "eth0"
|
||||||
backup:
|
backup:
|
||||||
folder: "/var/lib/postgresql/backup"
|
folder: "/var/lib/postgresql/backup"
|
||||||
tarfolder: "backup"
|
tarfolder: "backup"
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
ansible_host: sonar.intra.tormakris.dev
|
|
||||||
...
|
|
@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
ansible_host: swagger.intra.tormakris.dev
|
|
||||||
...
|
|
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)/'
|
||||||
|
...
|
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
|
||||||
|
...
|
18
infra.yaml
18
infra.yaml
@ -13,7 +13,6 @@
|
|||||||
roles:
|
roles:
|
||||||
- netplan
|
- netplan
|
||||||
- common
|
- common
|
||||||
- customfirewall
|
|
||||||
- backupscript
|
- backupscript
|
||||||
- customfirewall
|
- customfirewall
|
||||||
|
|
||||||
@ -41,7 +40,6 @@
|
|||||||
roles:
|
roles:
|
||||||
- common
|
- common
|
||||||
- docker
|
- docker
|
||||||
- neko
|
|
||||||
- customfirewall
|
- customfirewall
|
||||||
- internalsmtp
|
- internalsmtp
|
||||||
|
|
||||||
@ -67,4 +65,20 @@
|
|||||||
- internalsmtp
|
- internalsmtp
|
||||||
- backupscript
|
- backupscript
|
||||||
- backuphost
|
- backuphost
|
||||||
|
|
||||||
|
- name: "Deploy OpenVPN server"
|
||||||
|
hosts: openvpn
|
||||||
|
roles:
|
||||||
|
- netplan
|
||||||
|
- common
|
||||||
|
- openvpn
|
||||||
|
- customfirewall
|
||||||
|
- internalsmtp
|
||||||
|
|
||||||
|
- name: "Deploy Game server"
|
||||||
|
hosts: gameservers
|
||||||
|
roles:
|
||||||
|
- netplan
|
||||||
|
- common
|
||||||
|
- internalsmtp
|
||||||
...
|
...
|
@ -5,8 +5,7 @@ all:
|
|||||||
hosts:
|
hosts:
|
||||||
neko:
|
neko:
|
||||||
drone:
|
drone:
|
||||||
keycloak:
|
matrix:
|
||||||
swagger:
|
|
||||||
drone-runner:
|
drone-runner:
|
||||||
smtp:
|
smtp:
|
||||||
webgateway:
|
webgateway:
|
||||||
@ -14,19 +13,43 @@ all:
|
|||||||
nexus:
|
nexus:
|
||||||
git:
|
git:
|
||||||
postgres:
|
postgres:
|
||||||
|
monitoring:
|
||||||
|
ytmirror:
|
||||||
|
cloudlog:
|
||||||
|
unbound:
|
||||||
mckay:
|
mckay:
|
||||||
hosts:
|
hosts:
|
||||||
guacamole:
|
guacamole:
|
||||||
bitwarden:
|
bitwarden:
|
||||||
nextcloud:
|
nextcloud:
|
||||||
backup:
|
backup:
|
||||||
|
librespeed:
|
||||||
|
plex:
|
||||||
dockerwebhosts:
|
dockerwebhosts:
|
||||||
keycloak:
|
hosts:
|
||||||
|
matrix:
|
||||||
drone:
|
drone:
|
||||||
swagger:
|
|
||||||
guacamole:
|
guacamole:
|
||||||
bitwarden:
|
bitwarden:
|
||||||
nexus:
|
nexus:
|
||||||
nextcloud:
|
nextcloud:
|
||||||
neko:
|
monitoring:
|
||||||
|
ytmirror:
|
||||||
|
librespeed:
|
||||||
|
plex:
|
||||||
|
cloudlog:
|
||||||
|
nightlydocker:
|
||||||
|
hosts:
|
||||||
|
matrix:
|
||||||
|
guacamole:
|
||||||
|
bitwarden:
|
||||||
|
nexus:
|
||||||
|
nextcloud:
|
||||||
|
monitoring:
|
||||||
|
ytmirror:
|
||||||
|
librespeed:
|
||||||
|
plex:
|
||||||
|
cloudlog:
|
||||||
|
gameservers:
|
||||||
|
hosts:
|
||||||
...
|
...
|
||||||
|
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,44 +1,11 @@
|
|||||||
|
# TODO: Make backup user part of AD
|
||||||
---
|
---
|
||||||
- name: "Add backup user"
|
- name: "Add backup user"
|
||||||
ansible.builtin.user:
|
user:
|
||||||
name: backup
|
name: backup
|
||||||
comment: Backup user
|
comment: Backup user
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
|
|
||||||
- name: "Dsiable service user"
|
|
||||||
ansible.builtin.user:
|
|
||||||
name: service-user
|
|
||||||
state: present
|
|
||||||
password_lock: true
|
|
||||||
shell: "/sbin/nologin"
|
|
||||||
|
|
||||||
- name: Undefine AllowUsers
|
|
||||||
lineinfile:
|
|
||||||
state: absent
|
|
||||||
path: /etc/ssh/sshd_config
|
|
||||||
line: "AllowUsers tormakris ansible service-user"
|
|
||||||
|
|
||||||
- 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 backup"
|
|
||||||
when: checkallowusers.found == 0
|
|
||||||
|
|
||||||
- name: "Restart sshd"
|
|
||||||
service:
|
|
||||||
name: sshd
|
|
||||||
state: restarted
|
|
||||||
|
|
||||||
- name: Create .ssh directory of backup user
|
- name: Create .ssh directory of backup user
|
||||||
file:
|
file:
|
||||||
path: /home/backup/.ssh
|
path: /home/backup/.ssh
|
||||||
|
@ -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
|
|
@ -1,55 +1,12 @@
|
|||||||
---
|
---
|
||||||
- name: "Generate backupscript"
|
- name: "Generate backupscript"
|
||||||
ansible.builtin.template:
|
template:
|
||||||
src: backupscript.sh
|
src: backupscript.sh
|
||||||
dest: /opt/backupscript.sh
|
dest: /etc/cron.weekly/backupscript
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0700'
|
mode: '0700'
|
||||||
|
|
||||||
- name: Copy backup-script.service to target
|
|
||||||
copy:
|
|
||||||
src: backup-script.service
|
|
||||||
dest: /usr/lib/systemd/system/backup-script.service
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- name: Copy backup.target to target
|
|
||||||
copy:
|
|
||||||
src: backup.target
|
|
||||||
dest: /usr/lib/systemd/system/backup.target
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- name: Copy backup.timer to target
|
|
||||||
copy:
|
|
||||||
src: backup.timer
|
|
||||||
dest: /usr/lib/systemd/system/backup.timer
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: Create .ssh directory of root user
|
- name: Create .ssh directory of root user
|
||||||
file:
|
file:
|
||||||
path: /root/.ssh
|
path: /root/.ssh
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
# defaults file for timedatectl
|
# 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'
|
timedatectl_timezone: 'Europe/Budapest'
|
||||||
...
|
...
|
||||||
|
@ -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"
|
- name: "Remove Ubuntu bloatware"
|
||||||
apt:
|
apt:
|
||||||
state: absent
|
state: absent
|
||||||
@ -35,4 +42,6 @@
|
|||||||
- tcpdump
|
- tcpdump
|
||||||
- xxd
|
- xxd
|
||||||
- git
|
- git
|
||||||
|
- ncdu
|
||||||
|
- cron
|
||||||
...
|
...
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
- name: clean motd
|
- name: clean motd
|
||||||
file:
|
file:
|
||||||
state: touch
|
state: touch
|
||||||
owner: tormakris
|
owner: tormakris@intra.tormakris.dev
|
||||||
group: tormakris
|
group: domain users@intra.tormakris.dev
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
path: /home/tormakris/.hushlogin
|
path: /home/tormakris@intra.tormakris.dev/.hushlogin
|
||||||
...
|
...
|
||||||
|
@ -7,4 +7,5 @@
|
|||||||
- include_tasks: user-ops.yaml
|
- include_tasks: user-ops.yaml
|
||||||
- include_tasks: ssh-security-settings.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
|
||||||
|
...
|
@ -1,10 +1,4 @@
|
|||||||
---
|
---
|
||||||
- name: Disable password authentication
|
|
||||||
replace:
|
|
||||||
path: /etc/ssh/sshd_config
|
|
||||||
regexp: 'PasswordAuthentication yes'
|
|
||||||
replace: 'PasswordAuthentication no'
|
|
||||||
|
|
||||||
- name: Disable root authentication
|
- name: Disable root authentication
|
||||||
replace:
|
replace:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
@ -23,22 +17,6 @@
|
|||||||
regexp: '#AddressFamily any'
|
regexp: '#AddressFamily any'
|
||||||
replace: 'AddressFamily inet'
|
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"
|
- name: "Restart sshd"
|
||||||
service:
|
service:
|
||||||
name: sshd
|
name: sshd
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
- name: Reastart timesyncd to apply changes
|
- name: Reastart timesyncd to apply changes
|
||||||
when: ansible_service_mgr == "systemd"
|
when: ansible_service_mgr == "systemd"
|
||||||
ansible.builtin.systemd:
|
systemd:
|
||||||
state: restarted
|
state: restarted
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
name: systemd-timesyncd
|
name: systemd-timesyncd
|
||||||
|
@ -18,4 +18,6 @@
|
|||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
rule: allow
|
rule: allow
|
||||||
port: ssh
|
port: ssh
|
||||||
|
src: "{{ item }}"
|
||||||
|
with_items: "{{ allowedranges }}"
|
||||||
...
|
...
|
||||||
|
@ -1,57 +1,38 @@
|
|||||||
---
|
---
|
||||||
- name: "Add service user"
|
- name: Create .ssh directory of ansible user
|
||||||
ansible.builtin.user:
|
|
||||||
name: service-user
|
|
||||||
comment: Service user
|
|
||||||
shell: /bin/bash
|
|
||||||
|
|
||||||
- name: "Add ansible user"
|
|
||||||
ansible.builtin.user:
|
|
||||||
name: ansible
|
|
||||||
comment: Ansible
|
|
||||||
shell: /bin/bash
|
|
||||||
|
|
||||||
- name: "Add ansible user to sudo group"
|
|
||||||
ansible.builtin.user:
|
|
||||||
name: ansible
|
|
||||||
comment: Ansible
|
|
||||||
groups: sudo
|
|
||||||
append: yes
|
|
||||||
|
|
||||||
- name: Create .ssh directory of root user
|
|
||||||
file:
|
file:
|
||||||
path: /home/ansible/.ssh
|
path: /home/ansible@intra.tormakris.dev/.ssh
|
||||||
state: directory
|
state: directory
|
||||||
owner: ansible
|
owner: ansible@intra.tormakris.dev
|
||||||
group: ansible
|
group: domain users@intra.tormakris.dev
|
||||||
|
|
||||||
- name: Copy authorized_keys
|
- name: Copy authorized_keys
|
||||||
copy:
|
copy:
|
||||||
src: authorized_keys
|
src: authorized_keys
|
||||||
dest: /home/ansible/.ssh/authorized_keys
|
dest: /home/ansible@intra.tormakris.dev/.ssh/authorized_keys
|
||||||
mode: 0600
|
mode: 0600
|
||||||
owner: ansible
|
owner: ansible@intra.tormakris.dev
|
||||||
group: ansible
|
group: domain users@intra.tormakris.dev
|
||||||
|
|
||||||
- name: Check if ansible is already nopasswd in sudoers
|
- name: Check if group is present in sudoers
|
||||||
lineinfile:
|
lineinfile:
|
||||||
state: absent
|
state: absent
|
||||||
path: /etc/sudoers
|
path: /etc/sudoers
|
||||||
regexp: "^ansible"
|
regexp: "^%linuxadmins"
|
||||||
check_mode: true
|
check_mode: true
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: checkallowusers
|
register: checksudoers
|
||||||
|
|
||||||
- name: Define ansible nopasswd in sudoers
|
- name: Define group in sudoers
|
||||||
lineinfile:
|
lineinfile:
|
||||||
state: present
|
state: present
|
||||||
path: /etc/sudoers
|
path: /etc/sudoers
|
||||||
line: "ansible ALL=(ALL:ALL) NOPASSWD:ALL"
|
line: "%linuxadmins@intra.tormakris.dev ALL=(ALL) NOPASSWD: ALL"
|
||||||
when: checkallowusers.found == 0
|
when: checksudoers.found == 0
|
||||||
|
|
||||||
- name: "Update authorized_keys of tormakris"
|
- name: "Update authorized_keys of tormakris"
|
||||||
ansible.posix.authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: tormakris
|
user: tormakris@intra.tormakris.dev
|
||||||
state: present
|
state: present
|
||||||
key: https://static.tormakristof.eu/ssh.keys
|
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 }}
|
@ -1,3 +1,7 @@
|
|||||||
{
|
{
|
||||||
"userland-proxy": false
|
"userland-proxy": false,
|
||||||
|
"dns": [
|
||||||
|
"192.168.69.3",
|
||||||
|
"192.168.69.18"
|
||||||
|
]
|
||||||
}
|
}
|
@ -22,9 +22,15 @@
|
|||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
- name: "Add service user to docker group"
|
- name: "Add service user to docker group"
|
||||||
ansible.builtin.user:
|
user:
|
||||||
name: service-user
|
name: service-user@intra.tormakris.dev
|
||||||
comment: Service user
|
|
||||||
groups: docker
|
groups: docker
|
||||||
append: yes
|
append: yes
|
||||||
|
|
||||||
|
- name: Allow docker exporter via ufw
|
||||||
|
community.general.ufw:
|
||||||
|
rule: allow
|
||||||
|
port: "4194"
|
||||||
|
proto: tcp
|
||||||
|
src: 192.168.69.0/24
|
||||||
...
|
...
|
||||||
|
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,4 +16,38 @@
|
|||||||
name: postfix
|
name: postfix
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
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,4 +0,0 @@
|
|||||||
---
|
|
||||||
datadog:
|
|
||||||
apikey: ""
|
|
||||||
...
|
|
@ -1,4 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
systemctl stop haproxy
|
|
||||||
certbot renew --standalone --cert-name neko.tormakristof.eu
|
|
||||||
systemctl start haproxy
|
|
@ -1 +0,0 @@
|
|||||||
deb [signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] https://apt.datadoghq.com/ stable 7
|
|
@ -1,55 +0,0 @@
|
|||||||
global
|
|
||||||
log /dev/log local0
|
|
||||||
log /dev/log local1 notice
|
|
||||||
chroot /var/lib/haproxy
|
|
||||||
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
|
|
||||||
stats timeout 30s
|
|
||||||
user haproxy
|
|
||||||
group haproxy
|
|
||||||
daemon
|
|
||||||
|
|
||||||
# Default SSL material locations
|
|
||||||
ca-base /etc/ssl/certs
|
|
||||||
crt-base /etc/ssl/private
|
|
||||||
|
|
||||||
# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
|
|
||||||
ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
|
|
||||||
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
|
|
||||||
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
|
|
||||||
|
|
||||||
defaults
|
|
||||||
log global
|
|
||||||
mode http
|
|
||||||
option httplog
|
|
||||||
option dontlognull
|
|
||||||
timeout connect 5000
|
|
||||||
timeout client 50000
|
|
||||||
timeout server 50000
|
|
||||||
errorfile 400 /etc/haproxy/errors/400.http
|
|
||||||
errorfile 403 /etc/haproxy/errors/403.http
|
|
||||||
errorfile 408 /etc/haproxy/errors/408.http
|
|
||||||
errorfile 500 /etc/haproxy/errors/500.http
|
|
||||||
errorfile 502 /etc/haproxy/errors/502.http
|
|
||||||
errorfile 503 /etc/haproxy/errors/503.http
|
|
||||||
errorfile 504 /etc/haproxy/errors/504.http
|
|
||||||
|
|
||||||
frontend http-in
|
|
||||||
bind *:80
|
|
||||||
mode http
|
|
||||||
redirect scheme https code 301
|
|
||||||
|
|
||||||
frontend https-front
|
|
||||||
bind :443
|
|
||||||
mode tcp
|
|
||||||
use_backend https-back
|
|
||||||
|
|
||||||
backend https-back
|
|
||||||
mode tcp
|
|
||||||
balance roundrobin
|
|
||||||
server docker 127.0.0.1:8080 check
|
|
||||||
|
|
||||||
listen stats # Define a listen section called "stats"
|
|
||||||
bind 127.0.0.1:9000 # Listen on localhost:9000
|
|
||||||
mode http
|
|
||||||
stats enable # Enable stats page
|
|
||||||
stats uri /haproxy_stats # Stats URI
|
|
@ -1,78 +0,0 @@
|
|||||||
---
|
|
||||||
- name: "Install haproxy via apt"
|
|
||||||
apt:
|
|
||||||
update_cache: yes
|
|
||||||
state: present
|
|
||||||
name:
|
|
||||||
- haproxy
|
|
||||||
|
|
||||||
- name: Copy haproxy configuration
|
|
||||||
copy:
|
|
||||||
src: haproxy.cfg
|
|
||||||
dest: /etc/haproxy/haproxy.cfg
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- name: Enable and stop haproxy
|
|
||||||
service:
|
|
||||||
name: haproxy
|
|
||||||
state: stopped
|
|
||||||
enabled: yes
|
|
||||||
|
|
||||||
- name: "Install certbot via apt"
|
|
||||||
apt:
|
|
||||||
update_cache: yes
|
|
||||||
state: present
|
|
||||||
name:
|
|
||||||
- python3-certbot
|
|
||||||
|
|
||||||
- name: Generate certificate for all proxied domains
|
|
||||||
command:
|
|
||||||
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --standalone -d neko.tormakristof.eu
|
|
||||||
|
|
||||||
- name: Enable and start haproxy
|
|
||||||
service:
|
|
||||||
name: haproxy
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
||||||
|
|
||||||
- name: Copy certbot cronjob
|
|
||||||
copy:
|
|
||||||
src: certbot
|
|
||||||
dest: /etc/cron.weekly/certbot
|
|
||||||
mode: 0755
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- name: Reset ufw rules to default
|
|
||||||
community.general.ufw:
|
|
||||||
state: reset
|
|
||||||
|
|
||||||
- name: Enable ufw
|
|
||||||
community.general.ufw:
|
|
||||||
state: enabled
|
|
||||||
|
|
||||||
- name: Copy datadog repo config
|
|
||||||
copy:
|
|
||||||
src: datadog.list
|
|
||||||
dest: /etc/apt/sources.list.d/datadog.list
|
|
||||||
mode: 0655
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- name: "Install datadog-agent"
|
|
||||||
apt:
|
|
||||||
update_cache: yes
|
|
||||||
state: present
|
|
||||||
name:
|
|
||||||
- datadog-agent
|
|
||||||
|
|
||||||
- name: "Generate datadog configuration"
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: datadog.yaml
|
|
||||||
dest: /etc/datadog-agent/datadog.yaml
|
|
||||||
owner: dd-agent
|
|
||||||
group: dd-agent
|
|
||||||
mode: '0640'
|
|
||||||
...
|
|
File diff suppressed because it is too large
Load Diff
@ -6,9 +6,9 @@ network:
|
|||||||
{{ ansible_default_ipv4.interface }}:
|
{{ ansible_default_ipv4.interface }}:
|
||||||
dhcp4: true
|
dhcp4: true
|
||||||
dhcp-identifier: mac
|
dhcp-identifier: mac
|
||||||
|
{% if netplan.default_gateway is defined and netplan.default_gateway|length > 0 %}
|
||||||
dhcp4-overrides:
|
dhcp4-overrides:
|
||||||
use-routes: false
|
use-routes: false
|
||||||
{% if netplan.default_gateway is defined and netplan.default_gateway|length > 0 %}
|
|
||||||
gateway4: {{netplan.default_gateway}}
|
gateway4: {{netplan.default_gateway}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if netplan.additionalinterfaces is defined and netplan.additionalinterfaces|length > 0 %}
|
{% if netplan.additionalinterfaces is defined and netplan.additionalinterfaces|length > 0 %}
|
||||||
@ -29,7 +29,7 @@ network:
|
|||||||
gateway4: {{interface.gateway4}}
|
gateway4: {{interface.gateway4}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if interface.gateway6 is defined and interface.gateway6|length > 0 %}
|
{% if interface.gateway6 is defined and interface.gateway6|length > 0 %}
|
||||||
gateway4: {{interface.gateway6}}
|
gateway6: '{{interface.gateway6}}'
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if interface.denydns %}
|
{% if interface.denydns %}
|
||||||
nameservers:
|
nameservers:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
update_cache: yes
|
update_cache: yes
|
||||||
state: present
|
state: present
|
||||||
name:
|
name:
|
||||||
- openvpn-server
|
- openvpn
|
||||||
|
|
||||||
- name : "Enable ipv4 forwarding via sysctl"
|
- name : "Enable ipv4 forwarding via sysctl"
|
||||||
ansible.posix.sysctl:
|
ansible.posix.sysctl:
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
- name: Enable and restart openvpn daemon
|
- name: Enable and restart openvpn daemon
|
||||||
service:
|
service:
|
||||||
name: openvpn
|
name: openvpn-server@stargate
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
|
||||||
@ -36,14 +36,29 @@
|
|||||||
# START OPENVPN RULES
|
# START OPENVPN RULES
|
||||||
# NAT table rules
|
# NAT table rules
|
||||||
*nat
|
*nat
|
||||||
|
-F
|
||||||
:POSTROUTING ACCEPT [0:0]
|
:POSTROUTING ACCEPT [0:0]
|
||||||
# Allow traffic from OpenVPN client to everywhere
|
# 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 eth0 -j MASQUERADE
|
||||||
-A POSTROUTING -s 192.168.37.0/24 -o eth2 -j MASQUERADE
|
-A POSTROUTING -s 192.168.37.0/24 -o eth2 -j MASQUERADE
|
||||||
COMMIT
|
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
|
# END OPENVPN RULES
|
||||||
|
|
||||||
- name: Reload ufw
|
- name: Reload ufw
|
||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Apply custom ufw rules
|
||||||
|
community.general.ufw:
|
||||||
|
rule: allow
|
||||||
|
direction: "in"
|
||||||
|
interface: tun0
|
||||||
...
|
...
|
||||||
|
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,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
postfix_relayhost: 'smtp-relay.gmail.com'
|
postfix_relayhost: 'tormakris-dev.mail.protection.outlook.com'
|
||||||
external_domain: 'tormakris.dev'
|
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")
|
@ -12,7 +12,8 @@
|
|||||||
dest: /etc/postfix/main.cf
|
dest: /etc/postfix/main.cf
|
||||||
|
|
||||||
- name: Build /etc/mailname
|
- name: Build /etc/mailname
|
||||||
shell: hostname --fqdn > /etc/mailname
|
shell:
|
||||||
|
cmd: "hostname --fqdn > /etc/mailname"
|
||||||
|
|
||||||
- name: Restart Postfix
|
- name: Restart Postfix
|
||||||
service:
|
service:
|
||||||
@ -24,4 +25,39 @@
|
|||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
rule: allow
|
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
|
||||||
...
|
...
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Renew certificates with certbot
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
ExecStart=/usr/bin/bash /opt/certbot.sh
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=certbot.target
|
|
@ -1,5 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Script based certificate renewal via certbot
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target
|
|
@ -1,10 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Periodic certificate renewal
|
|
||||||
|
|
||||||
[Timer]
|
|
||||||
OnBootSec=10min
|
|
||||||
OnCalendar=Sun *-*-* 00:00:00
|
|
||||||
Unit=certbot.target
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
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"
|
@ -19,7 +19,7 @@
|
|||||||
port: https
|
port: https
|
||||||
|
|
||||||
- name: Copy default nginx config
|
- name: Copy default nginx config
|
||||||
ansible.builtin.copy:
|
copy:
|
||||||
src: nginx.conf
|
src: nginx.conf
|
||||||
dest: /etc/nginx/nginx.conf
|
dest: /etc/nginx/nginx.conf
|
||||||
owner: root
|
owner: root
|
||||||
@ -42,61 +42,21 @@
|
|||||||
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
|
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
|
||||||
with_items: "{{ static }}"
|
with_items: "{{ static }}"
|
||||||
|
|
||||||
- name: Generate certificate for all static sites
|
- name: Generate certificate for all redirect sites
|
||||||
command:
|
command:
|
||||||
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
|
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
|
||||||
with_items: "{{ redirect }}"
|
with_items: "{{ redirect }}"
|
||||||
|
|
||||||
- name: "Generate certbot script"
|
- name: "Generate certbot script"
|
||||||
ansible.builtin.template:
|
template:
|
||||||
src: certbot.sh
|
src: certbot.sh
|
||||||
dest: /opt/certbot.sh
|
dest: /etc/cron.weekly/certbot
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0700'
|
mode: '0700'
|
||||||
|
|
||||||
- name: Copy certbot-script.service to target
|
|
||||||
copy:
|
|
||||||
src: certbot-script.service
|
|
||||||
dest: /usr/lib/systemd/system/certbot-script.service
|
|
||||||
mode: 644
|
|
||||||
owner: root
|
|
||||||
|
|
||||||
- name: Copy certbot.target to target
|
|
||||||
copy:
|
|
||||||
src: certbot.target
|
|
||||||
dest: /usr/lib/systemd/system/certbot.target
|
|
||||||
mode: 644
|
|
||||||
owner: root
|
|
||||||
|
|
||||||
- name: Copy certbot.timer to target
|
|
||||||
copy:
|
|
||||||
src: certbot.timer
|
|
||||||
dest: /usr/lib/systemd/system/certbot.timer
|
|
||||||
mode: 644
|
|
||||||
owner: root
|
|
||||||
|
|
||||||
- name: Enable certbot-script.service and reload systemd daemon
|
|
||||||
when: ansible_service_mgr == "systemd"
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
name: certbot-script.service
|
|
||||||
|
|
||||||
- name: Enable certbot.target
|
|
||||||
when: ansible_service_mgr == "systemd"
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
enabled: yes
|
|
||||||
name: certbot.target
|
|
||||||
|
|
||||||
- name: Enable certbot.timer
|
|
||||||
when: ansible_service_mgr == "systemd"
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
enabled: yes
|
|
||||||
name: certbot.timer
|
|
||||||
|
|
||||||
- name: "Generate nginx configuration"
|
- name: "Generate nginx configuration"
|
||||||
ansible.builtin.template:
|
template:
|
||||||
src: nginx.conf
|
src: nginx.conf
|
||||||
dest: /etc/nginx/nginx.conf
|
dest: /etc/nginx/nginx.conf
|
||||||
owner: root
|
owner: root
|
||||||
@ -113,20 +73,48 @@
|
|||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
||||||
- name: "Remove any existing static file directories"
|
- name: "Remove any existing static file directories"
|
||||||
ansible.builtin.file:
|
file:
|
||||||
path: "{{ item.directory }}"
|
path: "{{ item.directory }}"
|
||||||
state: absent
|
state: absent
|
||||||
with_items: "{{ static }}"
|
with_items: "{{ static }}"
|
||||||
|
|
||||||
- name: "Checkout static websites from git"
|
- name: "Checkout static websites from git"
|
||||||
ansible.builtin.git:
|
git:
|
||||||
repo: "{{ item.repo }}"
|
repo: "{{ item.repo }}"
|
||||||
dest: "{{ item.directory }}"
|
dest: "{{ item.directory }}"
|
||||||
with_items: "{{ static }}"
|
with_items: "{{ static }}"
|
||||||
|
|
||||||
- name: "Remove .git directory from static websites"
|
- name: "Remove .git directory from static websites"
|
||||||
ansible.builtin.file:
|
file:
|
||||||
path: "{{ item.directory }}/.git"
|
path: "{{ item.directory }}/.git"
|
||||||
state: absent
|
state: absent
|
||||||
with_items: "{{ static }}"
|
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
|
||||||
...
|
...
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# {{ansible_managed}}
|
# {{ansible_managed}}
|
||||||
|
certbot renew --nginx --cert-name tormakristof.eu
|
||||||
{% for proxysite in proxy %}
|
{% for proxysite in proxy %}
|
||||||
certbot renew --nginx --cert-name {{ proxysite.domain }}
|
certbot renew --nginx --cert-name {{ proxysite.domain }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# {{ansible_managed}}
|
# {{ ansible_managed }}
|
||||||
user www-data;
|
user www-data;
|
||||||
worker_processes auto;
|
worker_processes auto;
|
||||||
pid /run/nginx.pid;
|
pid /run/nginx.pid;
|
||||||
@ -40,11 +40,13 @@ http {
|
|||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
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 X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection $http_connection;
|
proxy_set_header Connection $http_connection;
|
||||||
proxy_set_header X-Forwarded-Proto https;
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
client_max_body_size 10m;
|
proxy_ssl_server_name on;
|
||||||
client_body_buffer_size 128k;
|
client_body_buffer_size 128k;
|
||||||
proxy_connect_timeout 90;
|
proxy_connect_timeout 90;
|
||||||
proxy_send_timeout 120;
|
proxy_send_timeout 120;
|
||||||
@ -54,6 +56,7 @@ http {
|
|||||||
proxy_busy_buffers_size 256k;
|
proxy_busy_buffers_size 256k;
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
proxy_request_buffering off;
|
proxy_request_buffering off;
|
||||||
|
server_tokens off;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
|
||||||
@ -63,22 +66,35 @@ http {
|
|||||||
return 301 https://$host$request_uri;
|
return 301 https://$host$request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
{% for proxysite in proxy %}
|
{%- for proxysite in proxy -%}
|
||||||
server {
|
server {
|
||||||
listen 443 ssl http2;
|
listen 443 ssl http2;
|
||||||
listen [::]:443 ssl http2;
|
listen [::]:443 ssl http2;
|
||||||
server_name {{ proxysite.domain }};
|
server_name {{ proxysite.domain }};
|
||||||
|
proxy_ssl_name {{ proxysite.domain }};
|
||||||
ssl_certificate /etc/letsencrypt/live/{{ proxysite.domain }}/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/{{ proxysite.domain }}/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/{{ proxysite.domain }}/privkey.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 /{
|
location /{
|
||||||
proxy_pass https://{{ proxysite.ip }};
|
proxy_pass https://{{ proxysite.ip }};
|
||||||
|
{%- if proxysite.ignorecert %}
|
||||||
proxy_ssl_verify off;
|
proxy_ssl_verify off;
|
||||||
|
{%- endif %}
|
||||||
|
}
|
||||||
|
location /metrics{
|
||||||
|
proxy_pass https://{{ proxysite.ip }};
|
||||||
|
allow 192.168.69.0/24;
|
||||||
|
deny all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endfor %}
|
{%- endfor -%}
|
||||||
|
|
||||||
{% for staticsite in static %}
|
{%- for staticsite in static -%}
|
||||||
server {
|
server {
|
||||||
listen 443 ssl http2;
|
listen 443 ssl http2;
|
||||||
listen [::]:443 ssl http2;
|
listen [::]:443 ssl http2;
|
||||||
@ -91,9 +107,9 @@ http {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endfor %}
|
{%- endfor -%}
|
||||||
|
|
||||||
{% for redirectsite in redirect %}
|
{%- for redirectsite in redirect -%}
|
||||||
server {
|
server {
|
||||||
listen 443 ssl http2;
|
listen 443 ssl http2;
|
||||||
listen [::]:443 ssl http2;
|
listen [::]:443 ssl http2;
|
||||||
@ -103,5 +119,34 @@ http {
|
|||||||
return 301 {{ redirectsite.destination }};
|
return 301 {{ redirectsite.destination }};
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endfor %}
|
{%- 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,26 @@
|
|||||||
proxy:
|
proxy:
|
||||||
- {domain: bitwarden.tormakristof.eu, ip: bitwarden.intra.tormakris.dev}
|
- {domain: bitwarden.tormakristof.eu, ip: bitwarden.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||||
- {domain: nextcloud.tormakristof.eu, ip: nextcloud.intra.tormakris.dev}
|
- {domain: nextcloud.tormakristof.eu, ip: nextcloud.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||||
- {domain: drone.kmlabz.com, ip: drone.intra.tormakris.dev}
|
- {domain: drone.kmlabz.com, ip: drone.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||||
- {domain: git.kmlabz.com, ip: git.intra.tormakris.dev}
|
- {domain: git.kmlabz.com, ip: git.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||||
- {domain: guacamole.kmlabz.com, ip: guacamole.intra.tormakris.dev}
|
- {domain: guacamole.tormakristof.eu, ip: guacamole.intra.tormakris.dev, bigrequests: false, ignorecert: false}
|
||||||
- {domain: keycloak.kmlabz.com, ip: keycloak.intra.tormakris.dev}
|
- {domain: matrix.tormakristof.eu, ip: matrix.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||||
- {domain: nexus.kmlabz.com, ip: nexus.intra.tormakris.dev}
|
- {domain: chat.tormakristof.eu, ip: matrix.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||||
- {domain: registry.kmlabz.com, ip: nexus.intra.tormakris.dev}
|
- {domain: nexus.kmlabz.com, ip: nexus.intra.tormakris.dev, bigrequests: true, ignorecert: false}
|
||||||
- {domain: swagger.kmlabz.com, ip: swagger.intra.tormakris.dev}
|
- {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:
|
static:
|
||||||
- {domain: kmlabz.com, directory: /var/www/kmlabz.com, repo: "https://git.kmlabz.com/kmlabz/homepage.git"}
|
[]
|
||||||
|
|
||||||
redirect:
|
redirect:
|
||||||
- {domain: tormakristof.eu, destination: "https://www.tormakristof.eu"}
|
[]
|
||||||
- {domain: tormakris.dev, destination: "https://www.tormakristof.eu"}
|
|
||||||
- {domain: torma.xyz, destination: "https://www.tormakristof.eu"}
|
|
||||||
...
|
...
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
webserver:
|
webserver:
|
||||||
- domain: "_"
|
- domain: "_"
|
||||||
port: 8080
|
port: 8080
|
||||||
|
bigrequests: false
|
||||||
|
https: false
|
||||||
...
|
...
|
||||||
|
@ -58,6 +58,15 @@ http {
|
|||||||
# Virtual Host Configs
|
# Virtual Host Configs
|
||||||
##
|
##
|
||||||
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
server {
|
||||||
include /etc/nginx/sites-enabled/*;
|
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,13 +1,22 @@
|
|||||||
---
|
---
|
||||||
|
- name: Allow https port via ufw
|
||||||
|
community.general.ufw:
|
||||||
|
rule: allow
|
||||||
|
port: https
|
||||||
|
src: "{{ item }}"
|
||||||
|
with_items: "{{ allowedranges }}"
|
||||||
|
|
||||||
- name: "Install Nginx via apt"
|
- name: "Install Nginx via apt"
|
||||||
apt:
|
apt:
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
state: present
|
state: present
|
||||||
name:
|
name:
|
||||||
- nginx
|
- nginx
|
||||||
|
- python3-certbot
|
||||||
|
- python3-certbot-dns-cloudflare
|
||||||
|
|
||||||
- name: Copy default nginx config
|
- name: Copy default nginx config
|
||||||
ansible.builtin.copy:
|
copy:
|
||||||
src: nginx.conf
|
src: nginx.conf
|
||||||
dest: /etc/nginx/nginx.conf
|
dest: /etc/nginx/nginx.conf
|
||||||
owner: root
|
owner: root
|
||||||
@ -20,8 +29,34 @@
|
|||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
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"
|
- name: "Generate nginx configuration"
|
||||||
ansible.builtin.template:
|
template:
|
||||||
src: nginx.conf
|
src: nginx.conf
|
||||||
dest: /etc/nginx/nginx.conf
|
dest: /etc/nginx/nginx.conf
|
||||||
owner: root
|
owner: root
|
||||||
@ -33,8 +68,31 @@
|
|||||||
name: nginx
|
name: nginx
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
||||||
- name: Allow https port via ufw
|
- name: "Install nginx exporter"
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
state: present
|
||||||
|
name:
|
||||||
|
- prometheus-nginx-exporter
|
||||||
|
|
||||||
|
- name: Allow nginx exporter via ufw
|
||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
rule: allow
|
rule: allow
|
||||||
port: https
|
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 }}
|
@ -40,10 +40,12 @@ http {
|
|||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
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 X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection $http_connection;
|
proxy_set_header Connection $http_connection;
|
||||||
client_max_body_size 10m;
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
client_body_buffer_size 128k;
|
client_body_buffer_size 128k;
|
||||||
proxy_connect_timeout 90;
|
proxy_connect_timeout 90;
|
||||||
proxy_send_timeout 120;
|
proxy_send_timeout 120;
|
||||||
@ -53,6 +55,7 @@ http {
|
|||||||
proxy_busy_buffers_size 256k;
|
proxy_busy_buffers_size 256k;
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
proxy_request_buffering off;
|
proxy_request_buffering off;
|
||||||
|
server_tokens off;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
|
||||||
@ -67,12 +70,49 @@ http {
|
|||||||
listen 443 ssl http2;
|
listen 443 ssl http2;
|
||||||
listen [::]:443 ssl http2;
|
listen [::]:443 ssl http2;
|
||||||
server_name {{ server.domain }};
|
server_name {{ server.domain }};
|
||||||
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
|
ssl_certificate /etc/letsencrypt/live/{{ server.domain }}/fullchain.pem;
|
||||||
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
|
ssl_certificate_key /etc/letsencrypt/live/{{ server.domain }}/privkey.pem;
|
||||||
|
{% if server.bigrequests %}
|
||||||
|
client_max_body_size 8G;
|
||||||
|
{% endif %}
|
||||||
location /{
|
location /{
|
||||||
|
{% if server.https %}
|
||||||
|
proxy_pass https://127.0.0.1:{{ server.port }};
|
||||||
|
{% else %}
|
||||||
proxy_pass http://127.0.0.1:{{ server.port }};
|
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 %}
|
{%- endfor -%}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 8888;
|
||||||
|
|
||||||
|
location /stub_status {
|
||||||
|
stub_status;
|
||||||
|
allow 127.0.0.1;
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
6
run.sh
6
run.sh
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
ansible-galaxy collection install -r requirements.yaml
|
ansible-galaxy collection install -r requirements.yaml
|
||||||
ansible-playbook --ask-become-pass --ask-pass -i inventory.yaml $1
|
#ansible-playbook --ask-become-pass --ask-pass -i inventory.yaml $1
|
||||||
#ansible-playbook --ask-become-pass -i inventory.yaml $1
|
ANSIBLE_CONFIG="$SCRIPT_DIR/ansible.cfg" ansible-playbook -i inventory.yaml $1
|
||||||
|
Reference in New Issue
Block a user