Opscraft
Foundations: Linux, scripting, Git & networking

Python & Bash automation

New4 lessons · 23 min · 3 tests ·

Most Senior DevOps interviews in Bangalore include a scripting round: "parse this log and find the top 10 IPs", "write a script that cleans up unused EBS volumes", "call an API with retries", or a live Bash/Python exercise. The Linux topic covers shell fundamentals; this topic goes further into production-grade Bash, Python for automation (boto3, the Kubernetes client, HTTP APIs), packaging and testing your tools, and worked solutions to the classic coding-round problems.

Stage 1 · Foundations

Know these first

After this topic you can

  • Write safe Bash scripts with error handling
  • Automate AWS and API tasks in Python
  • Turn repetitive manual work into reusable tools

Lessons

  1. 1Production-grade Bash 8 min read
    • A robust script skeleton
    • Idioms worth knowing
    • jq for JSON (AWS CLI, kubectl, APIs)
    • When to switch from Bash to Python
  2. 2Python for automation 7 min read
    • A well-structured CLI tool
    • boto3 essentials
    • Kubernetes automation with Python
    • HTTP APIs with retries
    • Concurrency
    • Packaging, dependencies and quality
  3. 3Classic coding-round problems with solutions 5 min read
    • 1. Top 10 client IPs from an access log
    • 2. Count HTTP status codes and the 5xx ratio per minute
    • 3. Disk usage alert across hosts
    • 4. Find the largest files and directories
    • 5. Validate that all Kubernetes Deployments have resource limits
    • 6. Rotate/expire: delete S3 objects older than N days under a prefix (prefer lifecycle rules!)
    • 7. Health-check a list of URLs concurrently and exit non-zero on failure
    • 8. Parse YAML and diff two environment configs
    • Approach in a live coding round
  4. 4Interview questions and model answers 3 min read
    • "What does set -euo pipefail do and what are its pitfalls?"
    • "How do you handle pagination and throttling in boto3?"
    • "When would you choose Python over Bash?"
    • "How do you make an automation script safe to run in production?"
    • "Threads or asyncio or processes in Python?"
    • "Write a one-liner to find the top 5 URLs returning 500."