From manual commands to a CLI: planning, approving and verifying server changes

Moving server practice into a Go CLI: an exact plan, approval of its contents, a separate SSH verification session and handling a lost response.

A server blueprint passes through an approval gate to hardware and a separate inspection.

After configuring a server manually, it is easy to collect the commands into a script. Teaching it to distinguish a prepared state, an unrelated change and an operation whose response was lost is harder. Those distinctions shaped the plan → apply → verify sequence when we moved the practice into a Go CLI.

Disabling Nginx startup provides a concrete example. We exercised it on a separate Debian 13 VM used to test automation; the manual setup of the E‑01 learning VPS is described separately. At this stage the CLI is still not a complete server provisioning wizard.

A plan describes a particular state

Before making a change, the CLI reads installed packages, its own previous records and the service startup guards. The plan also binds the target server, selected SSH key, verified host key and evidence of an available independent console. A matching profile name alone cannot replace those checks.

The following is an adapted example of the implemented command. Replace the demo profile, private paths and SHA values with your own; the access files and original guard and package installation plans must already exist. No password is passed as an argument.

deploy-cli host nginx startup-disable-plan --profile demo \
  --request-file /private/administrator.json \
  --guard-plan-file /private/guard-plan.json \
  --guard-plan-sha256 <GUARD_PLAN_SHA256> \
  --package-plan-file /private/packages-plan.json \
  --package-plan-sha256 <PACKAGE_PLAN_SHA256> \
  --plan-file /private/startup-disable.json

The command creates a new local plan file with mode 0600. It does not overwrite an existing file. On the server it reads state through SSH and sudo, without disabling startup yet. Planning without server changes therefore still creates a local file.

This is the shortened actual response from that step in the VM. Only state fields remain; the plan hash and operational identifiers have been omitted.

{
  "status": "passed",
  "write_performed": false,
  "write_state": "none",
  "access_verified": true
}

access_verified records verified access within this command. write_performed: false means no managed host change took place. It does not mean Nginx is configured or a site is ready.

Approval applies to exact bytes

For apply, the operator supplies the SHA256 of the saved plan and separately approves the privileged operation. Editing the file after reviewing it makes the previous hash fail to match. A SHA is neither a password nor permission to change the server: it works alongside access checks, operation source checks and host state checks.

The state is read again before the first write. A plan does not reserve the server for future use. Another package installation, a foreign link or mismatched console evidence may invalidate it. The CLI then stops instead of adjusting the server to fit an outdated expectation.

Read a successful write through a new login

Apply is followed by a separate SSH connection using the selected key and a fresh password-based sudo check. It reads the result again and compares the fingerprint of the completed state. One successful writing session does not establish that a new login works and sees the intended files.

The startup-disable test used two separate authenticated SSH connections for that purpose. Reapplying a completed operation also performs a fresh read, but does not rename the files a second time. This is the behavior of this particular operation, not a general promise that any shell script can safely be repeated.

A lost response calls for inspecting state

After a connection drops, a write may not have started, may have completed or may have stopped halfway through. Automatically repeating apply can conceal that distinction. A durable journal is therefore maintained before changes, and an unknown result does not trigger an automatic retry.

A temporary-file test deliberately lost the response after the first real rename. An unfinished pending record remained; the next attempt neither renamed the files again nor removed the operation's traces. This tests a failure at the filesystem level, rather than cutting power to the VM.

The operator's sequence is straightforward: retain the plan and journal, restore independent access, inspect actual state and only then prepare another action. There is no automatic rollback here; the recovery console remains part of preparation. This CLI operation takes more work than one SSH command, but its outcome can be explained and checked.

Genuine terminal frame of a repeated VM verification. The response is shortened, with private paths and hashes omitted. Nginx remains inactive.
  1. Observability What to record before changing a server
  2. Operations & Security A separate administrator: from key login to the right privileges
  3. Operations & Security Recovering VPS access when SSH stops working
  4. Architecture Nginx on Debian: two public roots and HTTP access checks
  5. Platform Engineering First Symfony site on a prepared stack: Composer and file permissions