Ansible playbooks for deploying the Guitar0 platform: backend (Django), frontend (Next.js), and observability stack (Prometheus · Grafana · Loki).
- Ansible 2.17+
ansible-vaultpassword for secrets
pip install ansible
ansible-galaxy install -r ansible/requirements.ymlansible/
inventory/
staging.yml # staging hosts
production.yml # production hosts
group_vars/
all.yml # shared variables
staging/ # staging overrides + vault
production/ # production overrides + vault
playbooks/
setup.yml # one-time server setup
deploy-backend.yml
deploy-frontend.yml
monitoring.yml
rollback-backend.yml
rollback-frontend.yml
backup-backend.yml
roles/
common/ # packages, Docker, nginx, firewall, certbot
backend/
frontend/
monitoring/
observability/ # Prometheus rules, Grafana dashboards
Before running Ansible, prepare the server manually:
-
Generate an SSH key pair (if you don't have one):
ssh-keygen -t ed25519 -C "guitar0-deploy" -
Add your public key to the server via the hosting control panel, or copy it as root:
ssh root@<server-ip> mkdir -p /home/deploy/.ssh echo "<your public key>" >> /home/deploy/.ssh/authorized_keys
-
Create the
deployuser with passwordless sudo:adduser deploy echo "deploy ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/deploy mkdir -p /home/deploy/.ssh cp /root/.ssh/authorized_keys /home/deploy/.ssh/ chown -R deploy:deploy /home/deploy/.ssh chmod 700 /home/deploy/.ssh && chmod 600 /home/deploy/.ssh/authorized_keys
-
Update
ansible/inventory/production.ymlwith the new server IP/hostname. -
Create the vault password file:
echo "<vault-password>" > ansible/.vault_pass chmod 600 ansible/.vault_pass
-
Remove the old host key and trust the new server:
ssh-keygen -R <server-hostname> ssh-keyscan -H <server-hostname> >> ~/.ssh/known_hosts
-
Verify connectivity:
make ping INVENTORY=production SSH_PRIVATE_KEY_FILE=~/.ssh/<your-key>
-
Run one-time setup:
make setup INVENTORY=production SSH_PRIVATE_KEY_FILE=~/.ssh/<your-key>
make setup # one-time server setup (staging)
make deploy VERSION=1.2.3 # deploy backend + frontend
make deploy-backend VERSION=1.2.3 # backend only
make rollback-backend # rollback to previous version
make backup # backup database
make setup INVENTORY=production # target production
make vault-edit INVENTORY=production # edit production secretsRun make help to list all commands.
GNU Affero General Public License v3.0 or later. All source files carry SPDX headers and are REUSE compliant.