The automation job that should have stopped

A monitoring-agent update was authorized for twelve staging servers. By morning, ninety-six production machines had changed as well, even though the automation reported success. This lesson follows that fictional failure to expose the difference between carrying out a technicall…

The maintenance request was modest. Update the monitoring agent on twelve staging servers before the morning test run. At two in the morning, an engineer schedules the automation and goes back to another task. The following morning, ninety-six production servers have the new agent as well. The update itself appears to work. No machine has crashed. Yet the change has crossed an authorization boundary, and the team cannot say whether every production application is compatible with the new version.

This is an invented situation, but the design problem is familiar. The engineer did not ask for production to be changed. The automation selected its targets from a shared inventory, where a broad group included both staging and production machines. The script treated membership in that group as permission to act. It successfully performed the operation it had been given, and that operation was wider than the change anyone had approved. A job can be technically successful and operationally unacceptable at the same time.

Before asking how to automate a task, decide what the task is allowed to do. That boundary includes the intended targets, the permitted operations, the conditions that must be true before work begins, and the circumstances that require the job to stop. A helpful way to think about an automation run is as a temporary delegation of authority. A person is allowing software to make a series of changes on their behalf. If the person has not defined the limits of that delegation, the software will fill the gaps with whatever its selection rules and default behavior permit.

Suppose the team investigates why the ninety-six machines were included. The inventory has a label called application services. Originally that label described only staging servers. Over time, the organization reused it for production. The scheduling system still refers to the label, and the script assumes the label is sufficient. Notice that the defect did not require a spectacular programming mistake. It was a mismatch between an old assumption and a changing environment. The code never challenged the assumption before taking action.

The Bare Metal Cyber AutoOps+ study guide can be a useful companion after listening when you want to separate the technical steps in an automation process from the authority that makes those steps acceptable. For a proposed job, try describing the approved population and the condition that would cause you to refuse the work. A list of commands will not answer those questions. The study guide is independent educational material, and you do not need it in front of you to follow this example.

There are several ways to draw a reliable boundary around our agent update. The change request could identify a specific environment and service. The scheduler could supply a list of eligible machines obtained from a trusted inventory. The automation could require a matching change approval and refuse a target list that includes an unexpected environment. None of these is a magical single check. They become useful when they independently express the intended limitation. If the script asks one unreliable label whether a machine is staging and then asks the same label again, it has not gained independent assurance by checking twice.

The distinction between a request and a selection deserves attention. A request says what the organization wants to happen. A selection rule says which machines will receive the operation. Those can drift apart. A script that uses a wildcard to select every server whose name begins with the letters app might accidentally include an unrelated production database worker. A deployment group might be broadened by an administrator for another purpose. A cloud inventory might gain new instances while the job is running. Reliable automation compares its actual targets with the authorized purpose instead of assuming the two are always identical.

Consider a job expected to touch twelve machines. If it discovers thirteen, should it proceed with the first twelve? Perhaps one staging server was added and the request was merely outdated. Perhaps the thirteenth belongs to production because somebody mistyped a label. The script cannot determine the business meaning of that difference just by counting. A conservative design treats the unexpected population as a reason to pause for investigation or a rule-based review that was approved in advance. Count checks catch surprises, but counts alone do not identify which machine is wrong. The inventory itself and the approval boundaries still need examination.

The team now changes the selection process. The scheduler obtains an approved set of staging targets, records which inventory version produced that set, and passes those targets into the job. Before modifying anything, the job checks whether the machines still satisfy the required environmental constraints. This reduces the chance that a stale selection is used without question. It also introduces a deliberate decision about change during execution. If the inventory changes halfway through, should the running job silently include the new machine? For a bounded maintenance task, usually not. The new target can wait for another reviewed run.

This is where automation coding and operations policy meet. A function may accept a target as a parameter, but the existence of that parameter does not prove it is trustworthy. Inputs can come from a scheduler, a configuration file, an external service, or a human request. Each source can be missing, outdated, incorrectly formatted, or unexpectedly broad. The code must enforce the meaning of the input rather than merely accepting its shape. Later lessons will look closely at variables and types. For now, the central question is what evidence makes a particular input safe to act on.

Permissions provide another kind of boundary. Imagine the update process is given administrator rights across the entire company because that makes it convenient to reach any machine. The script may promise to work only in staging, but if that promise fails, the credential still authorizes production changes. Now imagine the same process has a credential that can manage the monitoring agent only on the approved staging population. Even a selection defect may be stopped by a separate access control. Least privilege is useful because it limits the damage when assumptions in another part of the design fail.

There is a catch. Access controls must be checked against the real operation, not described loosely as read-only or limited. Installing an agent may require specific write access. Some automation platforms permit operations at a broad account level even when a script filters individual machines. A credential that can modify every account resource offers much less protection than its friendly name suggests. The team should verify what the identity can actually change, how long it remains valid, and whether it can reach unrelated environments. An administrator credential stored in a convenient shared location is not a substitute for engineering the needed permissions.

At this point, the job still has not changed a machine. It can perform a preflight, which means checking the conditions that must hold before the maintenance begins. Those checks might include whether the approved maintenance period is active, whether the selected machines are reachable, whether enough healthy application capacity exists to tolerate the planned update, and whether the replacement agent has already been tested against the relevant service versions. Preflight does not guarantee an uneventful run. It converts known requirements into explicit reasons to delay work instead of discovering them after an outage.

A dry run can help, too, but it is easy to overestimate what it proves. A dry run might show the list of machines the automation intends to change and the actions it plans to request. That is valuable evidence about selection. Unless the tool explicitly simulates the full effect, it does not prove that the agent installation will succeed, that applications will remain healthy, or that the permissions will behave the same way during the actual change. A simulated success and a safe real-world outcome are different claims. The engineer needs to know which claim the test supports.

The team decides to begin with one staging server, confirm that the agent starts properly, and then extend the operation in small batches. Why use batches if the selection is already approved? Because correctness of targeting does not establish correctness of the change. A bad agent update could affect performance, memory use, or application health on every eligible machine. A limited first batch creates an opportunity to observe those effects before they spread. That observation is useful only if the automation knows what acceptable health looks like and has authority to stop the next batch.

This provides a natural place for the Bare Metal Cyber Cyber Wiki article on API token scope design if you want to explore the access side after the lesson. It explains the idea of limiting a machine identity by operation, resource, environment, and duration. Apply that idea to the staging update: a token that can install an agent on approved test machines should not quietly carry permission to reconfigure production networks. The article is optional reading. The operational point is that permissions should reinforce, rather than merely repeat, the script's stated boundaries.

Now the first batch runs. The job requests an agent update on one machine. The installation service reports that the request was accepted. The machine remains reachable, but the monitoring service has not yet produced a fresh measurement. Should the job proceed to the next batch? An accepted request is not a verified outcome. The job can distinguish the command it sent, the response it received, the change the target actually applied, and the health signal that confirms the intended result. If the proof of health has not arrived, a well-defined stopping rule should determine whether to wait, investigate, or end the rollout.

Suppose the job times out while waiting. A timeout establishes that confirmation was not received within the expected period. It does not always establish that the update failed. The target might have applied the update and lost its network connection before replying. Retrying without checking could reinstall the agent, interrupt the service, or create conflicting work. A safer recovery process asks whether the target already reached the desired state. The property often called idempotency means an operation can be repeated without continually changing the result after that desired state has been reached. Real maintenance scripts must be designed and tested for that property; it does not appear automatically because the same command is sent twice.

We should separate idempotency from rollback. An update may be safe to request again and still be difficult to undo. A new agent could change a local data format. A database migration could transform data that an older version no longer understands. In those cases, repeating the operation and reversing it are entirely different problems. The maintenance plan should state which changes can be reversed, what information needs to be preserved, and how the team will restore service if simply installing the previous version is insufficient. Calling a process reversible does not make it so.

The stopping policy must also make sense for partial success. Suppose eleven staging machines have updated cleanly and the twelfth has a persistent health failure. Do we roll back all eleven, leave them temporarily mixed, or repair the final machine separately? There is no universal answer. It depends on whether mixed agent versions are supported, whether the monitoring service requires consistency, and whether the older and newer versions can coexist safely. The job should expose its partial state clearly enough for the operator to make that decision. Hiding the eleventh success behind a single message saying the batch failed destroys useful information.

Good records identify the target, the intended action, the approval context, the attempt, and the confirmed result. They also show meaningful reasons for a refusal to act. An entry that says task failed is inadequate when the team needs to know whether the refusal came from a missing approval, a permission error, a health threshold, or an unreachable machine. Logs must be useful without becoming a place where credentials or sensitive configuration values are copied. An audit trail is evidence of what the automation reported doing; important effects may still need confirmation from the system being changed.

One subtle problem appears when the automation can keep running after someone notices a mistake. A job may have a stop button in its interface, yet workers that already received tasks can continue changing systems. A robust design defines what cancellation means. Can the scheduler prevent new work? Can a worker stop before starting its next target? Will an in-progress installation finish safely, or does interrupting it make recovery harder? Stopping new actions, interrupting current actions, and reversing completed actions are separate capabilities. Operators should know which ones exist before the emergency occurs.

Think again about our original ninety-six production machines. The team has two tasks after the unwanted update. One is to assess whether any production harm occurred and whether a controlled return to the previous state is necessary. The other is to repair the controls that allowed the job to exceed its authorization. Merely adding an extra confirmation prompt at scheduling time might not address the failure. If the operator cannot see the resolved target set, the prompt asks them to approve an assumption they have not verified. A meaningful approval must expose the scope being authorized.

An effective design does not place every safety decision on a person, either. If every routine job requires someone to read a hundred machine names, the process becomes slow and people start approving from habit. The better arrangement uses enforceable rules for predictable boundaries and human review for exceptions that genuinely require judgment. A policy could reject any staging job that selects a production resource, regardless of who clicked approve. A change owner could then review legitimate exceptions through a controlled process rather than weakening the default for everyone.

The same reasoning applies to smaller automation. Picture a scheduled cleanup job intended to remove temporary files older than a certain age. A typo changes its destination from the application's temporary directory to a shared storage area. A preview of the deletion scope, a restricted identity, a narrow allowed path, and a reasonable maximum deletion count each give the process another opportunity to stop. No one guardrail substitutes for knowing the actual target. Together they reduce the chance that a small specification error becomes a large operational incident.

A job can even be harmful without changing the wrong machine. Suppose a maintenance script runs against exactly the twelve authorized servers but updates all of them simultaneously. If the service requires a minimum number of healthy instances, the job may remove too much capacity at once. Authorization defines where the work may occur. Sequencing and concurrency controls define how quickly it may occur. Conditions for moving from one batch to the next belong in the plan because approved targets can still be disrupted by unsafe timing.

Operators often ask for more resilience by adding retries, broader permissions, and the ability to ignore errors. Each can be useful in a limited context. Together, without limits, they can turn an uncertain job into one that keeps acting even when evidence says to stop. A retry policy needs a bounded number of attempts or time limit. Permission expansion needs a justified and controlled approval. Ignoring a noncritical alert requires evidence that the condition is truly noncritical. Reliability is the ability to reach a trustworthy result, including a trustworthy refusal when the conditions are wrong.

A useful acceptance test for the revised job changes the assumptions deliberately. Give it a production target in an otherwise valid staging request. Give it an empty target list. Give it more machines than the approved limit. Remove the approval reference. Make the first server unreachable. Let the first server finish the update but lose its confirmation. These tests reveal whether the job respects the boundaries it claims to enforce. A test that only demonstrates success on the happy path cannot establish that the job is safe under the conditions operators actually fear.

When the team finally reruns the staging update, the important result is not merely that twelve agents were installed. The job selected the twelve intended machines, checked its authority and prerequisites, proceeded in controlled batches, confirmed the intended state, and retained evidence of what happened. If a boundary was violated, its correct result would have been to refuse the change. That refusal would be part of the successful operation of the control, not an embarrassment to hide from a status report.

Automation is powerful because it repeats decisions consistently and quickly. Those advantages become liabilities when the decisions were based on stale labels, ambiguous inputs, or permissions broader than the approved work. The engineer who designed the monitoring update did not need a more impressive script. They needed a clearer contract for what the script could change, stronger evidence before it acted, and defined behavior when the world no longer matched the plan. Carry that distinction into every automation task: executing the requested operation is only one part of doing the authorized job safely.

The automation job that should have stopped
Broadcast by