A lot of what people proudly call automation is really just a recording of one successful manual run. It worked once, on a clean system, in the exact state the author happened to be in, and it has never been asked to run twice. The moment reality diverges even slightly, it half-completes, leaves a mess, and someone has to log in and untangle what the script did before they can safely try again. That is not automation. That is a landmine with good intentions.
The property that separates real automation from a fragile recording is idempotency, an ugly word for a simple idea: running the thing twice should leave you in the same correct state as running it once. If the resource already exists, the script should notice and move on, not error out or create a duplicate. If it was interrupted halfway, running it again should finish the job cleanly, not compound the damage. Automation you can safely re-run is automation you can trust. Automation you can only run once, on a perfect system, is a demo.
I learned this from a provisioning script that assumed it was always starting from nothing. The first time a run failed partway through, the retry made everything worse, because now half the resources existed and the script tried to create them all again from scratch. We spent longer cleaning up after the automation than the manual process would ever have taken. The script was fast at being wrong, which is the worst thing a script can be.
The habit I build now is designing every automation to answer one question before it acts: what is the current state, and what needs to change to reach the desired one. Not "do these steps," but "make reality match this description, whatever it takes from wherever we are." That shift, from a script of commands to a declaration of the end state, is most of what makes modern infrastructure tooling worth using. It is also a mindset you can apply to a plain shell script if you are disciplined about checking before you change.
The real test of your automation is not whether it works. It is whether it works the second time, after the first time failed. If re-running it terrifies you, you have not automated the task. You have just written down one lucky run.
– Serguey Shinder
Top comments (0)