Design Principles#
A network automation team took the endeavor seriously, and after learning how network automation should be built, they created a solid architecture: structured intent data models, an engine to render configurations for devices from them, and a workflow to validate the risk of changes and push them via programmatic interfaces (with rollback support). The demo to the leadership team went well. Excellent!
Then, they handed it over to the network operations team to manage their network like bosses. However, adoption never came. They preferred the Command Line Interface (CLI). The automation team was disappointed, and when they asked them why they were not using the automation, the answers were consistent: “I don’t know what it’s going to do before it does it.” “If something goes wrong, I can’t tell what happened.” “I don’t understand how to read the output.” What the automation team understood clearly was completely opaque to the people who should run it and take responsibility for its outcome.
They had no way to validate what was going to change in the network, nor an audit trail of what steps were actually executed. The system was a black box for them, and you cannot trust what you do not understand. A year of effort sat unused.
That outcome is more common than anyone will admit, and I have seen it very often. Network automation initiatives will not succeed if the people who own the network operational responsibility do not trust the system. They have years of trust in the CLI; could you give them the same? The answer is yes, you can, if you adopt design principles that make network automation reliable, scalable, and safe.
These principles are not rocket science. All of them also apply to other software projects, but in this book we will approach them from the unique characteristics of the network, a critical infrastructure asset. Network engineers have built and maintained networks for decades using a process (based on caution and manual verification) that we are asking them to change. Let me tell you something: to promote change, start by earning trust.
Building Trust#
Start with trust, because without it network engineers will not adopt your automation. They need to believe that automation provides at least the same level of confidence as the manual processes it replaces (plus other benefits).
Even trickier: automation systems are often built by engineers who may not have deep networking experience. So automation must compensate by embedding strong, explicit characteristics that make it safe, dependable, and easy for network engineering teams to customize and manage.
The relevance of trustworthy automation is inspired by Damien Garros’s presentation Building Trustworthy Network Automation at AutoCon3.
To keep it simple, here are the four basic characteristics every system has to offer, summarized in Figure 2.1:
- Predictable: Consistent, deterministic outcomes. Engineers need to know what will happen before they press “go”, and get the same behavior every time.
- Reliable: Handles errors gracefully. Recovers from failures. Ensures operations complete safely (or roll back) even under unexpected conditions and at scale.
- Usable: Interfaces that let engineers validate, reason about, and control behavior without excessive complexity. With guardrails.
- Understandable: Cannot be a black box. Must expose intent, steps, results, and decisions in a way that builds human confidence.
Predictability or deterministic behavior is becoming increasingly relevant as Artificial Intelligence (AI) and Machine Learning (ML) technologies enter the network automation domain, because these introduce some randomness that needs to be kept within guardrails.
These qualities are not optional, and the engineers who depend on the automation must be able to see them for themselves.
I have built many network automation solutions. Nothing is more frustrating than watching a well-engineered solution get ignored or abandoned because network operators did not trust it. These principles help you avoid that outcome.
So, given these characteristics, here are the principles that support them.
The Six Foundational Principles#
The full list could be much longer (we will expand it later when introducing other principles from software engineering). But there are six fundamental principles that every network automation solution should incorporate:
- Intent-Driven: Define the desired state of the system under different conditions. Improves predictability, reduces cognitive load, makes the system more usable.
- Idempotency: Same operation multiple times = same final state. Reduces side effects, removes ambiguity, makes automation more understandable and safe to repeat.
- Transactional: Changes complete fully or fail safely. A change left half-applied is detected and recovered, never silently left behind. Essential for predictability and enables network-wide rollbacks.
- Versioning: Support versioning of both data and logic. Move backward or forward in time, recover previous states, maintain multiple states in parallel. Reinforces predictability and strengthens reliability.
- Testable: A proper testing environment is essential before executing changes in production. Improves reliability and helps engineers understand system behavior.
- Dry-Run Friendly: Show what it would do before doing it. Makes automation more usable and trusted by letting humans validate actions, visualize outcomes, and detect issues before they hit the network.
These principles are not exclusive to networking. They apply to automation across any IT domain. But they become especially critical in networking, where changes carry significant operational risk.
Figure 2.2 shows how each one supports trust.
Each of these design principles deserves more context. We will explore them in an order that reflects their logical dependencies: start with defining what we want to achieve, then ensure it happens safely and correctly, and finally validate that it works.
Intent-Driven#
Why start with intent? Before discussing how to execute automation, we need to understand what we are trying to achieve. Intent-driven design is the foundation everything else builds on.
A common use case to start with automation: scripts or playbooks that execute simple actions. Turn an interface up or down by providing the Fully Qualified Domain Name (FQDN) and interface name. This works, but it creates a problem. The next person who works with that interface will not know what its desired state is. Should it be up or down?
This issue affects both manual and automated operations. But with automation, the problem gets worse. You cannot confidently infer network intent from its current state, especially when many ad hoc changes have been applied.
Someone might argue that their intent is simply the actual state of the network: “check the config, that’s my intent.” Technically, that is an intent. But without a separate source to compare against, you cannot prove it still matches what you meant, or that circumstances have not altered it. The network configuration is the output of your intent, not the intent itself.
Intent manifests at different levels depending on your variability and customization needs. Very small environments may require less variable data and can rely more on templates (but this is an antipattern that will turn against us at some point, as the Constants are data too warning in Chapter 6 explains). Other data may require cross-team review, while some can be updated following conventions and guardrails.
So the quality of your intent-driven data directly determines the quality of your automation. This concept is closely related to the Source of Truth (SoT), which Chapter 4 and Chapter 5 cover in detail.
Infrastructure as Code (IaC): Intent-driven automation is the foundation of IaC: treating network infrastructure definitions like software code. With IaC, you get version control, code review processes, testing, and the ability to treat infrastructure changes the same way you treat software changes. This bridges network automation with software engineering best practices. IaC keeps templates, inventories, and intent as files under version control. Changes are reviewed, tested, and traced, not applied as one-off CLI edits.
Building on intent, the next principle ensures that once we know what we want, we can execute it safely and consistently.
Idempotency#
Why idempotency matters: Idempotency ensures that repeated executions produce the same result. Essential because automation often runs multiple times by accident, by retry mechanisms, or by design. Without idempotency, each run could make unpredictable changes.
Idempotency means running the same operation multiple times results in the same final state, with no unintended side effects.
For example, in automated ACL provisioning, if we define a rule, we expect:
- If the rule does not exist, it is added in a specific position.
- If the rule already exists, do not add duplicates.
- If another rule is added later, the previous one remains untouched and is not reordered.
Sounds like common sense, but the reality is more complex. The system must implement logic to ensure idempotency. For example, it needs to check:
- What is the current state of the ACL?
- Is the rule already part of it?
- If not, what difference needs to be applied?
Without idempotency, a retry can duplicate entries or apply a change twice.
Idempotency applies to the different dimensions of network automation. For example, it applies when requesting an Internet Protocol (IP) address via DHCP or from an IPAM system that understands the mapping between the request identifier and the result. Figure 2.3 shows the exchange:
As you will read later, to achieve idempotency, prefer using declarative models instead of imperative ones. Define the end state, and let the system work out the steps. This does not mean using imperative mode is impossible, but it is more complicated.
Idempotency makes repeated executions safe. The transactional principle handles the other case: a change that stops partway across several systems.
Transactional#
Why transactionality matters: Network changes often affect multiple devices simultaneously. Without transactionality, a failure partway through leaves the network in an inconsistent state: some devices updated, others not. Especially problematic in distributed systems where coordinating across multiple actors is inherently complex.
Transactional behavior is a common concept in databases, where multiple changes are applied atomically to maintain consistency. In networking (a distributed system), transactionality is even more complicated, but it is not a new problem. NETCONF (RFC 4741 in 2006, revised as RFC 6241 in 2011) gave each device a candidate configuration that can be validated and committed as one unit. It also added a confirmed commit, which rolls back on its own if nobody confirms it. That makes each device’s change an atomic operation. Across many devices, NETCONF gives you the building blocks, not the transaction. An orchestrator has to coordinate the per-device commits, or some devices change and others do not: a nightmare to troubleshoot. Not all devices support NETCONF either, so the practical answer depends on your infrastructure.
Providing transactional behavior prevents partial or broken operations (which are hard to troubleshoot and leave systems in unpredictable states) and is essential to avoid eroding trust in your automation. A network where some devices applied a change and others did not is worse than a network that rolled back completely.
So, generally, how could we apply transactionality to networking? This is a combination of techniques:
- NETCONF: Per-device candidate configuration, validation, and confirmed commit, which an orchestrator can coordinate across devices
- Database-backed transactions: Store configuration changes in a database with Atomicity, Consistency, Isolation, Durability (ACID) properties (more in Chapter 5), then apply them in coordinated batches with rollback capability
- Change notification queues: Capture all intended changes, validate them as a group, then execute with a coordinated rollback mechanism if any device fails
- Two-phase commit patterns: Stage and validate the change on every device first (phase 1), and abort everywhere if any device fails to prepare. Only then commit (phase 2). A device that fails in phase 2 needs a retry or a compensating change, because the others have already committed. The nearest network equivalent is a confirmed commit on each device, then one confirm across all of them
- Transactional logs: Record every change attempt with sufficient detail to undo partial operations manually or automatically
Every one of these mechanisms needs a way to roll back: a commit or snapshot that can be activated (internally or externally to the platform) to move to a previous state. This is not always available. Where true atomic commits are not available, implement a validated “prepare” stage and use an orchestrated coordinated commit or staged rollout to reduce risk.
These techniques do not give the same guarantee. Table 2.1 sorts them by what each one actually promises.
| Scope | What it guarantees | Example | What it does not cover |
|---|---|---|---|
| Device-level atomicity | One device takes all of the change or none of it | NETCONF candidate and commit, confirmed commit | The other devices in the same change |
| Coordinated commit | Every device is staged and validated before any commits | Two-phase pattern over confirmed commits | A device that fails after the others committed |
| Compensation | Each completed step has a declared undo, run in reverse | Saga Pattern (Chapter 8) | Side effects that do not reverse, such as a flapped BGP session or dropped traffic |
| Best effort with detection | A partial change is recorded and visible | Transactional log, pre-change snapshot | The recovery itself: a human or a later run finishes it |
Read the table from the bottom up. Every Network Automation Platform (NAP) needs the last row, because partial completion is a failure mode you design for, and no transactional label removes it. The rows above it make that failure rarer and smaller.
This principle naturally connects to versioning: when something goes wrong, you need to know what state you are in so you can roll back to a known-good version.
Versioning#
Why versioning matters: Every change carries risk. Versioning lets you know exactly what changed, when it changed, who changed it, and provides the ability to revert if needed. Foundation of safe operations at scale.
Historically, network engineering managed change through configuration backups: snapshots used for rollback purposes. However, reconciling post-change state after a rollback is extremely complex because backups lack context.
In software engineering, a Version Control System (VCS) such as Git is standard practice (luckily for me, I have not worked in any environment without some form of VCS). These systems enable:
- Easy collaboration: Multiple developers contribute code or data and can move forward on different branches
- Time travel: Return to previous points in history to understand what changed and when
- Atomic grouping: Multiple file changes can be bundled together as a single unit
Applying versioning to network automation provides significant benefits:
- Auditability and Traceability: Easily track who changed what and when, making the system transparent
- Cross-team Collaboration: Facilitates review of changes and enables team-based automation development
- Atomic Operations: Related changes across multiple files can be applied together, preventing partial or incomplete states
- CI/CD Integration: Automated pipelines can trigger testing and validation whenever code changes are detected
Configuration templates are a prime example of code that benefits from versioning. A single template change impacts all derived configurations across the network, so version control becomes essential. The same goes for the intent data the templates render: in general, all data should be stored in a versioned way. It is common to keep that data as versioned YAML or JavaScript Object Notation (JSON) files.
GitOps: An emerging pattern that takes versioning further. The Git repository becomes the authoritative record of intent, and a controller continuously compares it with the actual state in the network, correcting drift automatically. It is gaining adoption in network automation, especially in cloud-native and Kubernetes-integrated environments. For network devices, automatic correction is a separate decision: Chapter 11 explains why, and Chapter 16 covers when to allow it.
Versioning provides the history and audit trail. The next principle ensures we validate that changes work correctly before deployment.
Testable#
Why testability matters: Automation at scale amplifies errors. A bug in a playbook that affects one device is manageable. The same bug applied to 10,000 devices is a disaster. Testing is your safety net before deploying to production.
Testing is particularly challenging in networking. Often you do not own the entire network (think of internet Border Gateway Protocol (BGP) peerings, where you do not own the other side), or the scale is prohibitive (imagine testing a data center fabric with thousands of switches). Reproducing real test scenarios can be near-impossible or prohibitively expensive.
This does not mean you are without options. You can implement testing at multiple levels that validate automation behavior and network state under various circumstances.
The testing pyramid in Figure 2.4 provides a useful framework:
- Unit Tests validate data quality, basic logic, and specific behaviors in isolation using mocks or fake systems. They run quickly and catch fundamental errors early.
- Integration Tests introduce third-party systems in a simulated (and simplified) environment. Different automation components interact with each other and simulated network flavors, allowing you to validate integration points (for example, faking the Application Programming Interface (API) or Secure Shell (SSH) CLI interface of a network device).
- End-to-End Tests validate behavior in near-real scenarios using virtualized network environments or labs simulating part of your production network (we will go deeper on this topic in Chapter 10).
AI code assistants are increasingly useful for test generation. If you can articulate what to test, these tools can help create comprehensive test suites quickly (and catch logic flaws that you may not spot at first glance).
Automation requires continuous testing to ensure nothing breaks as systems grow. A regression introduced late in development is far more expensive than one caught during unit testing. As your automation scales, this becomes non-negotiable.
Advanced Testing Strategies:
- Chaos Engineering: Intentionally inject failures (device outages, network latency) to validate that your automation and monitoring handle them gracefully (Netflix popularized this approach with their Chaos Monkey framework).
- Property-Based Testing: Define properties that must hold for any valid input (for example, every VLAN ID your schema allows renders a configuration the device accepts, which quickly finds the IDs a platform reserves) and let the framework generate the inputs.
Finally, before deploying any changes, operators need visibility into what will happen.
Dry-Run Friendly#
Why dry-run capability matters: Even with all the previous safeguards, humans need to understand what automation will do before it executes. Dry-run capability bridges trust and action: it shows operators exactly what will change before any change is made.
In any major decision, understanding the plan of action before execution is critical. When building a house, you want to see how it will look before approving construction. Similarly, in network engineering, we are accustomed to change management processes that review execution plans before deployment.
With network automation, the frequency and scope of changes can increase dramatically. Providing operators with clear visibility into what will be executed before it happens is essential for building confidence and enabling proper review.
There are tools that provide this dry-run capability, but you can always create your own if needed:
- Ansible: The
--checkand--diffflags show what would be changed - Terraform: The
terraform plancommand displays the difference between current and desired state - Custom Network APIs: Some may expose a “dry-run” or preview mode
Listings 2.1 to 2.3 show what this visibility looks like in three tools:
- description: Uplink to CoreSwitch1
+ description: Uplink to CoreSwitch2
mtu: 9216
~ description = "Uplink to CoreSwitch1" -> "Uplink to CoreSwitch2"
mtu = 9216
{
"operation": "PATCH",
"path": "/interfaces/Gi0-1",
"changes": [
{
"field": "description",
"current_value": "Uplink to CoreSwitch1",
"proposed_value": "Uplink to CoreSwitch2"
}
],
"unchanged": { "mtu": 9216 }
}Dry runs transform automation from a “hope for the best” approach into a deliberate, reviewable process.
A dry run can go beyond this configuration diff and answer harder questions about the outcome of a change, such as its effect on operational state:
- Impact Analysis: Beyond showing what changes, analyze the impact on operational state, and communicate the business impact (e.g., “This will temporarily affect 10% of traffic”)
- Staged Rollouts: A dry run predicts; a staged rollout tests the prediction. Apply the change to a small subset of devices first, and validate its impact before the full deployment (Chapter 8)
- Network Simulation: Combine with network testing tooling to execute dry runs against a replica of your production network
Automation amplifies whatever you feed it. Clean, well-designed processes become more efficient and reliable. But poor design, bad data, or flawed logic also scale, creating bigger problems faster.
Why These Principles Matter: Learning from Failures#
The Meta Outage Case Study
In October 2021, Meta (formerly Facebook) suffered a global outage that took its services offline for about six hours. Meta’s own account is short. During routine maintenance, a command was issued to assess the capacity of the global backbone. The command took down every backbone connection instead, cutting the data centers off from each other. Meta’s tooling was supposed to audit commands like this one and stop them, but a bug in the audit tool let it through.
The damage then spread through dependencies. Meta’s DNS servers, unable to reach the data centers, withdrew their BGP advertisements, so the rest of the internet could no longer find Meta at all. The internal tools engineers would normally use to diagnose and repair the network ran on the same network. Engineers had to go to the data centers in person, and bring the load back slowly to avoid power and traffic surges.
Meta’s write-up does not say how its automation was built, so the list below makes no claim about it. It shows what the principles in this chapter are for, applied to this kind of failure:
- Dry run and impact preview: a command that would remove every backbone link should show that before it runs.
- Validation that fails closed: when the check itself is broken, the change stops instead of passing.
- Blast-radius limits: no single command, human or automated, should reach the whole backbone at once.
- Graceful Degradation and independent access: the tools you need to repair the network should not depend on that network, a point Chapter 12 returns to for the automation itself.
The principles in this chapter (intent-driven, idempotency, transactional, versioning, testable, and dry-run capability) address these failure modes. Build them in from the start; they are much harder to add later.
The Lesson: Do not automate chaos hoping to fix it later. Instead:
- Start with processes you understand and can validate
- Automate incrementally, learning from each step
- Treat every automation failure as a learning opportunity
- Build in safeguards: rate limits, rollback mechanisms, observability, blast-radius containment
- Separate concerns so failures in one area do not cascade globally
Notice how this connects with the People, Process, and Technology approach introduced in Chapter 1.
Beyond the six design principles, there are key patterns and considerations that bridge theory with practical implementation.
Architectural Decision Patterns#
These patterns help you make strategic decisions about your automation architecture.
Declarative vs. Imperative#
The choice between declarative and imperative approaches is fundamental. Each has strengths and trade-offs, depending on the use case. Managing infrastructure configuration can take two approaches:
- Declarative automation defines the desired end state; the system figures out how to achieve it. Example: “I want interface Gi0/1 to have an MTU of 9000.” The automation engine determines the current state and applies only necessary changes. Focuses on WHAT, the desired outcomes.
- Imperative automation specifies the exact steps to execute. Example: “Show interface config, parse it, calculate the difference, send these exact CLI commands in this order.” Focuses on HOW, the specific actions.
Declarative approaches make idempotency and dry runs much easier, because the system compares desired and current state before it acts. They do not make a change transactional on their own; that still depends on what the target supports.
Imperative approaches offer precise control but are harder to make idempotent and more prone to unintended side effects. However, they may be the only option when your target system lacks declarative capabilities.
The key trade-off: declarative approaches scale better. Once a declarative module exists, each new case costs little, while imperative approaches grow more complex with every edge case the steps must handle.
Most modern automation frameworks (Terraform, Ansible, Kubernetes, or tools built on Yet Another Next Generation (YANG) models) trend toward declarative models while allowing imperative fallbacks when needed (e.g., Ansible raw modules, direct CLI, Netmiko).
Some tools like Ansible can function both ways depending on the module type. Network-specific modules (like cisco.ios.ios_interfaces) are declarative, while ansible.netcommon.cli_config sends imperative commands. Listing 2.4 shows both approaches:
- name: Imperative vs. Declarative Approaches in Ansible
hosts: switches
gather_facts: no
vars:
interface_name: GigabitEthernet0/1
new_description: Uplink to CoreSwitch2
tasks:
- name: IMPERATIVE - Execute exact commands
ansible.netcommon.cli_config:
config: |
interface {{ interface_name }}
description {{ new_description }}
no shutdown
# Sends the commands on every run, and cannot tell whether anything was different
- name: DECLARATIVE - Define desired state
cisco.ios.ios_interfaces:
config:
- name: "{{ interface_name }}"
description: "{{ new_description }}"
enabled: true
state: merged
# Repeating this task is safe: it converges to the desired stateKeep in mind that with a declarative approach, you are offloading the logic to an external system, and in some scenarios, that may not be an available option. Notice in the previous example how you leverage an Ansible module
cisco.ios.ios_interfacesthat implements the logic needed to provide the declarative flavor.
The declarative approach is safer and more predictable, but requires module support for your specific device.
Mutable vs. Immutable Infrastructure#
The basic concept is: Do you allow in-place modifications to infrastructure (the network), or do you replace infrastructure entirely when changes are needed?
- Mutable Infrastructure: Traditional approach where you SSH into devices and modify configurations directly (or modify them via NETCONF, gRPC Network Management Interface (gNMI), or any API). Changes applied in place. Pros: less disruptive, lower overhead. Cons: harder to track state, increases configuration drift risk.
- Immutable Infrastructure: You never modify running infrastructure. Instead, you create new infrastructure with desired changes and switch traffic/connections. Used heavily in cloud (containers, VMs) but less common in networking. Pros: predictable state, easier to verify, eliminates drift. Cons: requires orchestration, more complex recovery, higher resource overhead.
In network automation, we are typically in a hybrid state. Configurations are mutable, changed in place, but the principle of immutability should guide your design: version everything, track changes, and be able to rebuild from scratch if needed.
Greenfield vs. Brownfield#
Not a technical term, but useful to understand two different scenarios when developing network automation solutions:
- Brownfield environments exist with legacy systems, manual processes, inconsistent configurations, and tribal knowledge. Harder because you are automating complexity that was never meant to be automated: inconsistent designs, missing data, legacy technology, human habits, and live traffic constraints. But it is the most common environment.
- Greenfield environments are built from scratch with automation-first design. You can implement all principles cleanly: version control from day one, declarative intent, clean data models, comprehensive testing. Ideal but rare.
Here is why brownfield environments are so complicated:
- Inconsistent network designs. Even a design that was consistent is rarely fully implemented anymore, and what remains is a collection of exceptions.
- Lack of clean and reliable data. The network itself, or maybe an outdated spreadsheet, is the only reference.
- Some network devices from different vendors and generations do not support modern network management interfaces beyond the CLI, which limits declarative approaches.
- Operational culture and fear of change. Do not forget that people come first, and you need to gain trust before adoption.
- Automation must coexist with live traffic without a clean cutover. The margin for error is tiny.
However, there is still hope in these cases. The following three approaches facilitate getting started with these scenarios:
- Partial greenfield approach: Automate new infrastructure while gradually refactoring legacy systems. This shows progress without starting with maximum complexity.
- Incremental target selection: Focus on parts of the network that are easier to automate and provide quick wins:
- Adding configuration drift detection and remediation for a few management features (AAA, Network Time Protocol (NTP), Simple Network Management Protocol (SNMP))
- Automating interface provisioning for a single device type
- Standardizing a single subsystem before expanding
- Build momentum: Each small win demonstrates automation’s value and builds trust for funding and expanding.
Device Diversity and Service Abstraction#
Not all network devices or services work the same way. Different vendors, models, and even software versions have unique interfaces, capabilities, and limitations. Your automation must address this heterogeneity strategically.
Two primary approaches:
- Embrace Vendor-Specific Automation: Write automation tailored to each vendor’s unique capabilities without compromising reproducibility. Pros: simpler initially, leverages device strengths. Cons: creates silos, harder to migrate if requirements change.
- Abstract It Away: Create a vendor-agnostic abstraction layer that standardizes common operations. Pros: portability, unified interface. Cons: added complexity, potential loss of device-specific capabilities.
Best Practice: Layered Approach Most mature operations use both: vendor-specific drivers at the bottom (one layer per device type), then a common abstraction layer above. This gives you the benefits of both strategies.
The key principle: separate implementation details (how specific devices work) from the final goal you want to achieve. This enables vendor independence and simplifies reasoning about your system.
The Fallacy of Tools Over Design#
While tools are essential, they still require good design. A common mistake: purchasing a tool and expecting it to solve all automation problems. The tools you use validate the architecture and design, but a well-designed automation strategy with not-so-fancy tooling beats, in the long run, more capable tooling without proper design.
Design and architecture are strategy and should come first. Tools are implementation details. Invest time in understanding your requirements, designing your architecture, and defining your principles before selecting tools. Sometimes a distributed architecture is appropriate. Other times a simpler, more capable solution better matches your needs in terms of outcome versus complexity. There is no single formula, but you must recognize and be intentional about your choices.
Also remember that tools are not magic boxes. Early in my career, I worked for a manager who believed they were. He had moved into IT from a completely different field, and he expected each new tool to solve problems nobody had explained to it. Do not do that. Understand what a tool actually does, and then bring your own logic into it. Customization and domain-specific configuration are unavoidable.
In Chapter 3, we will explore a reference architecture that highlights the main building blocks you need to consider when evaluating tools.
Buy vs. Build#
A common strategic question: should you purchase an off-the-shelf solution, build custom automation, or use a hybrid approach?
The simple rule: buy when you can, build when you must. Counterintuitively, building is often more expensive than buying. But buying what you need is not always possible.
When evaluating the decision:
- Buy: Use when a product closely matches your needs, supports your architecture, and the cost/benefit analysis favors it
- Build: Use when your requirements are unique, you have the expertise, or off-the-shelf solutions do not fit your principles
This is a design decision more than a procurement one. It is about how much customization and control you truly need.
Do not fall for the AI-assisted development fallacy. AI code assistants make building everything yourself look cheap, but writing the code is the smallest part of the cost. You still have to maintain, secure, and operate what you build, and every hour spent on something outside your core business is an hour not spent on what your business actually cares about.
Most organizations use a hybrid approach: buy strategic components (orchestration platforms, CI/CD systems, data storage) but build domain-specific automation (templates, workflows, validation logic). You must own the domain-specific layer: generic recipes rarely deliver the outcomes you need.
When evaluating open-source solutions, consider extensibility. You can often reuse the framework and build your own custom layers on top: for example, a data source to store network intent that extends the core tool with custom data models. Also, do not forget that with open source, you can still get support and enterprise editions to add safety nets when needed.
Automation Governance#
Who decides what gets automated? Who approves a change to automation logic? Who can authorize a job template to run against a thousand devices in production? These questions rarely have clean technical answers, but they must be answered organizationally before automation reaches any significant scale.
The lack of governance when adopting automation introduces a new risk, one that is not so relevant with manual operations. A single engineer making a manual error affects one device or one session, but the same engineer making an error in a playbook template can affect every device in scope simultaneously. For good and for bad, automation increases the impact, and also the blast radius.
Governance in this context requires defining four things:
Scope boundaries: which operations are eligible for automation and which require human execution regardless of automation maturity. BGP policy changes, routing protocol modifications, or security policy updates may remain human-gated even when the rest of the stack is automated. The automation could do them; the consequences of an error are large enough to warrant a human in the loop.
Logic approval process: changes to automation logic (new playbooks, modified templates, updated data models in the SoT) should go through a review process equivalent to a software code review. The discipline here mirrors software engineering: changes to code that runs in production require human review before they reach production. Automation code is no different.
Execution authorization: who can trigger what job, against what scope, under what conditions. This maps directly to role-based access control in the Execution layer (Chapter 6) and the Presentation layer (Chapter 9). The governance model must be expressed in the access controls of the tools, not just in a policy document.
Audit and accountability: automation must produce, at least, the same audit trail that manual change management produces. An execution event must be traceable to a change ticket, an approver, and a specific version of the automation logic that ran. This is not optional in regulated environments.
Governance is the mechanism by which organizations extend trust to automation incrementally. Starting with low-risk, reversible, well-understood operations and expanding scope as the automation earns a track record is more effective than either blocking automation entirely or deploying it without guardrails. Chapter 11 and Chapter 13 turn these four points into risk tiers, approvals, and an audit trail. Governance is also an organizational design: Chapter 14 covers how change management and team roles adapt when automation makes the changes. And once AI agents act on the network, the same four questions apply to them: Chapter 18 gives each agent a scope, an identity with limited privileges, and an approval path, as it would a new team member.
Last but not least, you have to keep in mind that network automation adheres to the general software engineering principles used to develop and integrate all the system components.
Software Engineering Principles#
In addition to network-specific design principles, broader software engineering principles matter just as much in building maintainable and scalable automation systems. If you come from a software engineering background, you will recognize most of these; the value here is seeing how they apply specifically to network automation.
I like to organize them into two categories, inspired by Robert C. Martin’s Clean Code and Clean Architecture books:
- Clean Code Principles: How to write automation logic that is readable, maintainable, and correct.
- Clean Architecture Principles: How to structure systems so components remain independent, testable, and evolvable.
For good examples of these principles applied to network automation, see the Network Automation Principles blog series by Ken Celenza on the Network to Code blog.
Clean Code Principles#
In this section, the focus is on how the software components are built.
Write Code for Readers
The code you write will be read many times in the future by yourself (when debugging) or by other people maintaining it (including AI coding assistants). The better you explain your intention, the easier their future job will be, because they will have the context. Use meaningful names and comments (do not abuse them), and a simple structure. Your code is not just instructions to machines; it is a form of documentation for humans.
Do Not Repeat Yourself (DRY)
Avoid duplicating logic across your automation codebase. Instead, extract common patterns into reusable templates, functions, or workflows.
Do not write device-specific configuration logic in ten different playbooks. Create one shared template, with variables for the differences. This reduces bugs and makes updates easier. This principle also applies to data: use proper data structures leveraging inheritance and polymorphism to create more scalable and reusable data models.
When you violate DRY, a fix in one place requires fixes in five others, and you will inevitably miss one.
Single Responsibility Principle (SRP)
Each module, function, or workflow should have one reason to change. In network automation, this means:
- A configuration template renderer should not also handle device discovery
- A validation workflow should not also execute changes
When each component has a single responsibility, failures are isolated, testing is simpler, and changes are less risky. Obviously, there will be a composition function (or orchestration) to connect all these functions together.
Fail Fast, Fail Visible
Detect problems as early as possible and expose them clearly. In automation:
- Validate data immediately upon input (do not wait until deployment)
- Make dry-run output explicit and obvious
- Log failures with full context, not vague error codes
- Alert operators immediately when something goes wrong
Catching issues early reduces blast radius and response time.
Security
Encryption, authentication, least privilege, and audit trails must be built into automation systems from the start. Retrofitting them later costs far more.
In network automation: every change should be auditable, credentials should never be hardcoded, and access control should follow the principle of least privilege. A single automation system with full network access is a security disaster waiting to happen.
We will go deep into security and compliance considerations in Chapter 13.
Principle of Least Astonishment
Automation should behave the way users expect. Surprising or counterintuitive behavior erodes trust.
For example, if an automation task is named “deploy_interface”, operators expect it to create an interface, not delete one. Unexpected behavior frustrates users and causes mistakes.
Defensive and Robust Programming
Build in retries, circuit breaker patterns, compensation logic, and fallback mechanisms. Distributed systems fail. Design for it. If a device is temporarily unreachable, retry with exponential backoff before declaring the failure. If a change fails halfway through, have a rollback plan. These patterns appear in Chapter 8 (Orchestration), where the Saga compensation pattern handles partial workflow failures.
Be conservative in what you send, be liberal in what you accept.
Jon Postel
Postel wrote it for TCP implementations; it applies unchanged to automation:
- Conservative sending: Ensure data you send to APIs or devices adheres to strict schemas and contracts
- Liberal acceptance: Be ready to handle variations (e.g., attributes as integers or strings with conversion) to maximize interoperability with different system versions
This principle bridges clean code with clean architecture principles. It affects both how you write integration logic and how you structure system interfaces.
Clean Architecture Principles#
Next, we explore principles that govern how components of a network automation solution come together.
Keep It Simple, Stupid (KISS)
Simpler is easier to understand, test, and maintain. Avoid over-engineering solutions in design, implementation, and architecture. Simplicity reduces bugs, increases maintainability, improves readability, and makes systems easier to extend or debug.
Simple does not mean simplistic. It means choosing the most straightforward approach that satisfies requirements without over-engineering or adding premature abstractions.
In network automation, this means preferring straightforward declarative approaches over complex imperative scripts (when possible), prioritizing clarity, small composable components, predictable behavior, and solutions that can be easily understood by others (including your future self).
Separation of Concerns
Clearly separate data (configuration), logic (workflows), and presentation (APIs/UIs). This prevents tight coupling and enables independent evolution of each layer.
In network automation:
- Data layer: Network intent stored as structured data
- Logic layer: Automation engines and validation rules
- Presentation layer: APIs, CLIs, dashboards for operators
This separation allows you to change how operators interact with automation without affecting the underlying logic. It also maps directly to the blocks of Chapter 3. The data layer is Network Intent and the Source of Truth (Chapters 4 and 5), the logic layer spans Execution, Observability, and Orchestration (Chapters 6 to 8), and the presentation layer is Chapter 9.
Observability
Automation must be instrumented to measure its own behavior, detect failures, and trigger corrective actions. You cannot optimize what you cannot measure. Track both technical metrics and business-oriented ones (e.g., ROI of automation initiatives).
In Chapter 7, we will cover the types of observability data networking cares about (metrics, logs, traces, flows, alerts, and more) and how to turn them into useful information at every level.
Without observability, you are flying blind. You will not know if automation is working correctly or just appearing to work. Remember: automation systems themselves fail and need monitoring. Instrument your automation tools as thoroughly as you instrument the network.
Extensibility
Design with the future in mind. New vendors, new technologies, and new requirements will arrive. Architecture should allow for these without requiring complete rewrites.
Use plugin architectures for vendor-specific drivers, avoid hardcoded assumptions about network topology, and keep interfaces stable while implementations evolve.
Minimal Coupling, Maximal Cohesion
Define clear contracts for how systems communicate: schemas, validation rules, and backward-compatibility policies. These contracts enable independent evolution of components.
In network automation, if your orchestration system talks to your device drivers through a well-defined Representational State Transfer (REST) API, either layer can evolve independently as long as the API contract is maintained.
Define the contract before the implementation. API-first design is the common way to do it: agree on the interface, then build behind it. Components built that way can evolve independently and be swapped without breaking each other.
Not all principles carry equal weight in this domain. Four of them address failure modes that are specific to critical infrastructure automation:
- Principle of Least Astonishment: automation that behaves unexpectedly destroys the operational trust established in the Building Trust section before it can take hold.
- Defensive and Robust Programming: networks fail in partial, non-deterministic ways that automation must anticipate by design, not handle as exceptions.
- Fail Fast, Fail Visible: early detection of failures contains blast radius before it scales across devices.
- Separation of Concerns: the NAF Framework in Chapter 3 is built on it. Separating intent, execution logic, and presentation is what lets each block evolve on its own.
This list is not complete, and software engineering offers many more principles worth learning. Use these as a starting point, and come back to them when you review a design.
Summary#
Any successful project depends on trust. Without trust, there is no adoption. And without adoption, there is no impact. The opening story showed a very common situation I faced, a fantastic network automation system that the network engineers were afraid to use and bypassed every time. It is your goal to avoid it.
To build trustworthy systems, make sure they offer four qualities: predictable, reliable, usable, and understandable. People using the system want zero surprises, no errors (or controlled fallbacks), simple interfaces, and full awareness of what is going on. This should not be new to you. It is the same thing we all expect when we are accountable for the output (and network engineers are).
The chapter went into the design principles that produce these qualities: intent-driven, idempotent, transactional, versioned, testable, and dry-run friendly. This was just an introduction. You are going to see them coming back again and again throughout the book, because they shape the architectural decisions along with other principles, network-related or more general ones associated with any software code and architecture project.
The message is clear: start with principles, not tools. Choose what helps you deliver the qualities that promote trust, and even very simple systems will start producing positive outcomes.
Next, in Chapter 3, we transform these principles into an architecture that gives you a reference to build network automation systems in a manageable way.
References#
- Clean Code, Robert C. Martin (Prentice Hall, 2008). The foundational treatment of the clean-code principles in the Clean Code Principles section, applied here to automation code and templates.
- Clean Architecture, Robert C. Martin (Prentice Hall, 2017). Dependency boundaries and separation of concerns; the architectural discipline behind the Clean Architecture Principles section.
- The Pragmatic Programmer, 20th Anniversary Edition, David Thomas and Andrew Hunt (Addison-Wesley, 2019). DRY, orthogonality, and the engineering habits that inform the testability and versioning principles in the Six Foundational Principles section.
- Infrastructure as Code, 2nd Edition, Kief Morris (O’Reilly, 2021). Declarative intent, idempotency, and immutability as first-class concerns; the source for the declarative-vs-imperative and mutable-vs-immutable patterns in the Architectural Decision Patterns section.
💬 Found something to improve? Send feedback for this chapter