Added few playbooks

This commit is contained in:
Amit Salunke 2026-09-26 22:18:46 +05:30
parent 2a16c328cb
commit b6f39d8d82
25 changed files with 43 additions and 38 deletions

View File

@ -1,4 +1,4 @@
# Local AccuPedia workspace. # Local AcuPedia workspace.
# Copy this file to .env and adjust for your machine. # Copy this file to .env and adjust for your machine.
# #
# Do NOT commit .env. # Do NOT commit .env.

View File

@ -39,7 +39,7 @@ With the clean Acupedia naming conventions:
- **Database**: `acupedia_db` - **Database**: `acupedia_db`
- **User**: `db_admin` / Password: `C1234spl` - **User**: `db_admin` / Password: `C1234spl`
- **Volumes**: `acupedia-postgres-data`, `acupedia-minio-data` - **Volumes**: `acupedia-postgres-data`, `acupedia-minio-data`
- **MinIO Bucket**: `accupedia-media` - **MinIO Bucket**: `acupedia-media`
### Start the containers: ### Start the containers:
```bash ```bash
@ -58,7 +58,7 @@ Applies the four schemas (`auth`, `content`, `commerce`, `platform`), tables, in
```bash ```bash
docker compose -f docker-compose.dev.yml exec backend \ docker compose -f docker-compose.dev.yml exec backend \
psql postgresql://db_admin:C1234spl@postgres:5432/acupedia_db -f /app/schema/accupedia_db_v5.sql psql postgresql://db_admin:C1234spl@postgres:5432/acupedia_db -f /app/schema/acupedia_db_v5.sql
``` ```
--- ---
@ -89,7 +89,7 @@ docker compose -f docker-compose.dev.yml exec backend \
--- ---
### Step 3.4: Seed Clinical Media Assets (Images to MinIO) ### Step 3.4: Seed Clinical Media Assets (Images to MinIO)
Seeds all 787 anatomical images, channel pathways, and charts across the 4 visual modules into MinIO object storage (`accupedia-media` bucket) and links them to their respective content items in PostgreSQL: Seeds all 787 anatomical images, channel pathways, and charts across the 4 visual modules into MinIO object storage (`acupedia-media` bucket) and links them to their respective content items in PostgreSQL:
**Option A (Recommended — Automated 1-line loop for all 4 modules):** **Option A (Recommended — Automated 1-line loop for all 4 modules):**
```bash ```bash

View File

@ -1,6 +1,6 @@
# acupedia-ops # acupedia-ops
Operational tooling for AccuPedia. Operational tooling for AcuPedia.
The repository owns: The repository owns:

View File

@ -1,2 +1,2 @@
"""AccuPedia operational tooling.""" """AcuPedia operational tooling."""
__version__ = "0.1.0" __version__ = "0.1.0"

View File

@ -6,6 +6,12 @@ from typing import Any, Callable, Mapping
from acupedia_ops.common.paths import ansible_root from acupedia_ops.common.paths import ansible_root
try:
import ansible_runner
except ImportError as exc:
raise RuntimeError(
'Install deployment support with: pip install -e ".[deployment]"'
) from exc
@dataclass(frozen=True, slots=True) @dataclass(frozen=True, slots=True)
class AnsibleRunResult: class AnsibleRunResult:
@ -43,12 +49,7 @@ def run_playbook(
event_handler: Callable[[dict[str, Any]], bool | None] | None = None, event_handler: Callable[[dict[str, Any]], bool | None] | None = None,
status_handler: Callable[[str, dict[str, Any]], None] | None = None, status_handler: Callable[[str, dict[str, Any]], None] | None = None,
) -> AnsibleRunResult: ) -> AnsibleRunResult:
try:
import ansible_runner
except ImportError as exc:
raise RuntimeError(
'Install deployment support with: pip install -e ".[deployment]"'
) from exc
root = ansible_root().resolve() root = ansible_root().resolve()
inventory_path = _resolve_inventory(inventory) inventory_path = _resolve_inventory(inventory)

View File

@ -28,20 +28,20 @@ def resolve_api_root(api_root: Path | None = None) -> Path:
raw = os.environ.get("ACUPEDIA_API_PATH", "").strip() raw = os.environ.get("ACUPEDIA_API_PATH", "").strip()
if not raw: if not raw:
raise RuntimeError( raise RuntimeError(
"AccuPedia API path is required. Supply --api-root or set " "AcuPedia API path is required. Supply --api-root or set "
"ACUPEDIA_API_PATH." "ACUPEDIA_API_PATH."
) )
root = resolve_workspace_path(raw, base_path=base) root = resolve_workspace_path(raw, base_path=base)
if not root.is_dir(): if not root.is_dir():
raise FileNotFoundError(f"AccuPedia API repository not found: {root}") raise FileNotFoundError(f"AcuPedia API repository not found: {root}")
if not (root / "app").is_dir(): if not (root / "app").is_dir():
raise ValueError(f"Invalid AccuPedia API repository; missing: {root / 'app'}") raise ValueError(f"Invalid AcuPedia API repository; missing: {root / 'app'}")
if not (root / "pyproject.toml").is_file(): if not (root / "pyproject.toml").is_file():
raise ValueError( raise ValueError(
f"Invalid AccuPedia API repository; missing: {root / 'pyproject.toml'}" f"Invalid AcuPedia API repository; missing: {root / 'pyproject.toml'}"
) )
return root return root

View File

@ -34,7 +34,7 @@ LOCAL_COMPONENTS = ("api", "mobile", "web", "admin")
def _build_parser() -> argparse.ArgumentParser: def _build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog="acupedia-ops", prog="acupedia-ops",
description="AccuPedia operational tooling", description="AcuPedia operational tooling",
) )
parser.add_argument( parser.add_argument(
"--env-file", "--env-file",

View File

@ -14,7 +14,7 @@ def workspace_base_path(
*, *,
required: bool = True, required: bool = True,
) -> Path | None: ) -> Path | None:
"""Return the AccuPedia workspace base path. """Return the AcuPedia workspace base path.
Resolution order: Resolution order:
1. explicit value 1. explicit value
@ -31,7 +31,7 @@ def workspace_base_path(
if not raw: if not raw:
if required: if required:
raise RuntimeError( raise RuntimeError(
f"{WORKSPACE_BASE_ENV} is required for relative AccuPedia paths." f"{WORKSPACE_BASE_ENV} is required for relative AcuPedia paths."
) )
return None return None
@ -49,7 +49,7 @@ def resolve_workspace_path(
*, *,
base_path: Path | None = None, base_path: Path | None = None,
) -> Path: ) -> Path:
"""Resolve an AccuPedia path deterministically. """Resolve an AcuPedia path deterministically.
Absolute paths are used as-is. Absolute paths are used as-is.
Relative paths are always resolved against ACUPEDIA_WORKSPACE_BASE_PATH, Relative paths are always resolved against ACUPEDIA_WORKSPACE_BASE_PATH,

View File

@ -23,6 +23,7 @@ def run_component(
component: str, component: str,
) -> None: ) -> None:
config = workspace.components[component] config = workspace.components[component]
print(config)
if not config.run_command: if not config.run_command:
raise RuntimeError( raise RuntimeError(
f"No run command configured for local component: {component}" f"No run command configured for local component: {component}"

View File

@ -19,4 +19,4 @@ all:
vars: vars:
ansible_user: ops ansible_user: ops
gitea_runner_instance_url: "https://gitea.example.com" gitea_runner_instance_url: "https://git.zedobject.local"

View File

@ -1,5 +1,5 @@
--- ---
- name: Deploy AccuPedia backend - name: Deploy AcuPedia backend
hosts: backend hosts: backend
gather_facts: true gather_facts: true
tasks: tasks:

View File

@ -1,5 +1,5 @@
--- ---
- name: Deploy AccuPedia database changes - name: Deploy AcuPedia database changes
hosts: backend hosts: backend
gather_facts: true gather_facts: true
tasks: tasks:

View File

@ -1,5 +1,5 @@
--- ---
- name: Provision AccuPedia infrastructure - name: Provision AcuPedia infrastructure
hosts: all hosts: all
gather_facts: true gather_facts: true
tasks: tasks:

View File

@ -7,7 +7,7 @@
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- ansible_os_family == "Debian" - ansible_os_family == "Debian"
fail_msg: "Initial AccuPedia remote setup supports Debian/Ubuntu hosts only." fail_msg: "Initial AcuPedia remote setup supports Debian/Ubuntu hosts only."
- name: Verify privilege escalation - name: Verify privilege escalation
ansible.builtin.command: /usr/bin/true ansible.builtin.command: /usr/bin/true
become: true become: true

View File

@ -3,7 +3,7 @@
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- ansible_os_family == "Debian" - ansible_os_family == "Debian"
fail_msg: "Initial AccuPedia remote setup supports Debian/Ubuntu hosts only." fail_msg: "Initial AcuPedia remote setup supports Debian/Ubuntu hosts only."
- name: Install common packages - name: Install common packages
ansible.builtin.apt: ansible.builtin.apt:

View File

@ -1,6 +1,6 @@
environment: dev environment: dev
backend: backend:
application_name: accupedia-api application_name: acupedia-api
database: database:
run_migrations: true run_migrations: true
infra: {} infra: {}

View File

@ -87,8 +87,8 @@ server {
return 301 https://acupedia.in$request_uri; return 301 https://acupedia.in$request_uri;
} }
# MinIO S3 Presigned Media Proxy (/accupedia-media/) # MinIO S3 Presigned Media Proxy (/acupedia-media/)
location /accupedia-media/ { location /acupedia-media/ {
proxy_pass http://minio_storage; proxy_pass http://minio_storage;
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;

View File

@ -1,6 +1,6 @@
environment: prod environment: prod
backend: backend:
application_name: accupedia-api application_name: acupedia-api
database: database:
run_migrations: true run_migrations: true
infra: {} infra: {}

View File

@ -1,6 +1,6 @@
environment: staging environment: staging
backend: backend:
application_name: accupedia-api application_name: acupedia-api
database: database:
run_migrations: true run_migrations: true
infra: {} infra: {}

View File

@ -96,12 +96,12 @@ services:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin} MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin} MINIO_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
MINIO_SECURE: "false" MINIO_SECURE: "false"
MINIO_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media} MINIO_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
MEDIA_STORAGE_SECURE: ${MEDIA_STORAGE_SECURE:-true} MEDIA_STORAGE_SECURE: ${MEDIA_STORAGE_SECURE:-true}
MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-http://localhost:9000} MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-http://localhost:9000}
MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin} MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin} MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media} MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
MEDIA_STORAGE_REGION: us-east-1 MEDIA_STORAGE_REGION: us-east-1
MEDIA_URL_TTL_SECONDS: 900 MEDIA_URL_TTL_SECONDS: 900
REDIS_HOST: redis REDIS_HOST: redis

View File

@ -1,6 +1,6 @@
# Local development # Local development
`acupedia-ops local ...` coordinates the local AccuPedia workspace. It does not `acupedia-ops local ...` coordinates the local AcuPedia workspace. It does not
replace the native development tools used by each repository. replace the native development tools used by each repository.
## Workspace model ## Workspace model

View File

@ -1,6 +1,6 @@
# Remote deployment foundation # Remote deployment foundation
AccuPedia remote environments are provisioned with Ansible through `ansible-runner`. Docker Compose is the runtime deployment mechanism on each target host. AcuPedia remote environments are provisioned with Ansible through `ansible-runner`. Docker Compose is the runtime deployment mechanism on each target host.
## Topology ## Topology

View File

@ -5,13 +5,14 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "acupedia-ops" name = "acupedia-ops"
version = "0.2.0" version = "0.2.0"
description = "Operational data-processing and deployment tooling for AccuPedia" description = "Operational data-processing and deployment tooling for AcuPedia"
readme = "README.md" readme = "README.md"
requires-python = ">=3.11" requires-python = ">=3.11"
dependencies = [ dependencies = [
"numpy>=2.0,<3.0", "numpy>=2.0,<3.0",
"opencv-python-headless>=4.10,<5.0", "opencv-python-headless>=4.10,<5.0",
"PyYAML>=6.0,<7.0", "PyYAML>=6.0,<7.0",
"ansible-runner>=2.4,<3.0",
] ]
[project.optional-dependencies] [project.optional-dependencies]

View File

@ -5,8 +5,8 @@ from acupedia_ops.common.config import load_config
def test_load_config(tmp_path: Path) -> None: def test_load_config(tmp_path: Path) -> None:
(tmp_path / "dev.yaml").write_text( (tmp_path / "dev.yaml").write_text(
"backend:\n application_name: accupedia-api\n", "backend:\n application_name: acupedia-api\n",
encoding="utf-8", encoding="utf-8",
) )
config = load_config("dev", config_root=tmp_path) config = load_config("dev", config_root=tmp_path)
assert config.values["backend"]["application_name"] == "accupedia-api" assert config.values["backend"]["application_name"] == "acupedia-api"

View File

@ -11,6 +11,7 @@ name = "acupedia-ops"
version = "0.2.0" version = "0.2.0"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "ansible-runner" },
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, { name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
{ name = "numpy", version = "2.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, { name = "numpy", version = "2.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
{ name = "opencv-python-headless" }, { name = "opencv-python-headless" },
@ -27,6 +28,7 @@ dev = [
[package.metadata] [package.metadata]
requires-dist = [ requires-dist = [
{ name = "ansible-runner", specifier = ">=2.4,<3.0" },
{ name = "ansible-runner", marker = "extra == 'deployment'", specifier = ">=2.4,<3.0" }, { name = "ansible-runner", marker = "extra == 'deployment'", specifier = ">=2.4,<3.0" },
{ name = "numpy", specifier = ">=2.0,<3.0" }, { name = "numpy", specifier = ">=2.0,<3.0" },
{ name = "opencv-python-headless", specifier = ">=4.10,<5.0" }, { name = "opencv-python-headless", specifier = ">=4.10,<5.0" },