From b6f39d8d82bb804a40397f08f2ee38adea2f6a3e Mon Sep 17 00:00:00 2001 From: Amit Salunke Date: Sat, 26 Sep 2026 22:18:46 +0530 Subject: [PATCH] Added few playbooks --- .env.example | 2 +- MANUAL_SETUP_GUIDE.md | 6 +++--- README.md | 2 +- acupedia_ops/__init__.py | 2 +- acupedia_ops/ansible/runner.py | 13 +++++++------ acupedia_ops/bootstrap/api_cli.py | 8 ++++---- acupedia_ops/cli.py | 2 +- acupedia_ops/common/workspace_paths.py | 6 +++--- acupedia_ops/local/services.py | 1 + ...nners.example.yml => gitea-runners-acupedia.yml} | 2 +- ansible/playbooks/backend.yml | 2 +- ansible/playbooks/database.yml | 2 +- ansible/playbooks/infra.yml | 2 +- ansible/playbooks/preflight.yml | 2 +- ansible/roles/common/tasks/main.yml | 2 +- config/dev.yaml | 2 +- config/nginx/acupedia.conf | 4 ++-- config/prod.yaml | 2 +- config/staging.yaml | 2 +- docker-compose.dev.yml | 4 ++-- docs/local-development.md | 2 +- docs/remote-deployment.md | 2 +- pyproject.toml | 3 ++- tests/common/test_config.py | 4 ++-- uv.lock | 2 ++ 25 files changed, 43 insertions(+), 38 deletions(-) rename ansible/inventories/{gitea-runners.example.yml => gitea-runners-acupedia.yml} (89%) diff --git a/.env.example b/.env.example index 2b4156e..3ba18d4 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -# Local AccuPedia workspace. +# Local AcuPedia workspace. # Copy this file to .env and adjust for your machine. # # Do NOT commit .env. diff --git a/MANUAL_SETUP_GUIDE.md b/MANUAL_SETUP_GUIDE.md index 2e7ab5c..84ce0e0 100644 --- a/MANUAL_SETUP_GUIDE.md +++ b/MANUAL_SETUP_GUIDE.md @@ -39,7 +39,7 @@ With the clean Acupedia naming conventions: - **Database**: `acupedia_db` - **User**: `db_admin` / Password: `C1234spl` - **Volumes**: `acupedia-postgres-data`, `acupedia-minio-data` -- **MinIO Bucket**: `accupedia-media` +- **MinIO Bucket**: `acupedia-media` ### Start the containers: ```bash @@ -58,7 +58,7 @@ Applies the four schemas (`auth`, `content`, `commerce`, `platform`), tables, in ```bash 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) -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):** ```bash diff --git a/README.md b/README.md index 8e8c443..1291001 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # acupedia-ops -Operational tooling for AccuPedia. +Operational tooling for AcuPedia. The repository owns: diff --git a/acupedia_ops/__init__.py b/acupedia_ops/__init__.py index 6675d78..3043066 100644 --- a/acupedia_ops/__init__.py +++ b/acupedia_ops/__init__.py @@ -1,2 +1,2 @@ -"""AccuPedia operational tooling.""" +"""AcuPedia operational tooling.""" __version__ = "0.1.0" diff --git a/acupedia_ops/ansible/runner.py b/acupedia_ops/ansible/runner.py index e9c3a82..1b36c6d 100644 --- a/acupedia_ops/ansible/runner.py +++ b/acupedia_ops/ansible/runner.py @@ -6,6 +6,12 @@ from typing import Any, Callable, Mapping 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) class AnsibleRunResult: @@ -43,12 +49,7 @@ def run_playbook( event_handler: Callable[[dict[str, Any]], bool | None] | None = None, status_handler: Callable[[str, dict[str, Any]], None] | None = None, ) -> 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() inventory_path = _resolve_inventory(inventory) diff --git a/acupedia_ops/bootstrap/api_cli.py b/acupedia_ops/bootstrap/api_cli.py index 19a043c..dc850e9 100644 --- a/acupedia_ops/bootstrap/api_cli.py +++ b/acupedia_ops/bootstrap/api_cli.py @@ -28,20 +28,20 @@ def resolve_api_root(api_root: Path | None = None) -> Path: raw = os.environ.get("ACUPEDIA_API_PATH", "").strip() if not raw: 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." ) root = resolve_workspace_path(raw, base_path=base) 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(): - 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(): raise ValueError( - f"Invalid AccuPedia API repository; missing: {root / 'pyproject.toml'}" + f"Invalid AcuPedia API repository; missing: {root / 'pyproject.toml'}" ) return root diff --git a/acupedia_ops/cli.py b/acupedia_ops/cli.py index 69f761b..31a8b03 100644 --- a/acupedia_ops/cli.py +++ b/acupedia_ops/cli.py @@ -34,7 +34,7 @@ LOCAL_COMPONENTS = ("api", "mobile", "web", "admin") def _build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( prog="acupedia-ops", - description="AccuPedia operational tooling", + description="AcuPedia operational tooling", ) parser.add_argument( "--env-file", diff --git a/acupedia_ops/common/workspace_paths.py b/acupedia_ops/common/workspace_paths.py index 8c4938b..9faafd9 100644 --- a/acupedia_ops/common/workspace_paths.py +++ b/acupedia_ops/common/workspace_paths.py @@ -14,7 +14,7 @@ def workspace_base_path( *, required: bool = True, ) -> Path | None: - """Return the AccuPedia workspace base path. + """Return the AcuPedia workspace base path. Resolution order: 1. explicit value @@ -31,7 +31,7 @@ def workspace_base_path( if not raw: if required: raise RuntimeError( - f"{WORKSPACE_BASE_ENV} is required for relative AccuPedia paths." + f"{WORKSPACE_BASE_ENV} is required for relative AcuPedia paths." ) return None @@ -49,7 +49,7 @@ def resolve_workspace_path( *, base_path: Path | None = None, ) -> Path: - """Resolve an AccuPedia path deterministically. + """Resolve an AcuPedia path deterministically. Absolute paths are used as-is. Relative paths are always resolved against ACUPEDIA_WORKSPACE_BASE_PATH, diff --git a/acupedia_ops/local/services.py b/acupedia_ops/local/services.py index 5ee27a0..55c6989 100644 --- a/acupedia_ops/local/services.py +++ b/acupedia_ops/local/services.py @@ -23,6 +23,7 @@ def run_component( component: str, ) -> None: config = workspace.components[component] + print(config) if not config.run_command: raise RuntimeError( f"No run command configured for local component: {component}" diff --git a/ansible/inventories/gitea-runners.example.yml b/ansible/inventories/gitea-runners-acupedia.yml similarity index 89% rename from ansible/inventories/gitea-runners.example.yml rename to ansible/inventories/gitea-runners-acupedia.yml index f5bca20..250b15e 100644 --- a/ansible/inventories/gitea-runners.example.yml +++ b/ansible/inventories/gitea-runners-acupedia.yml @@ -19,4 +19,4 @@ all: vars: ansible_user: ops - gitea_runner_instance_url: "https://gitea.example.com" + gitea_runner_instance_url: "https://git.zedobject.local" diff --git a/ansible/playbooks/backend.yml b/ansible/playbooks/backend.yml index d4ca7d4..72d86e0 100644 --- a/ansible/playbooks/backend.yml +++ b/ansible/playbooks/backend.yml @@ -1,5 +1,5 @@ --- -- name: Deploy AccuPedia backend +- name: Deploy AcuPedia backend hosts: backend gather_facts: true tasks: diff --git a/ansible/playbooks/database.yml b/ansible/playbooks/database.yml index 384353d..cb881c7 100644 --- a/ansible/playbooks/database.yml +++ b/ansible/playbooks/database.yml @@ -1,5 +1,5 @@ --- -- name: Deploy AccuPedia database changes +- name: Deploy AcuPedia database changes hosts: backend gather_facts: true tasks: diff --git a/ansible/playbooks/infra.yml b/ansible/playbooks/infra.yml index 92b0322..c5f45dd 100644 --- a/ansible/playbooks/infra.yml +++ b/ansible/playbooks/infra.yml @@ -1,5 +1,5 @@ --- -- name: Provision AccuPedia infrastructure +- name: Provision AcuPedia infrastructure hosts: all gather_facts: true tasks: diff --git a/ansible/playbooks/preflight.yml b/ansible/playbooks/preflight.yml index e56b476..1a9730a 100644 --- a/ansible/playbooks/preflight.yml +++ b/ansible/playbooks/preflight.yml @@ -7,7 +7,7 @@ ansible.builtin.assert: that: - 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 ansible.builtin.command: /usr/bin/true become: true diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index 492d708..c6325fc 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -3,7 +3,7 @@ ansible.builtin.assert: that: - 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 ansible.builtin.apt: diff --git a/config/dev.yaml b/config/dev.yaml index dd07f8e..c96644a 100644 --- a/config/dev.yaml +++ b/config/dev.yaml @@ -1,6 +1,6 @@ environment: dev backend: - application_name: accupedia-api + application_name: acupedia-api database: run_migrations: true infra: {} diff --git a/config/nginx/acupedia.conf b/config/nginx/acupedia.conf index 0da466f..e4a210f 100644 --- a/config/nginx/acupedia.conf +++ b/config/nginx/acupedia.conf @@ -87,8 +87,8 @@ server { return 301 https://acupedia.in$request_uri; } - # MinIO S3 Presigned Media Proxy (/accupedia-media/) - location /accupedia-media/ { + # MinIO S3 Presigned Media Proxy (/acupedia-media/) + location /acupedia-media/ { proxy_pass http://minio_storage; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; diff --git a/config/prod.yaml b/config/prod.yaml index 0beb569..49fe6e1 100644 --- a/config/prod.yaml +++ b/config/prod.yaml @@ -1,6 +1,6 @@ environment: prod backend: - application_name: accupedia-api + application_name: acupedia-api database: run_migrations: true infra: {} diff --git a/config/staging.yaml b/config/staging.yaml index f1d266a..b5b6751 100644 --- a/config/staging.yaml +++ b/config/staging.yaml @@ -1,6 +1,6 @@ environment: staging backend: - application_name: accupedia-api + application_name: acupedia-api database: run_migrations: true infra: {} diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 2660086..7489e40 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -96,12 +96,12 @@ services: MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin} MINIO_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin} 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_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-http://localhost:9000} MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_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_URL_TTL_SECONDS: 900 REDIS_HOST: redis diff --git a/docs/local-development.md b/docs/local-development.md index e4e5e4c..15b4db4 100644 --- a/docs/local-development.md +++ b/docs/local-development.md @@ -1,6 +1,6 @@ # 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. ## Workspace model diff --git a/docs/remote-deployment.md b/docs/remote-deployment.md index ef77736..5c34288 100644 --- a/docs/remote-deployment.md +++ b/docs/remote-deployment.md @@ -1,6 +1,6 @@ # 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 diff --git a/pyproject.toml b/pyproject.toml index 718f904..70b13d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,13 +5,14 @@ build-backend = "setuptools.build_meta" [project] name = "acupedia-ops" 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" requires-python = ">=3.11" dependencies = [ "numpy>=2.0,<3.0", "opencv-python-headless>=4.10,<5.0", "PyYAML>=6.0,<7.0", + "ansible-runner>=2.4,<3.0", ] [project.optional-dependencies] diff --git a/tests/common/test_config.py b/tests/common/test_config.py index e3409d4..ef42af9 100644 --- a/tests/common/test_config.py +++ b/tests/common/test_config.py @@ -5,8 +5,8 @@ from acupedia_ops.common.config import load_config def test_load_config(tmp_path: Path) -> None: (tmp_path / "dev.yaml").write_text( - "backend:\n application_name: accupedia-api\n", + "backend:\n application_name: acupedia-api\n", encoding="utf-8", ) config = load_config("dev", config_root=tmp_path) - assert config.values["backend"]["application_name"] == "accupedia-api" + assert config.values["backend"]["application_name"] == "acupedia-api" diff --git a/uv.lock b/uv.lock index 3fa7e3b..24ec47b 100644 --- a/uv.lock +++ b/uv.lock @@ -11,6 +11,7 @@ name = "acupedia-ops" version = "0.2.0" source = { editable = "." } 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.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, { name = "opencv-python-headless" }, @@ -27,6 +28,7 @@ dev = [ [package.metadata] requires-dist = [ + { name = "ansible-runner", specifier = ">=2.4,<3.0" }, { name = "ansible-runner", marker = "extra == 'deployment'", specifier = ">=2.4,<3.0" }, { name = "numpy", specifier = ">=2.0,<3.0" }, { name = "opencv-python-headless", specifier = ">=4.10,<5.0" },