LEADCHAPTER 13

Automating the network without breaking it

Decide what to automate from the harm and the repetition, climb from reading to changing in steps, and build the guardrails that let a script make a change safely: one tunnel at a time, a diff, a timed way back and a check that can fail

45 MINNETWORK ENGINEERUPDATED 2026-11-21
PREDICT

After the outage, Aondohemba, Larkhollow's network engineer, proposes replacing hand-typed tunnel changes with a script that reads a reviewed file and pushes the change to the gateways. What is the new risk that the script brings?

Most networks are still changed by hand, and most of the damage from hand changes comes from three things: a value typed wrongly, a change nobody recorded, and a check that could not fail. Automation can remove all three. It can also copy any of them to every device you own, faster than a person could. This chapter is about the lead’s decisions: what to automate first, how far up the ladder to go, and which guardrails must exist before a script is allowed to change anything.

It does not re-teach the pipeline. The workflow of plan, review and apply, state, modules and the approval of changes without a gate is in infrastructure as code and delivery, and the audit of repeated work, the payback arithmetic and the safety rules for automation that holds admin powers are in toil and automation. Read both. Here you learn what is different about a network: the device holds state that your repository does not, the other end of a link belongs to someone else, and the change that breaks things often does so hours later.

The company is Larkhollow, the AI agent and data platform with 300 people and 120 engineers. Its network is small and its tunnels matter more than their number, since the agents work only while they are up. Larkhollow has no separate network team. Its one network engineer, Aondohemba, sits in the connectors pod, the 20-engineer pod that builds the links to customers’ ticketing and ERP systems, and gives about six hours a week to network work. Forward deployed engineers in the company’s two pods set up each customer’s tunnel during a deployment, and some of them can log in to the gateways. Every count in this chapter is illustrative, and the Larkhollow tunnel figures are invented for the lesson.

The model: read, propose, apply

Automation is not one step. It is a ladder with three rungs, and each rung carries a different risk.

Rung What the machine does What can go wrong The guardrail that matters most
Read Collects configuration and state, compares it with intent, reports Silence read as health: the collector fails and nobody notices Alert when a collection fails, so no news is not read as good news
Propose Generates the change from a reviewed file and shows the diff A wrong value in the file looks right in the diff Checks against the live state and the peer before a person reads the diff
Apply Pushes the change, checks it and keeps or undoes it The mistake lands everywhere, fast Scope per run, a timed way back, a post-check that can fail

Climb one rung at a time, and stay on a rung until it has run for a quarter without surprises. Read is cheap, safe and useful by itself. The collected state is also the baseline for every later check and the saved copy a rollback needs, so the first rung pays for the third before it starts. A team that jumps straight to apply has nothing to compare the result with, which is how a pipeline ends up making unreviewed changes at machine speed.

Choose by harm and repetition

A network team does not have the toil profile of a service team. Changes are rare, a change that goes wrong is expensive, and many of the hours go on checking. If you only count hours, as the toil chapter teaches, you will automate the Monday morning look at every link and leave the tunnel change alone, because the tunnel change happens nine times a quarter and the look happens thirteen times. The outage was in the tunnel change.

So score each task on five questions and keep the answers beside the hours.

How often? A task done thirty times has a pattern you can capture. A task done twice a year does not, and a script for it will rot before it is used again.

How much harm when it goes wrong? Count customers and minutes: a tunnel that drops stops every agent working in that customer’s systems. Use incidents from your own records, as in troubleshooting a live fault, not a feeling.

Is it the same each time? A change that varies in shape every time is hard to automate safely. A change with three parameters and a known set of values is not.

Can you undo it, and can you tell? If you can save the old state and check the new one with a test that can fail, the task is a candidate. If neither is true, you are not ready to automate it, and the first job is to make it true.

Can you test it away from production? A lab, virtual devices, or a quiet gateway that carries nothing. Configuration analysers, such as Batfish, can also check a configuration against rules before it is pushed. If there is nothing to test on, the first rung is as far as you go.

The answers produce an order, and the order is rarely the one the hours give. The task that is rare, harmful, repeatable and testable goes first. The task that is rare, harmful and different every time stays manual, with better checks around it. The task that is frequent, harmless and read-only is built early for another reason: it gives the others their baseline.

What is different about a network

Four properties make network automation more careful work than automating a service.

The device is the truth, or the repository is. In a deployment pipeline the repository holds the intended state, and a nightly plan finds drift. A network device accepts changes from anyone with access, the console, a vendor tool or a colleague at night. Decide which is the source of truth and enforce it: the devices are read every night and compared with the repository, and a difference opens a ticket. A tool such as NetBox is built as a record of intended state that people maintain, and diagrams and documentation covers what it can and cannot tell you. The repository wins only if the read rung exists.

The other end is not yours. A tunnel has two ends, and your pipeline controls one. The settings must agree, and the other side changes on its own timetable. A check that reads only your gateway proves your gateway agrees with itself. Ask the peer’s state where the protocol lets you: the tunnel is established, the security associations show the proposal you expect, and traffic crosses in both directions. Where it does not, write the peer’s expected settings into the plan and have the customer’s network team confirm them in writing before the change.

The fault can arrive late. IPsec tunnels renegotiate their keys on a timer. IKEv2, defined in RFC 7296, replaces the keys of an established tunnel at section 2.8, “Rekeying”, and a setting the two sides disagree on can sit unnoticed until that moment. The change passes every check made at once and fails at the next rekey. This is the lag case from the changes chapter: a check that runs too early passes. The cure belongs in the automation, because a person at 18:10 on a Thursday will not remember it. The post-check forces a rekey inside the window and confirms the tunnel comes back on the new settings. Check that your gateways support this, and test it on a quiet tunnel first.

Overlaps and shared space. A customer’s address ranges can overlap yours, or another customer’s. A script that adds a subnet to a tunnel must check the new range against the addressing plan before it pushes, because an overlap that is accepted silently routes one customer’s traffic into another’s network. The check is a lookup in the plan, and it takes seconds.

Guardrails: what must exist before the script changes anything

The toil chapter lists the safety practices for any automation with admin powers: defensive input, a cap per run, idempotent steps, a default to a human and alerts on the automation itself. They all apply. This is the network version, in the order a change meets them.

  1. Intent in a reviewed file. The change is a pull request against the file that describes the tunnels. The reviewer sees the diff and the checks’ output beside it, not only the text.
  2. Input checks. The values are valid for this peer: the proposal is one the gateway supports, the subnet is in the plan and overlaps nothing, the peer address is the one on record. A bad value stops the run before any device is touched.
  3. A read before the write. The run collects the live state of the tunnel and saves it off the device with a timestamp. This is the saved state the rollback uses, and it is the baseline for the post-checks.
  4. Scope: one tunnel per run. The run changes one tunnel, checks it, and only then moves to the next. A run that lists forty tunnels is forty runs with a stop between each. Start with the least important customer and leave the largest for last, as the changes chapter says of waves.
  5. A diff and a dry run. The run shows exactly what it will send. In a pipeline, it posts that to the review.
  6. A timed way back. Use the platform’s own timed rollback where it has one, such as the confirmed commit in NETCONF, so the device undoes the change unless the run confirms it. Where it does not, the run keeps the saved state and restores it if a check fails.
  7. Post-checks that can fail. The control plane (the tunnel is established and shows the expected settings), the data path (a probe crosses it in both directions) and the service (a harmless read through the connector succeeds). Add the forced rekey from the last section. Give each a pass line, a fail line and a rule for the middle, as in the changes chapter.
  8. Stop on the first failure. The run does not go on to the next tunnel, and it does not retry in a loop. It rolls back this one, saves what it saw, and pages a person.
  9. A kill switch. One setting, held by the on-call, that stops every run at once, and a rule that nobody needs a meeting to use it.
  10. An audit record. Who asked, who reviewed, what was sent, what the checks said and what the run decided, attached to the change automatically. The record is the evidence for the customer and for an auditor. At Crustwell, where auditors sample 30 of a quarter’s 112 changes, a record that the pipeline writes for every change means that no sample can be a missing one.

Access. Decide who can run the job and who can change a gateway directly. If the forward deployed engineers can type into production gateways, the script has not removed the risk; it has added a second route. The target is that engineers request tunnel changes through the pull request and the pipeline applies them with its own short-lived credential, with a break-glass login that pages someone and ends in a pull request that brings the repository back in line. Identity, access and secrets covers the credentials. Firewall rules and access reviews shows the review that finds who can reach what today. The forward deployed engineer’s side of getting access to a customer’s systems is in a planned forward-deployed-engineer chapter on getting access to data and systems.

Review by a person, or by the pipeline

Some teams add a second person to every change. A second person is useful, and it fails in one specific way: the reviewer sees the same text the author saw. If the wrong value looks right to the author, it often looks right to the reviewer, and a reviewer at 17:30 with a queue reads a diff for typos, not for the peer’s policy. The checks in the pipeline look at different things from the person: the live state, the peer, the plan. A good design uses both. The pipeline does the checking that a machine does better, and the person decides whether the change should be made at all, and whether this is the right moment. Review alone, with a script behind it, only moves the typing to a file.

Keep the manual path

The SRE book’s chapter on automation notes that automation can leave operators out of practice. For a network the risk is sharper, because the day the automation is down is the day the network is too. Keep a short runbook for the manual path of each automated change, with the commands, the saved state’s location and the checks, and exercise it. Test it by doing a real change by hand once a quarter, on a quiet tunnel, with a colleague who normally uses the pipeline.

Where practitioners disagree

Automate everything, or the reading. One camp holds that anything done more than a few times should be code, and that manual changes are the defect. Another holds that read-only automation is where most of the value sits and that writing to devices is where most of the risk sits. Both are right in different networks. The answer depends on the rung your tests and your way back can support.

Controller or scripts. A vendor’s controller gives you intent, a diff and rollback in one product, and it ties you to the vendor’s model of the network. Scripts and templates against your own source of truth give you control and put the maintenance on you. A small team with several kinds of device usually ends up with scripts; a large estate of one vendor may be better with the controller.

Pipeline as the only door. The strict view closes the console, so nothing is changed outside the repository. The practical view keeps a break-glass login because an outage at night needs a way in that does not depend on a working pipeline. The compromise is the one in the access section: the login exists, it pages, and every use ends in a pull request.

Test networks. Some teams keep a full lab. Others test on virtual devices and analyse the configuration, because the lab never matches production. A lab that does not match gives confidence you have not earned, so write down what it does not cover.

Day to day

At Lead level, a Senior Network Engineer or Network Architect, you decide what the team automates and you set the rules every automation meets.

Weekly. Read the automation’s own report: runs, stops, rollbacks and collections that failed. A collector that has silently failed for a week is worse than no collector. Review the drift report and chase each unrecorded change to a person and a reason.

Per request. When someone asks for automation, ask for the task’s counts from the records: how often, how long, how many failures, what the harm was. Then answer with a rung, not a yes: read now, propose next quarter, apply when the checks exist.

Per change to the automation. The code, the file format and the checks are changed through review like any other change, and a change to a guardrail is reviewed more carefully than a change to a step. Take care with a change that widens scope, raises a cap or loosens a pass line.

Quarterly. Force a failure on a quiet tunnel: a check that should fail, a gateway that does not answer, a peer that rejects. Confirm that the run stops, rolls back and pages. Exercise the manual path. Re-read the inventory of tasks and move something up or down a rung.

After an incident. Ask two questions. Was the cause a change made outside the pipeline, and if so, why was that the easier route? Did the automation do something that a person would have stopped? Both lead to work on the guardrails, not to blame. The incident management chapter covers the response itself.

Telling the story. Report to the head of engineering in outcomes: changes made, changes that failed their checks and were caught, drift found and closed, hours given back. A count of scripts is not a result.

Where automation goes wrong

Automating the symptom. A script that re-applies a setting every hour hides the colleague who keeps changing it by hand. Find the cause.

No read rung. The pipeline pushes to devices whose state nobody has collected, so a failed check has nothing to compare against.

Scope without a stop. The run takes a list and works through it. The first failure is also the last, because it has already reached everything.

A check that cannot fail. The run reports success because the tunnel is up, which is what it also reported before the change.

Silent collectors. The nightly read stopped on Tuesday. The report is empty, and empty looks like no drift.

Two doors. The pipeline exists, and so does the habit of typing on the gateway. The repository and the device slowly disagree, and the next automated change overwrites a hand fix nobody recorded.

BY ORG SIZE
STARTUPunder 30 people

There is no network team, and one infrastructure engineer looks after the office, the cloud and perhaps two tunnels. Do not build a pipeline. Do the first rung: save every device’s configuration to a repository each night, and write a check of the tunnels that mails you when one is down or about to rekey. Change by hand, with the saved copy and a colleague on the phone. The risk is the single person who holds the only record of the settings.

SCALE-UP30 to 300

This is Larkhollow’s stage: a growing list of customer tunnels and one network engineer. The danger is two doors, a pipeline for the careful and the console for the hurried. Build the read rung first, then automate the one change that has hurt you, with the full set of guardrails, and close the console to the people who rely on it only after the pipeline serves them faster. Name who may stop all runs.

ENTERPRISE300 and up

Hundreds of devices, several vendors and a change board. Crustwell’s head office alone has 1,208 devices. The task is to turn the board’s evidence into something the pipeline produces: a standard change for the classes that pass the checks, the board’s time for the rest, and one record per change. The politics are about ownership of the source of truth and about who may bypass it. Report drift between the repository and the devices the way you report patch age.

ARTEFACT Write an automation plan with guardrails ~55 MIN
YOU PRODUCEA plan that ranks the network tasks by harm and repetition, places each on the read, propose or apply rung, names the guardrails for each automated change, and says what stays manual

Template

# Network automation plan: <team>, <quarter>

## Inventory (from the records of <period>)
| Task | Times | Minutes each | Hours | Failures or incidents | Can we undo it | Can we test it |
|---|---|---|---|---|---|---|

## Ranking
Harm · Repetition · Same each time · Undo · Test, one line per task, and the order that results.

## Plan by rung
| Task | Rung now | Rung next | Why | Build hours | Payback or named benefit |
|---|---|---|---|---|---|

## Guardrails for each automated change
Scope per run · Input checks · Saved state · Way back and its time · Post-checks (pass, middle, fail) · Late-fault check · Stop rule

## Access and control
Who runs it · Credentials · Who can stop it · Break-glass and how it is recorded

## Stays manual
<task> and the reason · The manual path and when it is exercised

## Measures and review date
WORKED EXAMPLE

Ojaline’s hub network, the plan for next quarter. Ojaline has nine city hubs, two of them core, run by one team of four on a one-in-four on-call rota, which owns the cloud networks as well as the hub links. The figures are illustrative.

Inventory, last 13 weeks (65 working days). Looking for unrecorded changes each morning: 65 times at 15 minutes, 16.25 hours, five unrecorded changes found. Hub VLAN and port changes: 34 at 20 minutes, 11.3 hours, none failed. Hub firewall rule changes: 15 at 40 minutes, 10 hours, two rolled back. Core routing-policy changes: 4 at 90 minutes, 6 hours, one caused an incident. In all, 2,615 minutes, about 43.6 hours.

Plan.

Task Rung now Rung next Why
Morning look for drift Manual Read Frequent and harmless. It gives every device a saved configuration with a timestamp.
Hub VLAN and port changes Manual Propose, next quarter Same shape each time and no failures. The hours do not justify more yet.
Hub firewall rule changes Manual Propose, after a quarter of the read rung Two of 15 rolled back, which is 13%. Apply waits for the saved state.
Core routing-policy changes Manual Pre-checks and the generated diff only Four a quarter, different each time, one incident. They stay manual.

Funded. The drift report: 24 hours to build, saving 16.25 hours a quarter, or 5.4 a month, with 1 hour a month to maintain. Payback is 24 ÷ (5.4 − 1), about 5.4 months. A pre-check and post-check pack for the 4 core and 15 firewall changes: 16 hours, and it does not pay back on hours. It is justified by the core incident, one in four changes, as the toil chapter allows when the benefit is named.

Guardrails for the read rung. Read-only credentials, so the collector cannot write. An alert when any of the nine hubs fails to collect. Every configuration saved with a timestamp, which also serves as a rollback copy.

Stays manual. The core routing-policy apply, with a second person and the generated diff. A manual run of a hub firewall change each quarter keeps the habit.

Review. In 13 weeks: unrecorded changes found and closed, collections missed, and the share of rolled-back changes.

Now you

You are Aondohemba, Larkhollow’s network engineer, and you sit in the connectors pod, whose lead gives you six hours a week for network work. Larkhollow has 26 customer tunnels. Last quarter’s records show: 13 Monday checks of every tunnel, 50 minutes each; 4 encryption-setting changes at 45 minutes each, one of which caused a 3 hour 10 minute outage when it failed at the next rekey; 3 subnet additions at 30 minutes; 2 peer address changes at 40 minutes; 18 firewall rule requests for connectors at 25 minutes, two of which had to be redone; and 3 monthly copies of gateway configurations at 20 minutes, one of which was stale when you needed it in the outage. The customers’ own network teams control the far ends. Forward deployed engineers in both pods can log in to the gateways today. Gateways from one vendor have an API, and gateways from another have only a command line and no timed rollback. Write the plan: rank the tasks, choose what to automate first, and set the guardrails, the access rules and what stays manual.

Self-check

DECIDE

Larkhollow has 26 customer tunnels. Last quarter there were 9 hand-made tunnel changes, four on encryption settings, three on subnets and two on peer addresses, at about 40 minutes each. One of them, a mistyped setting that failed at the next rekey, stopped a customer's agents for 3 hours 10 minutes. Aondohemba, the only network engineer, has about six hours a week for network work, and the forward deployed engineers need tunnel changes within days of a customer asking. There is a quiet test tunnel, and nothing is automated yet. What does Aondohemba build first?

READING
  1. BOOK
    Network Programmability and Automation, 2nd edition Matt Oswalt, Christian Adell, Scott S. Lowe and Jason Edelman, 2023

    The standard text for the job. Read it with the three rungs of this chapter in mind and see where it puts validation and a way back, and where it leaves them to you. Read: The chapters on source of truth, templates and the automation architecture; skim the tool chapters for your own vendors.

  2. DOC
    The Evolution of Automation at Google Google, in Site Reliability Engineering, 2016

    A long account of what automation buys and what it costs when it becomes the only way a system is run. Read the part on the hierarchy of automation classes against your own plan. Read: Chapter 7.

  3. DOC
    Eliminating Toil Google, in The Site Reliability Workbook, 2018

    The case for measuring toil and checking cost against benefit before you build. Use it for the arithmetic in your inventory, then add the harm column the network needs. Read: Chapter 6.

  4. DOC
    RFC 7296: Internet Key Exchange Protocol Version 2 (IKEv2) C. Kaufman, P. Hoffman, Y. Nir, P. Eronen and T. Kivinen, 2014

    The standard behind the tunnel that fails hours after a change. Read section 2.8 so you know when your gateways renegotiate, and what your post-check must provoke. Read: Section 2.8, Rekeying.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Leading a network outage →