service-status-app

Service
Log | Files | Refs | README

commit 60b5d80fb290ee2d4ab6029f7029dd5a37577f88
Author: Karl Eklund <localpart@gmail.com>
Date:   Fri, 27 Mar 2026 16:36:39 +0100

Add interview material

Diffstat:
Ainstructions.md | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apython_app/README.md | 27+++++++++++++++++++++++++++
Apython_app/main.py | 32++++++++++++++++++++++++++++++++
Apython_app/requirements.txt | 3+++
4 files changed, 119 insertions(+), 0 deletions(-)

diff --git a/instructions.md b/instructions.md @@ -0,0 +1,57 @@ +# Instructions +You are provided with a small Python web application. +The application fetches and exposes the status of an external service. +The application is intentionally minimal and may contain shortcomings. +Please complete the following tasks. + +### Containerization + +Create a Dockerfile for the application. +Requirements: + +* The application should run inside a container +* It should be accessible from your host machine + + +### Run it Locally + +Provide instructions or scripts to: + +* Build the Docker image +* Run the container locally + + +### Deployment with Ansible + +Write an Ansible playbook that: + +* Builds the Docker image +* Tags the image +* Runs the container locally + + +### Improvements + +Describe improvements you would make to the Python application. +Examples (not exhaustive): + +* Error handling +* Logging +* Structure +* Configuration + + +## Deliverables + +* Dockerfile +* Ansible playbook(s) +* Any scripts used +* README with instructions +* Short description of improvements + + +## Notes + +* The task should take no more than 1–2 hours +* Focus on clarity and practicality rather than completeness +* Keep solutions simple and well-structured diff --git a/python_app/README.md b/python_app/README.md @@ -0,0 +1,27 @@ +# Minimal FastAPI App for DevOps Interview + +This is a small FastAPI application intended for a DevOps / SysAdmin interview task. + +It exposes: +- `GET /` - simple health-style message +- `GET /status` - fetches and returns a simplified status from a public status API +- `GET /status/raw` - returns the full upstream response + +## Run locally + +```bash +python -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +uvicorn main:app --host 0.0.0.0 --port 8000 +``` + +Then open: +- `http://localhost:8000/` +- `http://localhost:8000/status` + +## Environment variables + +- `STATUS_URL` - upstream status endpoint to query + + diff --git a/python_app/main.py b/python_app/main.py @@ -0,0 +1,32 @@ +from fastapi import FastAPI, HTTPException +import os +import requests + +app = FastAPI(title="Service Status App") + +STATUS_URL = os.getenv("STATUS_URL", "https://www.githubstatus.com/api/v2/status.json") + + +@app.get("/") +def root(): + return {"message": "Service status app is running"} + + +@app.get("/status") +def get_status(): + try: + response = requests.get(STATUS_URL, timeout=5) + data = response.json() + return { + "source": STATUS_URL, + "indicator": data["status"]["indicator"], + "description": data["status"]["description"], + } + except Exception as exc: + raise HTTPException(status_code=500, detail=f"Failed to fetch status: {exc}") + + +@app.get("/status/raw") +def get_raw_status(): + response = requests.get(STATUS_URL, timeout=5) + return response.json() diff --git a/python_app/requirements.txt b/python_app/requirements.txt @@ -0,0 +1,3 @@ +fastapi==0.115.0 +uvicorn[standard]==0.30.6 +requests==2.32.3