feat: prepare-new-server playbook + role struktura
playbook prepare-new-server.yml:
- update systemu
- deploy user (UID 1000, heslo zamknuto)
- SSH klic pro deploy uzivatele
- adresarova struktura (/home/deploy/{docker,scripts,backups,logs,...})
- Docker Engine + Compose plugin (bez sudo)
- UFW firewall (22, 80, 443)
- fail2ban
- overeni docker bez sudo
Role (kazda v samostatnem adresari):
- common: update, base packages, timezone
- deploy-user: vytvoreni usera UID 1000
- ssh-keys: authorized_keys deployment
- firewall: UFW konfigurace
- docker: Docker Engine + Compose + daemon.json
- directories: /home/deploy/{docker/<sluzba>,backups,scripts,logs}
Pouziti:
ansible-playbook -i inventory.yml playbooks/prepare-new-server.yml
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
---
|
||||
# Proměnné pro firewall roli
|
||||
ssh_port: 22
|
||||
# Dalsi porty co chces povolit (pro servery)
|
||||
allowed_ports:
|
||||
- { port: 80, proto: tcp, comment: "HTTP" }
|
||||
- { port: 443, proto: tcp, comment: "HTTPS" }
|
||||
- { port: "{{ ssh_port }}", proto: tcp, comment: "SSH" }
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
- name: Nainstaluj UFW
|
||||
ansible.builtin.apt:
|
||||
name: ufw
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Reset UFW na default
|
||||
community.general.ufw:
|
||||
state: reset
|
||||
|
||||
- name: UFW default - deny incoming
|
||||
community.general.ufw:
|
||||
direction: incoming
|
||||
policy: deny
|
||||
|
||||
- name: UFW default - allow outgoing
|
||||
community.general.ufw:
|
||||
direction: outgoing
|
||||
policy: allow
|
||||
|
||||
- name: Povol porty pres UFW
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "{{ item.port }}"
|
||||
proto: "{{ item.proto }}"
|
||||
comment: "{{ item.comment }}"
|
||||
loop: "{{ allowed_ports }}"
|
||||
|
||||
- name: Aktivuj UFW
|
||||
community.general.ufw:
|
||||
state: enabled
|
||||
Reference in New Issue
Block a user