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: This repository defines:
- 🧱 Terraform resources for Hetzner infrastructure (`test` and `prod`) - 🧱 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) - 📚 End-to-end setup guides and roadmap documents (mostly Turkish)
- 📊 Sizing/cost analysis and supporting reference assets - 📊 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: 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) - 🧱 **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 - 🚀 **Application/stack deployment**: handled in related deployment workflows and stack manifests referenced by roadmap docs
## 📌 Current Repository Status ## 📌 Current Repository Status
@ -23,15 +23,23 @@ As of now, this repository primarily contains:
- 🧱 Ready Terraform code for: - 🧱 Ready Terraform code for:
- `terraform/hetzner/test` - `terraform/hetzner/test`
- `terraform/hetzner/prod` - `terraform/hetzner/prod`
- 📦 A generated sample inventory file: - 🤖 Ansible automation assets for both environments:
- `ansible/inventory/generated/test.yml` - `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: - 📘 Detailed setup phases:
- `setup/00-genel-yol-haritasi.md` through `setup/09-prod-runner-ha-ve-swarm.md` - `setup/00-genel-yol-haritasi.md` through `setup/09-prod-runner-ha-ve-swarm.md`
- 🛣️ Environment roadmap steps: - 🛣️ Environment roadmap steps:
- `roadmap/test-env/*` - `roadmap/test-env/*`
- `roadmap/prod-env/*` - `roadmap/prod-env/*`
- 📈 Capacity planning report: - 📈 Capacity planning and reference charts:
- `hetzner-sizing-report.md` - `hetzner-sizing-report.md`
- `test-app-graphs.png`
- `test-db-graphs.png`
## 🧭 Target Environment Topology ## 🧭 Target Environment Topology
@ -77,9 +85,26 @@ See:
```text ```text
Environment_Infrastructure/ Environment_Infrastructure/
├── ansible/ ├── ansible/
│ └── inventory/ │ ├── prod/
│ └── generated/ │ │ ├── ansible.cfg
│ └── test.yml │ │ ├── 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/ ├── roadmap/
│ ├── test-env/ │ ├── test-env/
│ └── prod-env/ │ └── prod-env/
@ -99,7 +124,9 @@ Environment_Infrastructure/
│ ├── test/ │ ├── test/
│ └── prod/ │ └── prod/
├── hetzner-sizing-report.md ├── hetzner-sizing-report.md
└── setup-vs-roadmap-map.md ├── setup-vs-roadmap-map.md
├── test-app-graphs.png
└── test-db-graphs.png
``` ```
## ✅ Prerequisites ## ✅ Prerequisites
@ -130,7 +157,8 @@ Then run:
terraform init terraform init
terraform plan terraform plan
terraform apply 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 ### 2) 🏭 Production Infrastructure
@ -151,7 +179,8 @@ Then run:
terraform init terraform init
terraform plan terraform plan
terraform apply 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) ## 🧱 Setup Flow (Canonical Order)
@ -206,8 +235,7 @@ Recommended:
## ⚠️ Known Gaps / Notes ## ⚠️ Known Gaps / Notes
- Ansible role/playbook source code is described by docs but is not currently present in this repository. - `ansible/prod/inventory/generated/prod.yml` is an expected output path but may not exist until generated.
- `ansible/inventory/generated/prod.yml` is 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. - Some roadmap steps target files under the broader `iklim.co` application repository, not this repository alone.
## ✅ Quick Validation Checklist ## ✅ Quick Validation Checklist
@ -218,7 +246,7 @@ After Terraform apply:
- floating IP exists and is attached - floating IP exists and is attached
- firewalls expose only intended public ports - firewalls expose only intended public ports
- placement groups are assigned - 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: 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 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ı ### 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: 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/ generated/
test.yml test.yml
group_vars/ group_vars/
all.yml all/
test.yml vars.yml
vault.yml
test-bootstrap.yml test-bootstrap.yml
roles/ roles/
base/ base/
@ -117,8 +128,8 @@ ansible/
Tüm test node'larına uygulanır: Tüm test node'larına uygulanır:
- `dnf update` - `dnf update`
- temel paketler (sırasıyla kurulur): - `epel-release` — ayrı task olarak önce kurulur; `fail2ban`, `davfs2`, `htop`, `btop` bu repoya bağımlı
- `epel-release` — fail2ban ve davfs2 bu repo'dan gelir; önce kurulur - temel paketler (`epel-release` aktif olduktan sonra):
- `curl` - `curl`
- `wget` - `wget`
- `git` - `git`
@ -133,10 +144,12 @@ Tüm test node'larına uygulanır:
- `chrony` - `chrony`
- `python3` - `python3`
- `python3-pip` - `python3-pip`
- `python3-passlib``password_hash` filtresi için (EPEL)
- `htop` — interaktif proses izleme (EPEL) - `htop` — interaktif proses izleme (EPEL)
- `btop` — kaynak monitörü, grafik arayüz (EPEL) - `btop` — kaynak monitörü, grafik arayüz (EPEL)
- timezone: `Europe/Istanbul` - timezone: `Europe/Istanbul`
- hostname ayarı - hostname ayarı
- klavye düzeni: `trq` (Türkçe Q)
- sistem reboot gerekiyorsa kontrollü reboot - sistem reboot gerekiyorsa kontrollü reboot
## Security Hardening Role ## Security Hardening Role
@ -150,9 +163,11 @@ Tüm test node'larına uygulanır:
- `MaxAuthTries 3` - `MaxAuthTries 3`
- `fail2ban` SSH jail aktif edilir. - `fail2ban` SSH jail aktif edilir.
- `dnf-automatic` ile otomatik güvenlik güncelleştirmeleri 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: - `firewalld` default:
- incoming: deny (drop zone) - incoming: deny (drop zone)
- outgoing: allow - 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. - Public SSH sadece admin CIDR'dan açılır.
### SELinux Kararı ### SELinux Kararı
@ -252,6 +267,7 @@ Docker convenience script kullanılmayacak. Production benzeri test ortamı içi
/opt/iklimco/init /opt/iklimco/init
/opt/iklimco/init/postgresql /opt/iklimco/init/postgresql
/opt/iklimco/init/mongodb /opt/iklimco/init/mongodb
/opt/iklimco/stacks
``` ```
DB node üzerinde manuel DB kurulumu için minimum: 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 ### 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 ```yaml
storagebox_account: "u469968" storagebox_account: "u469968"
``` storagebox_user: "{{ storagebox_account }}-sub4"
`group_vars/test.yml` — test ortamına özgü; user ve url account'tan türetilir:
```yaml
storagebox_user: "{{ storagebox_account }}-sub1"
storagebox_url: "https://{{ storagebox_user }}.your-storagebox.de/" 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" 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 ```bash
# Sifreleme ansible-vault edit group_vars/all/vault.yml
ansible-vault encrypt group_vars/test-vault.yml
# Düzenleme
ansible-vault edit group_vars/test-vault.yml
``` ```
`test-vault.yml` içeriği: `vault.yml` içeriği:
```yaml ```yaml
vault_storagebox_password: "SUB_ACCOUNT_PAROLASI" vault_storagebox_password: "SUB_ACCOUNT_PAROLASI"
vault_iklim_password: "IKLIM_KULLANICI_PAROLASI"
``` ```
### Adımlar ### 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 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ı ### 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: 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/ generated/
prod.yml prod.yml
group_vars/ group_vars/
all.yml all/
prod.yml vars.yml
vault.yml
prod-bootstrap.yml prod-bootstrap.yml
roles/ roles/
base/ base/
@ -120,8 +131,8 @@ ansible/
Tüm prod node'larına uygulanır: Tüm prod node'larına uygulanır:
- Paket cache update - Paket cache update
- Temel paketler (sırasıyla kurulur): - `epel-release` — ayrı task olarak önce kurulur; `fail2ban`, `davfs2`, `htop`, `btop` bu repoya bağımlı
- `epel-release` — fail2ban ve davfs2 bu repo'dan gelir; önce kurulur - temel paketler (`epel-release` aktif olduktan sonra):
- `curl` - `curl`
- `wget` - `wget`
- `git` - `git`
@ -133,14 +144,15 @@ Tüm prod node'larına uygulanır:
- `tree` - `tree`
- `ca-certificates` - `ca-certificates`
- `fail2ban` - `fail2ban`
- `firewalld`
- `chrony` - `chrony`
- `python3` - `python3`
- `python3-pip` - `python3-pip`
- `python3-passlib``password_hash` filtresi için (EPEL)
- `htop` — interaktif proses izleme (EPEL) - `htop` — interaktif proses izleme (EPEL)
- `btop` — kaynak monitörü, grafik arayüz (EPEL) - `btop` — kaynak monitörü, grafik arayüz (EPEL)
- timezone: `Europe/Istanbul` - timezone: `Europe/Istanbul`
- hostname ayarı - hostname ayarı
- klavye düzeni: `trq` (Türkçe Q)
- chrony/NTP aktif - chrony/NTP aktif
## Security Hardening Role ## Security Hardening Role
@ -154,7 +166,9 @@ Tüm prod node'larına uygulanır:
- `MaxAuthTries 3` - `MaxAuthTries 3`
- `fail2ban` aktif edilir. - `fail2ban` aktif edilir.
- `dnf-automatic` ile otomatik güvenlik güncelleştirmeleri 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. - `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. - SSH sadece admin CIDR'dan açılır.
- DB portları public açılmaz. - DB portları public açılmaz.
@ -221,7 +235,7 @@ Her node'a uygulanır. Sunucu üzerinde ed25519 SSH anahtar çifti üretilir ve
## Kabul Kriterleri ## 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 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. - 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). - Manager quorum sağlanır (3 manager, 1 kayıp tolere edilir).