Playbooks¶
All playbooks live in the repo root. Use make or ansible-playbook directly.
Quick reference¶
| Playbook | Makefile target | Purpose |
|---|---|---|
site.yml | make site | Full run – web + db |
web.yml | make web | Web servers (full config) |
db.yml | make db | Database servers (full config) |
baseline.yml | (none) | Common hardening only (all hosts) |
bootstrap_root.yml | make bootstrap-root | First-time root bootstrap |
bootstrap_web.yml | make bootstrap-web | First-time web bootstrap (Docker + cloudflared) |
bootstrap_db.yml | make bootstrap-db | First-time DB bootstrap (MariaDB + cloudflared) |
lockdown.yml | make lockdown | Close inbound ports – tunnel-only access |
tool.yml | (none) | Tool servers (Verdaccio, deployment, monitoring) |
analytics.yml | (none) | Analytics servers |
Makefile usage¶
The Makefile defaults to the stage inventory. Override with ENV=prod.
# Ping all staging hosts
make ping
# Run web playbook on prod
make ENV=prod web
# Run db playbook on prod
make ENV=prod db
# Full site run on prod
make ENV=prod site
The Makefile includes VAULT ?= --ask-vault-pass. Because ansible.cfg already points to .ansible_vault_pass, you normally don't need vault prompts. Suppress the flag:
Playbook details¶
site.yml – full site run¶
Imports both web.yml and db.yml. Use this to converge the entire environment.
web.yml – web servers¶
Applies the complete web server configuration to the web group.
Roles applied (in order): common_baseline → access_users → deployment → journald_limits → logrotate_custom → unattended_upgrades → firewall_ufw → ssh_hardening → fail2ban → auditd → docker_engine → docker_compose_plugin → cadvisor → netdata → cloudflare → cronjobs
# All web servers
ansible-playbook -i inventories/prod/hosts.yml web.yml
# Single host
ansible-playbook -i inventories/prod/hosts.yml web.yml --limit bkdk-web-01
db.yml – database servers¶
Applies the complete database server configuration to the db group.
Roles applied (in order): common_baseline → access_users → journald_limits → logrotate_custom → unattended_upgrades → firewall_ufw → ssh_hardening → fail2ban → auditd → cloudflare → netdata → mariadb → mariadb_binlog → sqlbak
baseline.yml – hardening only¶
Runs security hardening roles on all hosts without app-specific configuration. Useful for mass updates to security policy.
Roles: common_baseline, journald_limits, logrotate_custom, unattended_upgrades, firewall_ufw, ssh_hardening, fail2ban, auditd
bootstrap_root.yml – first-time root bootstrap¶
Used when you only have root SSH access to a fresh server. Creates operator users (pt, sd), installs their public keys, configures sudo, and applies baseline hardening.
Runs as remote_user: root. Does not use become.
See New server for the full first-time workflow.
bootstrap_web.yml – web bootstrap¶
Extends baseline.yml with Docker Engine, Docker Compose plugin, and cloudflared installation. Run this after bootstrap_root.yml on new web servers.
bootstrap_db.yml – DB bootstrap¶
Extends baseline.yml with MariaDB, binary log configuration, SqlBak, and cloudflared. Run this after bootstrap_root.yml on new database servers.
lockdown.yml – Zero Trust lockdown¶
Closes all inbound UFW ports and binds SSH to localhost. After this, the server is only reachable via Cloudflare Tunnel. Requires cloudflared to already be running (verified before applying).
Warning: If cloudflared is not healthy when this runs, the playbook will abort. Do not run this unless you have verified tunnel connectivity.
tool.yml – tool servers¶
Configures the tools group: Verdaccio (private npm registry), deployment tooling, and monitoring.
analytics.yml – analytics servers¶
Configures the analytics group: Docker-based analytics stack with standard hardening and Cloudflare integration.
Useful flags¶
| Flag | Purpose |
|---|---|
--limit <host> | Run only against one host or group |
--check | Dry run – show what would change |
--diff | Show file diffs for template changes |
--tags <tag> | Run only tasks with this tag (e.g. debug) |
--skip-tags <tag> | Skip tasks with this tag |
-v / -vvv | Increase verbosity |
Example – dry run with diffs on a single host: