Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Andrey Kotlyar <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later

# Ansible
ansible/.ansible/
ansible/.vault_pass
Expand Down
235 changes: 235 additions & 0 deletions LICENSES/AGPL-3.0-or-later.txt

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# SPDX-FileCopyrightText: 2026 Andrey Kotlyar <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

.PHONY: help install lint ping setup \
deploy-backend deploy-frontend deploy \
rollback-backend rollback-frontend \
monitoring backup vault-edit

SHELL := /bin/bash

INVENTORY ?= staging
VERSION ?= latest

ANSIBLE := ansible-playbook -i ansible/inventory/$(INVENTORY).yml

# =============================================================================

help: ## Show available commands
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

install: ## Install Ansible and galaxy requirements
pip install ansible ansible-lint
ansible-galaxy install -r ansible/requirements.yml

lint: ## Run ansible-lint
ansible-lint ansible/playbooks/

ping: ## Check SSH connectivity (make ping INVENTORY=production)
ansible all -i ansible/inventory/$(INVENTORY).yml -m ping

# =============================================================================
# Setup
# =============================================================================

setup: ## One-time server setup (make setup INVENTORY=production)
$(ANSIBLE) ansible/playbooks/setup.yml

# =============================================================================
# Deploy
# =============================================================================

deploy-backend: ## Deploy backend (make deploy-backend VERSION=1.2.3)
$(ANSIBLE) ansible/playbooks/deploy-backend.yml -e VERSION=$(VERSION)

deploy-frontend: ## Deploy frontend (make deploy-frontend VERSION=1.2.3)
$(ANSIBLE) ansible/playbooks/deploy-frontend.yml -e VERSION=$(VERSION)

deploy: deploy-backend deploy-frontend ## Deploy backend + frontend

# =============================================================================
# Rollback
# =============================================================================

rollback-backend: ## Rollback backend to previous version
$(ANSIBLE) ansible/playbooks/rollback-backend.yml

rollback-frontend: ## Rollback frontend to previous version
$(ANSIBLE) ansible/playbooks/rollback-frontend.yml

# =============================================================================
# Operations
# =============================================================================

monitoring: ## Deploy observability stack
$(ANSIBLE) ansible/playbooks/monitoring.yml

backup: ## Backup backend database
$(ANSIBLE) ansible/playbooks/backup-backend.yml

vault-edit: ## Edit secrets vault (make vault-edit INVENTORY=production)
ansible-vault edit ansible/inventory/group_vars/$(INVENTORY)/vault.yml
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,69 @@
<!--
SPDX-FileCopyrightText: 2026 Andrey Kotlyar <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
-->

# Guitar0 infrastructure

[![License](https://img.shields.io/badge/license-AGPL--3.0--or--later-green.svg)](./LICENSES/AGPL-3.0-or-later.txt)
[![REUSE status](https://api.reuse.software/badge/github.com/guitar0-net/infrastructure)](https://api.reuse.software/info/github.com/guitar0-net/infrastructure)

Ansible playbooks for deploying the [Guitar0](https://guitar0.net) platform: backend (Django), frontend (Next.js), and observability stack (Prometheus · Grafana · Loki).

## Prerequisites

- Ansible 2.17+
- `ansible-vault` password for secrets

```bash
pip install ansible
ansible-galaxy install -r ansible/requirements.yml
```

## Structure

```
ansible/
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
```

## Usage

```bash
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 secrets
```

Run `make help` to list all commands.

## License

[GNU Affero General Public License v3.0 or later](./LICENSES/AGPL-3.0-or-later.txt).
All source files carry SPDX headers and are [REUSE compliant](https://reuse.software).
17 changes: 17 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2026 Andrey Kotlyar <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later

version = 1

[[annotations]]
path = [
# Ansible Vault — encrypted, cannot contain plaintext headers
"ansible/inventory/group_vars/staging/vault.yml",
"ansible/inventory/group_vars/production/vault.yml",
"ansible/.vault_pass",
# Ansible generated cache
"ansible/.ansible/**",
]
precedence = "closest"
SPDX-FileCopyrightText = "2026 Andrey Kotlyar <[email protected]>"
SPDX-License-Identifier = "AGPL-3.0-or-later"
3 changes: 3 additions & 0 deletions observability/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2026 Andrey Kotlyar <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later

# Copy to .env and fill in the values
# cp .env.example .env

Expand Down
Loading