custom firewall solution

This commit is contained in:
Torma Kristóf 2022-04-16 17:47:49 +02:00
parent 49102eb285
commit 75d7aad012
10 changed files with 50 additions and 50 deletions

View File

@ -8,4 +8,4 @@
- webserver
- internalsmtp
- backupscript
- gitea
- customfirewall

View File

@ -2,4 +2,9 @@
servicename: git
backup:
prearecommand: ""
folder: "/home/git"
folder: "/home/service-user"
tarfolder: "gitea docker-compose.yml"
firewall:
- port: "2222"
proto: tcp
interface: "eth0"

17
host_vars/neko.yaml Normal file
View File

@ -0,0 +1,17 @@
---
firewall:
- port: "ssh"
proto: tcp
interface: "eth0"
- port: "http"
proto: tcp
interface: "eth1"
- port: "https"
proto: tcp
interface: "eth1"
- port: "ssh"
proto: tcp
interface: "eth1"
- port: "59000:59049"
proto: udp
interface: "eth1"

View File

@ -5,4 +5,5 @@
- common
- docker
- neko
- customfirewall
- internalsmtp

View File

@ -0,0 +1,4 @@
Host backup backup.stargate.internal
HostName backup.stargate.internal
User backup
IdentityFile ~/.ssh/id_rsa

View File

@ -11,7 +11,7 @@
copy:
src: backup-script.service
dest: /usr/lib/systemd/system/backup-script.service
mode: 644
mode: 0644
owner: root
group: root
@ -19,7 +19,7 @@
copy:
src: backup.target
dest: /usr/lib/systemd/system/backup.target
mode: 644
mode: 0644
owner: root
group: root
@ -27,7 +27,7 @@
copy:
src: backup.timer
dest: /usr/lib/systemd/system/backup.timer
mode: 644
mode: 0644
owner: root
group: root
@ -49,3 +49,11 @@
ansible.builtin.systemd:
enabled: yes
name: backup.timer
- name: Copy ssh config
copy:
src: ssh_config
dest: /root/.ssh/config
mode: 0600
owner: root
group: root

View File

@ -3,6 +3,6 @@
{{backup.prearecommand}}
time ( rsync -azP --delete {{backup.folder}} backup@192.168.69.26:/mnt/backupstore/{{servicename}}/staging )
time ( rsync -azP --delete {{backup.folder}} backup@backup.stargate.internal:/mnt/backupstore/{{servicename}}/staging )
time ( ssh backup@backup.stargate.internal 'tar -zcvf /mnt/backupstore/{{servicename}}/{{servicename}}-$(date +"%Y-%m-%d").tar.gz -C /mnt/backupstore/{{servicename}}/staging' )
time ( ssh backup@backup.stargate.internal 'tar -zcvf /mnt/backupstore/{{servicename}}/{{servicename}}-$(date +"%Y-%m-%d").tar.gz -C /mnt/backupstore/{{servicename}}/staging {{backup.tarfolder}}' )

View File

@ -0,0 +1,8 @@
---
- name: Apply custom ufw rules
community.general.ufw:
rule: allow
port: "{{item.port}}"
proto: {{item.proto}}
interface: {{item.interface}}
with_items: "{{firewall}}"

View File

@ -1,6 +0,0 @@
---
- name: Allow git ssh via ufw
community.general.ufw:
rule: allow
port: 2222
proto: tcp

View File

@ -26,40 +26,3 @@
- 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: 59000:59049
proto: udp
interface: eth1