Thinking in Automation
Automation turns a task you do by hand into something a computer does the same way every time. It saves time, but its real value is consistency: automated deploys and backups do not forget steps at 2 a.m.
Is it worth automating?
Automate when a task is:
- Repeated: daily reports, deploys, backups, onboarding a client.
- Error-prone: many steps, easy to miss one.
- Time-sensitive: renewing certificates, rotating logs, sending reminders.
A simple test: (time per run × runs per year) compared with time to build. Then add the cost of mistakes, which is often the bigger number.
Properties of a good automated job
| Property | Meaning |
|---|---|
| Idempotent | running it twice does no harm (create only if missing) |
| Fails loudly | stops on the first error and tells someone |
| Logged | records what it did and when |
| Configurable | no hard-coded paths or secrets; uses arguments and env vars |
| Safe by default | has a dry-run mode; destructive steps need explicit flags |
Idempotency matters most. A PandaDev example: the learning content importer only creates modules that do not exist, so it can run on every deploy safely.
Choosing the tool
| Task | Good choice |
|---|---|
| Glue between shell commands, files, small server jobs | Bash |
| Logic, data processing, APIs, anything over ~50 lines | Python |
| Running something on a schedule | cron or systemd timers |
| Testing and deploying on every push | CI/CD (GitHub Actions) |
| Configuring many servers the same way | Ansible |
| Creating cloud infrastructure | Terraform (Cloud Fundamentals track) |
Plan before you code
Write the steps as plain sentences first:
- Dump the database.
- Compress it with today's date.
- Upload it off-site.
- Delete local copies older than 14 days.
- If any step fails, email the admin.
Each sentence becomes a function or a few lines. The list also becomes the script's documentation.
Check yourself
- Why is idempotency the most important property?
- When should a Bash script become a Python script?
- What is a dry-run mode for?
आपकी प्रगति केवल इसी ब्राउज़र में सहेजी जाती है।
समीक्षा के लिए भेजें (10 अंक)