InterviewStack.io LogoInterviewStack.io

Python Scripting for Infrastructure Automation Questions

Applied Python skills for building reusable, production grade automation for infrastructure and operations. Topics include designing modular automation code and libraries, using relevant third party libraries for systems administration and remote management, invoking and controlling subprocesses, interacting with application programming interfaces and cloud platform endpoints, robust error handling and structured logging, automated testing of scripts and modules, packaging and distributing tools for reuse, secure credential management, integration with configuration management and orchestration tooling, and designing multi step workflows and idempotent operations. Candidates should demonstrate experience with writing maintainable automation, reasoning about failure modes, and selecting appropriate abstractions and libraries for operational tasks.

HardSystem Design
63 practiced
Design a scalable Python automation platform ('job-runner') that schedules and executes scheduled and event-driven jobs across many workers. Requirements: exactly-once or at-least-once semantics as appropriate, distributed locking or leader election, persistent job checkpoints, retries with backoff, role-based permissions for job definitions, multi-tenant isolation, metrics and tracing, and the ability to scale to 10k job executions per hour. Sketch the architecture, component responsibilities, storage choices (RDB, NoSQL, Redis), locking approach, and how to handle partial failures and recovery.
MediumTechnical
73 practiced
Write a Python script 'runbook-runner.py' that consumes a YAML runbook of steps like:
- name: create-db run: ./scripts/create_db.sh rollback: ./scripts/drop_db.sh
The runner must execute steps sequentially, support '--dry-run', support '--parallel' to run independent steps concurrently (assume the YAML indicates dependencies), and implement rollback behavior which executes rollback commands in reverse order if any step fails. Outline code structure, error handling, and how you would implement dependency-based parallelism and rollback ordering.
MediumTechnical
53 practiced
Implement a Python decorator '@instrument' that logs function entry and exit with JSON fields: function, args_hash, start_ts, end_ts, duration_ms, status, and exception info on failure. Use the standard logging module and design the decorator so overhead is minimal when instrumentation is disabled. Show code for the decorator and an example usage.
EasyTechnical
62 practiced
Design a module and package layout for a reusable Python infrastructure automation library that provides: a core action API (create_vm, provision_network), pluggable cloud provider adapters, utilities for retries and authentication, a CLI entrypoint, and plugin hooks for custom provider code. Sketch directory layout, main modules and responsibilities, and how you would write tests and documentation for contributors.
EasyTechnical
69 practiced
Explain structured logging and why it matters for automation scripts used by SREs. Provide a concise Python example using the standard 'logging' module that emits JSON logs with the fields: timestamp, level, message, module, trace_id, and duration_ms. Explain how to attach contextual information (like trace_id) to all log records and how structured logs integrate with log aggregators for search and alerting.

Unlock Full Question Bank

Get access to hundreds of Python Scripting for Infrastructure Automation interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.