Python and Bash scripts that eliminate toil, glue tools together, and form the building blocks of CI/CD pipelines. The difference between a hero who does things manually and a system that runs itself.
Python and Bash scripts that eliminate toil, glue tools together, and form the building blocks of CI/CD pipelines. The difference between a hero who does things manually and a system that runs itself.
Lesson outline
In The DevOps Handbook, every place in the value stream where a human copies commands from a wiki, re-types the same sequence of CLI commands, or manually clicks through a web console is a candidate for automation. Scripts are the first step: they capture what a human does and make it repeatable, parameterized, and auditable.
Toil vs engineering work
Google SRE defines toil as manual, repetitive, automatable work that scales linearly with service growth. Restarting a service manually every time it crashes is toil. Writing a script that detects the crash and restarts it automatically is engineering work. The script runs forever; the manual restart is forgotten the moment you close the terminal.
DevOps engineers are glue — they connect CLIs, APIs, config files, cloud SDKs, and monitoring systems. Scripts are the connective tissue. A deploy script that pulls the latest image, runs health checks, flips the load balancer, and sends a Slack notification is more reliable than any engineer doing it manually at 2am.
Both Bash and Python are essential in a DevOps engineer's toolkit, but they excel at different tasks:
When to use Bash
When to use Python
Scripts in production are code. They should be treated with the same engineering discipline as application code: version controlled, tested, reviewed, and documented.
Production scripting standards
Scripts do not exist in isolation — they are the building blocks that get assembled into CI/CD pipelines. The automation ladder describes how a manual task evolves:
Automation maturity ladder
Most teams operate between Level 1 and Level 3. Elite teams push toward Level 4 and Level 5. Every time you write a runbook, ask: can this be a script? Every time you run a script manually, ask: can this run on a schedule or trigger?
High-value scripting targets in DevOps
Scripting questions in DevOps interviews often include a live coding challenge: write a health check script, or fix a broken Bash script. Know `set -euo pipefail` cold — it comes up constantly. Be ready to explain idempotency with a concrete example (check before create). Understand the difference between exit codes 0 and non-zero and how pipelines use them. Have a story about automating a painful manual process and the measurable impact (time saved, error reduction). Bonus: understand Python subprocess vs shell — when to use `subprocess.run` vs os.system vs shell=True (never use shell=True with user input).
Quick check · Scripting for DevOps
1 / 4
Key takeaways
💡 Analogy
Scripting in DevOps is like building a factory assembly line vs handcrafting each product. A craftsman (hero engineer) can make one item at a time, perfectly. But a factory (script + CI/CD pipeline) makes thousands of identical items with consistent quality, no fatigue, and no sick days. The first factory is hard to build. But once running, it runs forever. Every time you replace a manual process with a script, you are building a factory. Every time you wire a script into CI/CD, you are making the factory run itself.
⚡ Core Idea
Scripting transforms toil (manual, repetitive, error-prone work) into automation (consistent, auditable, tireless execution). The key properties are: idempotency (safe to run multiple times), parameterization (works in any environment), proper exit codes (integrates with pipelines), and version control (auditable, reviewable, rollback-able).
🎯 Why It Matters
The engineering value of a script compounds over time. A 2-hour task done manually every week costs 100 hours per year. A 4-hour script that automates it saves 96 hours in year one and 104 hours every subsequent year. More importantly, scripts eliminate the risk of human error on the 47th repetition, at 3am, during an incident. The best DevOps engineers are prolific automators — they are always asking 'how do I make sure I never have to do this manually again?'
Ready to see how this works in the cloud?
Switch to Career Paths for structured paths (e.g. Developer, DevOps) and provider-specific lessons.
View role-based pathsSign in to track your progress and mark lessons complete.
Questions? Discuss in the community or start a thread below.
Join DiscordSign in to start or join a thread.