Refine: Update documentation to accurately reflect Ansible assets and structure

This commit brings the `README.md` and Ansible setup guides (`03-test-ansible-bootstrap.md`, `07-prod-ansible-bootstrap.md`) in sync with the current state of the Ansible automation.

Key updates include:
- Acknowledging the presence of in-repository Ansible playbooks and shared roles.
- Correcting Ansible inventory output paths and Terraform output commands.
- Detailing the new `group_vars/all/{vars.yml,vault.yml}` structure.
- Updating Ansible prerequisites to include `passlib` for password hashing.
- Adding documentation for `iklim` system user creation, keyboard layout, and refined firewall rules.
- Removing outdated "Known Gaps" related to missing Ansible code.
This commit is contained in:
Murat ÖZDEMİR 2026-05-11 19:00:10 +03:00
parent f73504c0f2
commit 65443e81e7
3 changed files with 90 additions and 40 deletions

View File

@ -4,7 +4,7 @@ Infrastructure-as-code and operational runbook repository for `iklim.co` test an
This repository defines:
- 🧱 Terraform resources for Hetzner infrastructure (`test` and `prod`)
- 📦 Generated Ansible inventory output targets
- 🤖 Ansible bootstrap playbooks, shared roles, and inventory targets
- 📚 End-to-end setup guides and roadmap documents (mostly Turkish)
- 📊 Sizing/cost analysis and supporting reference assets
@ -13,7 +13,7 @@ This repository defines:
The main goal is to standardize and document infrastructure provisioning with clear responsibility boundaries:
- 🧱 **Terraform**: creates cloud infrastructure (servers, private networks, firewalls, placement groups, floating IPs, SSH key registration, inventory output)
- 🤖 **Ansible**: prepares OS, security hardening, Docker/Swarm, runner setup, StorageBox mount workflows (described in docs; role code is not currently in this repo)
- 🤖 **Ansible**: prepares OS, security hardening, Docker/Swarm, runner setup, and StorageBox mount workflows via in-repo playbooks and shared roles
- 🚀 **Application/stack deployment**: handled in related deployment workflows and stack manifests referenced by roadmap docs
## 📌 Current Repository Status
@ -23,15 +23,23 @@ As of now, this repository primarily contains:
- 🧱 Ready Terraform code for:
- `terraform/hetzner/test`
- `terraform/hetzner/prod`
- 📦 A generated sample inventory file:
- `ansible/inventory/generated/test.yml`
- 🤖 Ansible automation assets for both environments:
- `ansible/test/test-bootstrap.yml`
- `ansible/prod/prod-bootstrap.yml`
- `ansible/roles/*`
- `ansible/test/group_vars/*` and `ansible/prod/group_vars/*`
- 📦 Inventory artifacts and output targets:
- `ansible/test/inventory/generated/test.yml` (tracked sample)
- `ansible/prod/inventory/generated/prod.yml` (expected output path)
- 📘 Detailed setup phases:
- `setup/00-genel-yol-haritasi.md` through `setup/09-prod-runner-ha-ve-swarm.md`
- 🛣️ Environment roadmap steps:
- `roadmap/test-env/*`
- `roadmap/prod-env/*`
- 📈 Capacity planning report:
- 📈 Capacity planning and reference charts:
- `hetzner-sizing-report.md`
- `test-app-graphs.png`
- `test-db-graphs.png`
## 🧭 Target Environment Topology
@ -77,9 +85,26 @@ See:
```text
Environment_Infrastructure/
├── ansible/
│ └── inventory/
│ └── generated/
│ └── test.yml
│ ├── prod/
│ │ ├── ansible.cfg
│ │ ├── group_vars/
│ │ └── prod-bootstrap.yml
│ ├── roles/
│ │ ├── base/
│ │ ├── docker/
│ │ ├── hardening/
│ │ ├── node_dirs/
│ │ ├── storagebox/
│ │ ├── storagebox_ssh_key/
│ │ └── swarm/
│ ├── test/
│ │ ├── ansible.cfg
│ │ ├── group_vars/
│ │ ├── inventory/
│ │ │ └── generated/
│ │ │ └── test.yml
│ │ └── test-bootstrap.yml
│ └── requirements.yml
├── roadmap/
│ ├── test-env/
│ └── prod-env/
@ -99,7 +124,9 @@ Environment_Infrastructure/
│ ├── test/
│ └── prod/
├── hetzner-sizing-report.md
└── setup-vs-roadmap-map.md
├── setup-vs-roadmap-map.md
├── test-app-graphs.png
└── test-db-graphs.png
```
## ✅ Prerequisites
@ -130,7 +157,8 @@ Then run:
terraform init
terraform plan
terraform apply
terraform output -raw ansible_inventory_yaml > ../../../ansible/inventory/generated/test.yml
mkdir -p ../../../ansible/test/inventory/generated
terraform output -raw ansible_inventory_yaml > ../../../ansible/test/inventory/generated/test.yml
```
### 2) 🏭 Production Infrastructure
@ -151,7 +179,8 @@ Then run:
terraform init
terraform plan
terraform apply
terraform output -raw ansible_inventory_yaml > ../../../ansible/inventory/generated/prod.yml
mkdir -p ../../../ansible/prod/inventory/generated
terraform output -raw ansible_inventory_yaml > ../../../ansible/prod/inventory/generated/prod.yml
```
## 🧱 Setup Flow (Canonical Order)
@ -206,8 +235,7 @@ Recommended:
## ⚠️ Known Gaps / Notes
- Ansible role/playbook source code is described by docs but is not currently present in this repository.
- `ansible/inventory/generated/prod.yml` is expected output path but may not exist until generated.
- `ansible/prod/inventory/generated/prod.yml` is an expected output path but may not exist until generated.
- Some roadmap steps target files under the broader `iklim.co` application repository, not this repository alone.
## ✅ Quick Validation Checklist
@ -218,7 +246,7 @@ After Terraform apply:
- floating IP exists and is attached
- firewalls expose only intended public ports
- placement groups are assigned
- generated inventory YAML is exported to `ansible/inventory/generated/*.yml`
- generated inventory YAML is exported to `ansible/{test,prod}/inventory/generated/*.yml`
After bootstrap/deploy phases:

View File

@ -40,6 +40,16 @@ Ansible, kontrol makinesinde (kendi bilgisayarınızda) yüklü olmalıdır. Hed
pipx install --include-deps ansible
```
### Ek Python Bağımlılıkları
`password_hash` filtresi için `passlib` kontrol makinesinde gereklidir:
```bash
pipx inject ansible passlib
```
> `pip` ile kurduysanız: `pip install passlib`
### Kurulumun Doğrulanması
Hangi yöntemle kurarsanız kurun, kurulumun başarılı olduğunu doğrulamak için aşağıdaki komutları kullanın:
@ -99,8 +109,9 @@ ansible/
generated/
test.yml
group_vars/
all.yml
test.yml
all/
vars.yml
vault.yml
test-bootstrap.yml
roles/
base/
@ -117,8 +128,8 @@ ansible/
Tüm test node'larına uygulanır:
- `dnf update`
- temel paketler (sırasıyla kurulur):
- `epel-release` — fail2ban ve davfs2 bu repo'dan gelir; önce kurulur
- `epel-release` — ayrı task olarak önce kurulur; `fail2ban`, `davfs2`, `htop`, `btop` bu repoya bağımlı
- temel paketler (`epel-release` aktif olduktan sonra):
- `curl`
- `wget`
- `git`
@ -133,10 +144,12 @@ Tüm test node'larına uygulanır:
- `chrony`
- `python3`
- `python3-pip`
- `python3-passlib``password_hash` filtresi için (EPEL)
- `htop` — interaktif proses izleme (EPEL)
- `btop` — kaynak monitörü, grafik arayüz (EPEL)
- timezone: `Europe/Istanbul`
- hostname ayarı
- klavye düzeni: `trq` (Türkçe Q)
- sistem reboot gerekiyorsa kontrollü reboot
## Security Hardening Role
@ -150,9 +163,11 @@ Tüm test node'larına uygulanır:
- `MaxAuthTries 3`
- `fail2ban` SSH jail aktif edilir.
- `dnf-automatic` ile otomatik güvenlik güncelleştirmeleri aktif edilir.
- `iklim` sistem kullanıcısı oluşturulur; `wheel` grubuna eklenir (şifre vault'tan alınır).
- `firewalld` default:
- incoming: deny (drop zone)
- outgoing: allow
- SSH kuralı önce `drop` zone'a rich rule olarak yazılır, ardından default zone `drop` yapılır — kilitleme riski ortadan kalkar.
- Public SSH sadece admin CIDR'dan açılır.
### SELinux Kararı
@ -252,6 +267,7 @@ Docker convenience script kullanılmayacak. Production benzeri test ortamı içi
/opt/iklimco/init
/opt/iklimco/init/postgresql
/opt/iklimco/init/mongodb
/opt/iklimco/stacks
```
DB node üzerinde manuel DB kurulumu için minimum:
@ -281,37 +297,29 @@ Hetzner StorageBox'u WebDAV (DAVFS) protokolü üzerinden `/mnt/storagebox` olar
### Role Değişkenleri
`group_vars/all.yml` — tüm ortamlar için ortak:
Tüm değişkenler `group_vars/all/vars.yml` içinde tanımlanır:
```yaml
storagebox_account: "u469968"
```
`group_vars/test.yml` — test ortamına özgü; user ve url account'tan türetilir:
```yaml
storagebox_user: "{{ storagebox_account }}-sub1"
storagebox_user: "{{ storagebox_account }}-sub4"
storagebox_url: "https://{{ storagebox_user }}.your-storagebox.de/"
storagebox_password: "{{ vault_storagebox_password }}" # Ansible Vault ile saklanır
storagebox_password: "{{ vault_storagebox_password }}"
storagebox_mount_point: "/mnt/storagebox"
```
Prod ortamında yalnızca suffix değişir (`sub4``sub5`), geri kalan her şey türetilir.
Prod ortamında suffix `sub4``sub5` olarak değişir.
`vault_storagebox_password` değeri Ansible Vault ile şifreli `group_vars/test-vault.yml` içinde tutulur:
Şifreler Ansible Vault ile şifreli `group_vars/all/vault.yml` içinde tutulur:
```bash
# Sifreleme
ansible-vault encrypt group_vars/test-vault.yml
# Düzenleme
ansible-vault edit group_vars/test-vault.yml
ansible-vault edit group_vars/all/vault.yml
```
`test-vault.yml` içeriği:
`vault.yml` içeriği:
```yaml
vault_storagebox_password: "SUB_ACCOUNT_PAROLASI"
vault_iklim_password: "IKLIM_KULLANICI_PAROLASI"
```
### Adımlar

View File

@ -39,6 +39,16 @@ Ansible, kontrol makinesinde (kendi bilgisayarınızda) yüklü olmalıdır. Hed
pipx install --include-deps ansible
```
### Ek Python Bağımlılıkları
`password_hash` filtresi için `passlib` kontrol makinesinde gereklidir:
```bash
pipx inject ansible passlib
```
> `pip` ile kurduysanız: `pip install passlib`
### Kurulumun Doğrulanması
Hangi yöntemle kurarsanız kurun, kurulumun başarılı olduğunu doğrulamak için aşağıdaki komutları kullanın:
@ -102,8 +112,9 @@ ansible/
generated/
prod.yml
group_vars/
all.yml
prod.yml
all/
vars.yml
vault.yml
prod-bootstrap.yml
roles/
base/
@ -120,8 +131,8 @@ ansible/
Tüm prod node'larına uygulanır:
- Paket cache update
- Temel paketler (sırasıyla kurulur):
- `epel-release` — fail2ban ve davfs2 bu repo'dan gelir; önce kurulur
- `epel-release` — ayrı task olarak önce kurulur; `fail2ban`, `davfs2`, `htop`, `btop` bu repoya bağımlı
- temel paketler (`epel-release` aktif olduktan sonra):
- `curl`
- `wget`
- `git`
@ -133,14 +144,15 @@ Tüm prod node'larına uygulanır:
- `tree`
- `ca-certificates`
- `fail2ban`
- `firewalld`
- `chrony`
- `python3`
- `python3-pip`
- `python3-passlib``password_hash` filtresi için (EPEL)
- `htop` — interaktif proses izleme (EPEL)
- `btop` — kaynak monitörü, grafik arayüz (EPEL)
- timezone: `Europe/Istanbul`
- hostname ayarı
- klavye düzeni: `trq` (Türkçe Q)
- chrony/NTP aktif
## Security Hardening Role
@ -154,7 +166,9 @@ Tüm prod node'larına uygulanır:
- `MaxAuthTries 3`
- `fail2ban` aktif edilir.
- `dnf-automatic` ile otomatik güvenlik güncelleştirmeleri aktif edilir.
- `iklim` sistem kullanıcısı oluşturulur; `wheel` grubuna eklenir (şifre vault'tan alınır).
- `firewalld` default: incoming deny (drop zone), outgoing allow.
- SSH kuralı önce `drop` zone'a rich rule olarak yazılır, ardından default zone `drop` yapılır.
- SSH sadece admin CIDR'dan açılır.
- DB portları public açılmaz.
@ -221,7 +235,7 @@ Her node'a uygulanır. Sunucu üzerinde ed25519 SSH anahtar çifti üretilir ve
## Kabul Kriterleri
- `ansible -i inventory/generated/prod.yml all -m ping` başarılı olur.
- `ansible all -m ping` başarılı olur.
- 3 Swarm manager node `docker node ls` içinde Leader/Reachable görünür.
- 3 DB node `docker node ls` içinde Worker olarak görünür.
- Manager quorum sağlanır (3 manager, 1 kayıp tolere edilir).