Nov 1, 2025 · 13224 words · 63 min read

Execution#

A playbook had been running for months with no problem. It targeted the three access switches in the lab and it took two minutes to run end-to-end, with clean results every time. It was time to promote it to the full network inventory (800 switches). What could go wrong? Nobody expected trouble.

The reality was different. The first 600 devices ran it without a problem, but then the job slowed. Later, it stalled. The RADIUS server was not able to cope with the 150 simultaneous SSH authentication requests, so it started to reject connections, and the job hung on 150 devices mid-execution. An engineer had to manually kill the job.

This was not the biggest problem. After the failed execution, nobody knew which switches had run the change (the 600 that finished), which ones were half done (the 150 that hung), or the 50 that the job never reached. There was no execution state report. The next try looked obvious: re-run it and hope for idempotency to save the day. It did, but it was not clear it would, because they had not validated it before.

This incident revealed something important: the automation was designed for the lab, not for the real network. There were many variables that a reliable execution layer has to account for that were not properly considered.

Most people think of network automation as: “take the same data, and without connecting as a human in the Command Line Interface (CLI), do something on the network”. I would bet most people starting with network automation begin there. And yes, that is what the Execution block does. But as you have seen throughout this book, network automation is bigger than this first step, and Execution is just one component within the architecture.

The Execution block directly interacts with the network for the most dangerous operations, such as config changes or reboots. So do not skip this chapter.

In this chapter, I will cover the goals and functionalities this block encompasses, and the internal capabilities it needs to achieve them.

Fundamentals#

Execution defines how actions reach the network. The what comes from the Intent block, and the when comes from Orchestration.

In early network automation projects, a script that bounces an interface for a given device and interface name can be the first win. What starts as that one script grows into a much more sophisticated system.

What does an execution system actually need to do? Five things matter:

  1. Get the right data into place. Before executing anything, you need to know what to execute (the intent), where to execute it (which devices), and how to access them (credentials, connection details). This means pulling inventory and fetching the intended state from the Source of Truth (SoT) (more about it in Chapter 4 and Chapter 5), and sometimes querying observability data to understand current conditions. Without this integration, your execution engine is just blindly running commands. For your mental health, avoid it.

  2. Start when needed, whether that is now or later. Sometimes you need immediate execution: an engineer clicks “deploy” and expects it to happen right away. Other times, execution should wait: deploy during the maintenance window, wait for a device to come online, or react to an event from observability. The system needs to support both synchronous and asynchronous triggers.

  3. Track state over time. Network-wide operations are not instant. You might deploy to hundreds of devices over hours. Which devices succeeded? Which failed? Which are still pending? State management also enables idempotency (run the same task twice, get the same result), rollback (undo what you just did), and resume (pick up where you left off after a failure). Without state tracking, every execution is a one-shot gamble.

  4. Execute reliably at scale. A script that works for 5 devices often breaks (or degrades) at 500. You may need parallel execution, error handling, retries, rate limiting, and dry-run capabilities. The system should gracefully handle partial failures, provide clear feedback on what went wrong, and never leave the network in an undefined state. Different operations need different strategies. Some are fast and parallel, others slow and serial.

  5. Work with any network device or platform. Your network probably has switches and routers from several vendors, firewalls from others, two public clouds, and Linux hosts. Each one expects its own syntax, speaks different protocols, and has different operational patterns. Your execution layer needs adapters for all of them: each one turns vendor-agnostic intent into its platform’s syntax and delivers it, so the rest of your automation does not care about the differences.

Those five goals also draw the block’s boundary: what the Executor does itself, and what it leaves to its neighbors.

What is in scope

  • Rendering or translating technical-layer intent into each platform’s syntax, through versioned adapters
  • Connecting to network devices via any supported protocol
  • Executing configuration changes, operational commands, file transfers, reboots
  • Managing execution state and tracking progress
  • Handling errors, retries, and rollbacks
  • Providing feedback to Orchestration

What is out of scope

  • Deciding what to configure (that is Intent)
  • Orchestrating complex multi-step workflows and deciding when to trigger (that is Orchestration)
  • Long-term storage and analysis of execution results (that is Observability)

Think of execution as the engine in a car: it provides power and motion, but does not decide where to go or when to turn. Those decisions come from the driver (Orchestration) following a map (Intent).

Next come the functionalities this block has to provide to answer the previous goals.

Functionalities#

Five functionalities work together to modify network state safely and reliably, and Figure 6.1 maps each one to the goal it delivers.

Execution Goals

Figure 6.1: The five Execution goals, and the functionality that delivers each one.
  1. Data Integration. Gets the intent, the inventory, and the credentials into place before anything runs, from the Source of Truth, from observability, and from the secrets backend.
  2. Triggering. Starts execution, synchronously when someone is waiting for the answer and asynchronously when something else is.
  3. State Management. Tracks where the execution is and what the devices look like, which is what makes idempotency, resume, and rollback possible.
  4. Engine. Runs the task: how the logic is expressed, how much of it happens at once, where it runs from, and what happens when part of it fails.
  5. Network Adapter. Renders or translates intent into each platform’s syntax, speaks the protocols, and manages the connections underneath them, so nothing above this layer knows which syntax or interface a device uses.

These components form a chain: data integration provides the inputs, triggering starts the process, the engine executes tasks using network adapters, and state management tracks everything throughout.

Following this order, start with the data integrations this block requires.

Data Integration#

There are many different integrations, but the cornerstone is the integration with the Source of Truth, to understand what to do and where to do it.

Of all the intent data, everything starts with the Inventory. The inventory data defines the target devices. We covered this in Chapter 4, but at minimum, you need:

That is the minimum. You can also pull more of the technical layer from the Source of Truth to refine how a job behaves. For example, the location, the role (spine/leaf/edge), or the environment (prod/staging) can change how the Executor runs its logic.

The inventory data always comes from the Intent block, even though in many cases this boundary is not so clear. For example, Ansible, a very popular Executor tool, leverages YAML files (host_vars, group_vars). The data in these files belongs to the Source of Truth block. As mentioned before, one tool can implement many functions, and one function can be implemented by many tools.

Inventory never carries credentials, only pointers to them. The Source of Truth says which secret a device uses; the Executor resolves that pointer at job start and keeps the value no longer than the job. The Executor should support multiple credential sources and per-device overrides, because one fleet rarely shares one account. The security consequences of getting this wrong come later in this chapter.

Finally, the meat and potatoes of the Source of Truth integration is the actual intent, what you want to configure or change:

  • Technical-layer data: The vendor-agnostic intent itself, which the adapter renders or translates into the device’s syntax.
  • Commands: Specific CLI commands or API calls to execute for device operations.
  • Files: Software images for upgrades, configuration files for import.

Configuration intent always arrives as technical-layer data, never as vendor syntax, exposed per inventory item in scope. Turning it into each device’s syntax is the adapter’s job, covered in the Rendering and Translation section.

Should the Executor fetch intent data itself, or should the caller (e.g., Orchestration) pass it in? Both work. Fetching intent directly couples execution to your Source of Truth but ensures data is always fresh. Receiving intent as parameters makes execution more generic but requires Orchestration to handle data fetching.

A rendered artifact can go stale between the moment it is rendered and the moment it is deployed. If the SoT data changes after the artifact was rendered and approved, deploying it applies an outdated configuration. The staleness window is the time between the render and the deploy. For automation that renders at trigger time, this window is minimal. For workflows that render during validation and deploy in a later maintenance window, it can grow to hours or days. Before deploying, check that the intent version the artifact was rendered from is still current; if it is not, render again, and the new artifact goes through review again.

Comparing desired and actual state is Observability’s analysis, and deciding what to do about the result is the Orchestrator’s. The Executor’s own comparison is narrower: the real-time dry-run diff for the change it is about to make. But when there is a delay between the decision and the execution, the Executor may need to check actual data at the last instant before proceeding, for example:

  • Pre-execution validation: Is the device reachable? Is there enough disk space for an upgrade? Are there active sessions that would be disrupted?
  • Graceful degradation: Before rebooting a switch, query observability to see if there is redundant connectivity. If not, delay or abort.
  • Conditional logic: Only apply a configuration if certain conditions are met, such as Central Processing Unit (CPU) below threshold, no active alarms, or time of day within the window.
  • Drain capacity: Before executing a draining operation, ensure the available capacity is enough to absorb the change without breaking Service Level Objectives (SLOs).

A common pattern: Ansible resource modules in gathered state, or Nornir tasks that collect facts, run observability queries before and after execution, comparing results to detect unexpected changes. The “before/after snapshot” approach catches regressions that would otherwise go unnoticed. Again, the same tool acting as Executor could act as Collector, but even then the responsibilities stay split.

What starts the Executor? A change in the Source of Truth, a self-healing action, or someone running a demo that needs to simulate an interface going down. One way or another, something has to kick off the Executor.

Triggering#

Execution does not start by itself. Something has to trigger it. There are two main patterns:

Synchronous (immediate, blocking):

  • API calls: An external system or user invokes an API endpoint, execution runs, and the response includes results. Simple and direct.
  • The Presentation layer via CLI commands or API calls: Engineers run commands that directly invoke execution (ansible-playbook, terraform apply, custom scripts). These CLI commands are part of the lightweight presentation layer offered by these tools (more in Chapter 9).

Asynchronous (delayed or event-driven):

  • Webhooks: External systems (Git, ticketing, CI/CD) send Hypertext Transfer Protocol (HTTP) requests when events happen, and do not wait for the deployment to finish. Common pattern: Git push triggers config deployment.
  • Event listeners: React to events from observability (device down, threshold crossed), message queues, or external systems. Event-Driven Ansible (EDA) built this pattern explicitly: listen to events, match rules, trigger playbooks automatically.
  • Message queues: Tasks submitted to a queue (RabbitMQ, Kafka, AWS SQS), workers pull and execute them. Enables buffering, priority queuing, and rate limiting.

The right approach depends on your use case. Immediate changes (fixing a production issue) need synchronous triggers. Reactive automation (responding to alerts) uses event listeners. Scale considerations matter too, as we will cover in Chapter 12.

The actual trigger usually comes from Orchestration, though if that does not exist, other blocks can trigger execution directly. For example, triggering directly from the Presentation layer as a human-exposed task, or from the Source of Truth block.

Execution can be a single targeted task, but it can also involve multiple parallel targets belonging to the same task, and that needs state coordination.

State Management#

State management is about tracking where you are in an execution and what the world looks like so you can make intelligent decisions.

There are different types of state data to track:

  • Which devices have been processed?
  • Which tasks succeeded, failed, or are pending?
  • If a task failed with a transient error, can we retry?
  • If execution was interrupted, can we resume where we left off?
  • What is currently configured on the infrastructure?

Most of these questions are answered within a single execution, but the last one, which belongs to the Observability block even though it is commonly implemented here, can be approached in two ways:

  • Stateless (e.g., Ansible). Each execution runs independently. No persistent state between runs. Every execution starts fresh: gather current state, compute diff, apply changes. Simpler to operate (no state database), but less efficient (you re-discover everything each time) and no built-in rollback.

  • Stateful (e.g., Terraform). The system maintains a persistent state file tracking what was last deployed. On each run, compare desired state (your config) to recorded state (what you deployed last time) to actual state (what is on the device). This enables precise change planning, efficient execution (only change what is different), and rollback (revert to previous state). But now you have a state file to protect, lock, and sync across multiple operators.

Stateful tracking looks ideal, but it only holds if every change goes through the tool. One engineer fixing something by hand at 02:00 makes the state file a lie, and from then on you are importing and re-syncing resources instead of deploying them. That is why Terraform works well for cloud, where the API is the only way in, and poorly for switches, where the console is always there.

Transactional execution is the next step when you want stronger safety guarantees than best effort. A transaction groups multiple device changes into a single unit: either everything is applied and validated, or the system rolls back to the previous state. This requires three things:

  • A clear boundary (what operations are inside the transaction)
  • A durable record of pre-change state (for rollback)
  • A locking or lease mechanism to prevent concurrent changes from breaking atomicity

Most network automation settles for “transaction-like” behavior instead of strict Atomicity, Consistency, Isolation, Durability (ACID) semantics, the guarantees a database gives a transaction, because not all devices support native commit/rollback. Still, you can approximate transactions by taking snapshots, using candidate configs (when supported), enforcing exclusive locks, and making rollback paths a first-class part of the execution flow.

Across devices, “rolls back” usually means compensation: the Saga Pattern in Chapter 8 undoes each completed step in reverse. Some effects do not come back with the configuration, such as a Border Gateway Protocol (BGP) session that flapped or traffic dropped during the change. So the execution flow must also detect and record a partial change, not only try to prevent one.

The challenge? State sync and sharing. If multiple people or systems modify network devices, state gets stale. Terraform addresses this with remote state storage and locking. Ansible avoids the problem by being stateless but sacrifices efficiency. The middle ground: cache current state temporarily, validate before each operation, and build “eventual consistency” patterns where brief mismatches are acceptable.

As mentioned in the design principles, idempotency is key to creating trust in your network automation system, and idempotency happens, mostly, here in the Executor.

Idempotency means running the same automation multiple times produces the same result. Apply a VLAN config once: the VLAN is created. Apply it again: nothing changes (the VLAN already exists). If execution fails halfway through, you can safely re-run it without creating duplicates or breaking things. Reliability is all about it.

How tools achieve idempotency:

  • Built-in modules (e.g., Ansible): Most Ansible modules are idempotent by design. The cisco.ios.ios_vlans module checks if the VLAN exists before creating it. If it is already there with correct config, Ansible reports “ok” (no change). This requires the module author to implement checking logic.

  • State comparison (e.g., Terraform): Terraform compares desired state to current state, computes a diff, and only applies differences. If you run terraform apply twice with no changes to your config, the second run does nothing.

  • Declarative APIs (e.g., NETCONF with Yet Another Next Generation (YANG) models): Some protocols handle idempotency natively. Send the same NETCONF <edit-config> with merge twice, and the datastore ends in the same state: merge creates or updates as needed. The guarantee is narrow, though. Merge never deletes, so it cannot remove what intent no longer contains, a limit Chapter 10 returns to.

  • Manual checking (e.g., raw scripts): The last resort. If you are writing Python or Go scripts, you implement idempotency yourself: query current state, compare to desired state, and change only what differs. That means parsing every output, handling every edge case, and maintaining it all on every firmware release. Choose it only when no module or declarative interface covers the device.

Idempotency is harder than it looks. What if the VLAN exists but has wrong settings? Should you update it (potentially disrupting traffic) or report a conflict? What about transient failures (device temporarily unreachable)? Retry logic must distinguish between “operation already done” (idempotent success) and “operation failed” (real error).

Idempotency has a cost, and the overhead depends on who does the comparison. With NETCONF merge, the device reconciles state itself, so there is no extra read. A declarative resource module still reads the device first, but once per task, not once per line. With raw scripts, you pay for every check yourself: one read per device before every write (declarative tooling scales better because of this).

Finally, the Engine determines which logic is supported and how it can be defined.

Engine#

The execution engine is the core logic that takes a task (“configure this VLAN on these 50 switches”) and executes it safely and efficiently. This is not Orchestration. The Orchestration block coordinates multiple execution tasks across time and dependencies. The engine just runs one task well (or a simple chain of tasks).

It accepts a task definition, breaks it into per-device operations, runs them with the right concurrency, handles the failures, and reports what happened. That breaks down into six design questions, which are the rest of this section. How do you express the logic, how much runs at once, and where does it run from? What can you see before committing, how do you confirm the result, and what happens when part of it fails?

An engine might configure 100 routers in parallel, but when to run, which configuration to apply, and what next are Orchestration’s decisions. Execution is the workhorse; Orchestration is the foreman.

That said, execution engines often support simple chaining: “do task A, then task B on the same devices”. That is basic sequencing, not full Orchestration. When you need complex workflows (wait for external approval, branch based on results, coordinate across multiple systems), you need a real Orchestration layer (more in Chapter 8). For example, this sequence can still be one execution flow: upgrade firmware, wait for a device reboot, verify operation, update inventory. But if it requires human validation or conditional branching based on broader validation, it belongs in the Orchestration block.

The first thing the Engine defines is how you express the execution logic. Different language styles have different trade-offs, as Table 6.1 shows:

StyleExamplesStrengthsTrade-offs
Domain-specific languages (DSLs)Ansible (YAML), Terraform (HCL)Lower barrier to entry, self-documenting intent, built-in execution semanticsLimited flexibility, harder debugging in complex scenarios, conditional logic can become awkward
General-purpose programmingNornir (Python), custom Python/Go scriptsFull flexibility, strong debugging tooling, easy library reuseHigher skill requirement, more code to maintain, less standardization across teams
Table 6.1: Domain-specific languages versus general-purpose programming.

Many teams use DSLs (Ansible) for common patterns and drop into custom code (Python modules, plugins) for complex edge cases. This balances accessibility with power. The human factor usually decides which approach wins; more on that in Chapter 14.

Regardless of the language, there are two basic patterns for defining actions.

Imperative versus Declarative#

As already defined in Chapter 2, there are two patterns to define actions:

  • Imperative: You specify how to do something, step by step.

  • Declarative: You specify what the end state should be, and the tool figures out how.

Declarative is simpler for the person writing the task, and it is the shortest path to idempotency. But there is no hidden magic: the work does not disappear; it moves. Someone has to write the module that reads current state, computes the diff, and handles the edge cases, so that everyone downstream can just declare an end state. When nobody has done that work for your platform, you are back to imperative. That same module often translates into platform syntax too, which makes it the translation half of an adapter (see the Rendering and Translation section). It needs the device’s current state to compute the delta, so it runs next to the device. Table 6.2 compares the two approaches.

ApproachStrengthsTrade-offs
DeclarativeIdempotent when the module or protocol is; intent is easier to read; fewer operator mistakes because the tool handles edge casesDepends heavily on module/provider quality; less control over execution path; troubleshooting can be harder when internals are abstracted
ImperativeFull control over each step; execution flow is explicit; works in almost any environment with CLI accessMore code and testing effort; idempotency is on you; long-term maintenance grows quickly as edge cases accumulate
Table 6.2: Declarative versus imperative execution.

A good way to see the difference is to look at Ansible, which supports both:

With Imperative Ansible, you are literally telling Ansible which commands to run. If the VLAN exists, this still runs (though it might be idempotent depending on the module).

- name: Create VLAN 412
  cisco.ios.ios_config:
    parents: vlan 412
    lines:
      - name app-payments
Listing 6.1: Imperative Ansible: the exact commands to run.

With Declarative Ansible, you describe desired state. Ansible figures out what commands to run. If VLAN 412 already exists with the correct name, Ansible does nothing.

- name: Ensure VLAN 412 exists
  cisco.ios.ios_vlans:
    config:
      - vlan_id: 412
        name: app-payments
    state: merged
Listing 6.2: Declarative Ansible: the desired state.

Most teams use declarative when possible, imperative when necessary. Just remember: declarative means someone else carries the burden, even if it looks simple from the outside.

Still in the engine logic, another important functionality is how the tasks are executed.

Serial versus Parallel#

Simplifying a little, two options exist for running tasks, and Figure 6.2 contrasts them:

Serial vs Parallel

Figure 6.2: Serial execution versus parallel execution.
  • Serial execution: Process devices one at a time. Configure device 1, wait for completion, configure device 2, and so on. Safe (you see failures immediately and can stop), but slow (100 devices = 100× the time of one device).

  • Parallel execution: Process multiple devices simultaneously. Configure devices 1-10 at once, 11-20 next, and so on.

Why Nornir exists. Ansible has always run a task across hosts in parallel, up to the forks limit (five by default, which is the first thing to raise). What it adds, with the default linear strategy, is a barrier at every task boundary: no host starts step 2 until the slowest host finishes step 1. Across 800 switches, one unresponsive device sets the pace of every step in the play. The free strategy lifts that barrier and lets each host run ahead. Nornir starts from the other end: it is a Python framework with a thread pool, so each device runs its whole workflow independently and you set the concurrency in code. You do not get a fixed speed-up. What you get is that one slow device no longer delays every step.

Parallel execution looks like the obvious winner whenever no ordering is required, but it comes with challenges of its own:

  • Control plane impact: Hitting 1,000 devices simultaneously can overload management networks, data sources, authentication systems, or device control planes.
  • Dependency handling: If devices depend on each other (spine before leaf), you need ordering. Pure parallelism does not work.
  • Error blast radius: If your automation has a bug, parallel execution deploys it to many devices before you notice. Serial execution fails on device 1, and you stop before damaging devices 2-100.

My recommendation: use parallel execution with batching. Process devices in groups of 10-50, or waves, and verify the success of each batch before continuing. This balances speed with safety. Batch size is the easy half, though: which devices share a wave is what bounds the damage. Keep both halves of a redundant pair in different waves, and treat tiers that depend on each other as consecutive waves rather than parallel batches: spines first, verified, then leaves. Chapter 8 names this progressive wave rollout and covers the health gate between waves; Chapter 11 covers the deployment mechanics.

One constraint decides the batch size before any of this does: the change window. Sixteen batches of 50, each with a convergence wait and a verification pass, is a different proposition in a four-hour Saturday window than in a Network Automation Platform (NAP) that deploys on demand. Do the arithmetic before picking the number, because the alternative is discovering at 05:00 that the window closed with 300 switches changed and 500 not. If the full scope does not fit, the scope is wrong rather than the batch size: split it across windows at a boundary you choose, with each window ending on a consistent state.

Concurrency is one half of how the work gets distributed. The other half is where it runs from.

Agents and Workers#

Two topology questions decide how execution reaches the network: who initiates the connection, and where the execution runs.

  • Agentless execution is the default in networking, for a simple reason: you cannot install software on most network devices. The Executor connects in, does the work, disconnects, and nothing persists on the target. The cost is that every operation pays connection setup, and the Executor needs reachability and credentials for every device it manages.

  • Agent-based execution inverts the direction. Something on or near the device holds a persistent connection outward and pulls work from the central system. On servers this is standard. In networking it shows up as on-box agents on platforms that allow containers, and more often as a proxy worker: a small executor in a remote site that takes jobs centrally and runs them locally. The win is reachability, because the agent dials out and no inbound path to each device is needed, which matters for sites behind NAT or a strict firewall policy. The cost is one more component to deploy, monitor, and upgrade, and an agent that dies takes its devices offline from the automation’s point of view even though the network is healthy.

Worker placement follows from that choice. One central worker pool is simplest, and it holds until latency or reachability breaks it. Regional workers sit close to their devices, which matters most for CLI sessions, where a single task is dozens of round trips and every millisecond of latency multiplies. The trade-off is distributed state: many workers, one place to record what happened. That is the distributed scenario State Management warned about, and the scaling side of it belongs to Chapter 12.

Dry-run support is another of the trust-building design principles from Chapter 2, like idempotency.

Dry Run#

A dry run is the execution engine’s “plan” phase: simulate changes without touching devices, then surface a concrete diff and risks. A good dry run pulls current state, computes the exact device-level operations that would run, and validates prerequisites (reachability, schema, dependency ordering). It should be fast, deterministic, and reproducible so reviewers can trust it.

Ignore the syntax; this Terraform plan for an AWS VPC shows what a reviewable change looks like:

Terraform will perform the following actions:

  # aws_vpc.main will be created
  + resource "aws_vpc" "main" {
      + cidr_block           = "10.10.0.0/16"
      + enable_dns_support   = true
      + enable_dns_hostnames = true
      + tags = {
          + "Name" = "core-vpc"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
Listing 6.3: A Terraform plan showing the dry run.

The diff is what a reviewer validates: the exact resources and attributes that would change, without touching the actual infrastructure.

A dry run makes approvals meaningful and rollbacks less likely. It gives humans a clear view of what will happen, and it gives the engine a chance to reject unsafe or inconsistent changes early. If the network platform supports candidate configs or commit-check, the engine should use those. Otherwise, a dry run is a computed diff plus pre-checks, but not a guarantee (nevertheless, better than nothing).

In my experience, offering dry-run capabilities is very convenient in the early days of an automation project to get network engineers’ buy-in. Later, people stop reading every dry run by hand, but keep producing it: it is the evidence the review and the audit trail rely on.

I have skimmed more dry runs than I would like to admit, usually the long ones, which are exactly the ones that matter. After the third coffee, a 400-line diff looks much like a 40-line one. So I stopped relying on my own attention and built it into the output instead. When a dry run touches something risky, such as a routing policy, a management interface, or more devices than the request named, its summary opens with a warning that is hard to miss. That warning is not there for the junior engineer. It is there for me.

A good engine lets you stop short. Every change has five steps, and only the last one changes the device. Get the technical-layer data from the SoT. Render or translate it into the device’s syntax. Gather the current configuration from the device, and compare the two. Then apply the difference, or replace if possible. Being able to run the first four on their own is what makes a change reviewable, and it is the same machinery dry run uses.

The apply stage has its own gradient, ordered by blast radius. Merging adds your configuration to what is already there. Replacing swaps out one section and leaves the rest alone. Overwriting makes the whole device match the intent, which also deletes anything the intent does not mention. Declarative tooling exposes these as named states, and the names differ by tool while the blast radius does not. Pick the narrowest one that achieves the change, and be certain which one your module uses by default.

A dry run covers the half of a change that has not happened yet. The other half needs checking afterwards.

Verification#

A dry run asks what will happen; verification asks what did. The two are not symmetric. A clean dry run is a prediction; a clean verification is evidence, and a change is not finished until you have the second one. Three things are worth checking, in increasing order of what they prove and what they cost. Figure 6.3 shows them, with the fourth check that the wave gate of Chapter 8 adds when the next step is widening the scope.

Verification levels: config state, operational state, and service state, plus the wave gate’s nothing-else-moved check

Figure 6.3: Verification levels, and the check the wave gate adds.
  • Config state: read the configuration back and confirm it matches the intent. Cheap and immediate, but it only proves the device accepted the text. A VLAN can be present in the config and carry no traffic.
  • Operational state: check the device’s own view of the result. The VLAN is active, the interface is up, the BGP session is established. This proves the device acted on the configuration.
  • Service state: check the thing the change was for. A host in the new VLAN gets an address and reaches its gateway. This is the only check that proves the change did what was asked.

All three checks read from the Collector and Observability, the blocks that gather device state and make it queryable (Chapter 7). The Executor or Orchestration consults them, depending on how close to the execution the check happens.

Timing matters as much as the choice of check. Protocols need time to converge, so verification that runs immediately after the apply reports failures that are not failures: a session mid-establishment, an interface still settling. Wait for convergence, with a bounded timeout, before trusting the answer.

All of this needs a “before” to compare against, which is what the before/after snapshot pattern from the Data Integration section is for. Without the first snapshot you cannot distinguish a problem you caused from one that was already there.

The last big responsibility of the Executor engine is to handle the challenges that could impact operational resilience.

Resiliency#

Everything fails, all the time.

Werner Vogels

Vogels is right about network execution too: devices reboot, connectivity hiccups, and control planes get overwhelmed. Other dependencies, such as the Intent block, may also have temporary issues. Resilient execution handles these gracefully via seven strategies, which Chapter 12 extends:

  • Retry logic handles transient failures. A connection timeout or a temporary CPU spike should trigger a retry with exponential backoff. An authentication failure or a syntax error should not: it will fail the same way every time. Cap the attempts, or a device that is down for good will hold your job open forever.

  • Rate limiting protects the systems you depend on, not the ones you are changing. A job that opens 150 device sessions at once also makes 150 authentication requests, 150 inventory lookups, and 150 secret reads. The devices are fine; the RADIUS server is not. Cap concurrency against each shared dependency separately, because their limits differ by an order of magnitude. An AAA server may handle a few dozen simultaneous logins, a Source of Truth API a few hundred requests per second, and a secrets manager fewer than either. Retries multiply this load at the worst moment, when the dependency is already struggling, which is why backoff should be exponential and jittered: randomized, so the retries do not resynchronize into a second wave.

  • Timeouts come in three layers. A connection timeout bounds how long you wait for a device to answer. A task timeout bounds a complete operation, so one stuck device cannot hang the run. A global timeout bounds the entire job. Without all three, a single unresponsive switch can block a deployment to 800.

  • Error handling is the policy decision: what happens to the other devices when one fails? Fail fast aborts everything, which is safe but wastes the work already done. Keep going logs the failure and continues, which is efficient but can spread a bad change across the fleet.

    A threshold stops the job when failures cross a limit, and it is usually the right shape. The limit belongs to the change rather than to the tool, so it arrives with the change and is passed to the job. Chapter 8 works through how to choose it, and why a forwarding or security change should be all or nothing where a monitoring change can run at 95%. Whatever you pick, apply it consistently: unpredictable partial-failure behavior destroys trust faster than an outright failure.

  • Rollback needs a snapshot taken before the change, not after you notice the problem. Capture the current config per device, and on failure restore it automatically for the affected scope only. This is execution rollback: one task undoing its own changes. Undoing tasks that already completed, because a later step of the workflow failed, is Saga compensation, which the Orchestrator runs. Rollback and dry run share one ingredient, the snapshot of the current configuration: dry run compares against it, and rollback restores it.

  • Circuit breakers stop you from burning the job on dead devices. When a device fails repeatedly, mark it unhealthy and skip it for a while. Otherwise every batch pays the full connection timeout for a switch that has been powered off since last Tuesday.

  • Checkpointing saves progress as the job runs. If the engine crashes at device 600 of 800, you resume from the checkpoint instead of starting over. This is what the team in the opening story did not have.

Building all this is hard. Most teams start with basic retry logic and add complexity as they hit failures in production.

And the final responsibility of the Executor is to provide a reusable write interface toward the network infrastructure.

Network Adapter#

Network devices expect different syntaxes and speak different protocols. The network adapter layer absorbs both, so upper layers do not care whether they are configuring a Cisco switch via SSH or an Arista switch via Representational State Transfer (REST) API.

The Executor reaches every device through the Adapter Pattern: one adapter per platform, all accepting the same input, technical-layer data. It is the most widely implemented way to absorb a multi-vendor fleet. Each adapter has two halves, as Figure 6.4 shows: rendering or translation turns the record into the platform’s syntax, and delivery speaks the device’s interface and interprets its response.

Adapter Fanout

Figure 6.4: The Adapter Pattern: one adapter per platform.

In the figure, as in the Implementation Example later in this chapter, the Vendor A and Vendor B adapters render with your templates, and the Vendor C adapter translates with a declarative module. All three start from the same technical-layer record, and nothing above the adapters knows which syntax or interface a device uses. The next two sections cover the two halves: rendering and translation first, then delivery.

The Collector applies the same principle on the read path: one collection module per vendor or protocol, with the Processor normalizing what they deliver (Chapter 7).

This pattern is easy to build and well understood. The maintenance burden grows as the device inventory diversifies: each new vendor or OS version requires a new adapter or a new version of one. The pattern scales well for a defined set of vendors, but it becomes more complex to maintain when the network is very heterogeneous. But, at least, the complexity is bounded to this component, leaving the Intent agnostic to all these changes.

It does scale further than it looks, though. Facebook’s Robotron (Sung, Tie, Wong, and Zeng, SIGCOMM 2016) describes this exact shape applied to tens of thousands of devices connecting hundreds of thousands of servers. An object store called FBNet holds the network as objects and the relationships between them. Vendor-specific device configurations are generated from those objects through per-device-type templates, extended as new device types enter production. Vendor-agnostic intent in one system, per-device-type rendering from it, and a separate deployment step that pushes the result: the same split this section argues for, running a network most enterprises will never match in size.

Robotron settles the scale question and leaves the diversity question open, because a hyperscaler’s device catalog is narrower and far more tightly controlled than an enterprise’s. Facebook chose its platforms; a company with campus gear from four vendors, a WAN from a fifth, an inherited data center from an acquisition, and three firmware generations in each did not. The pattern’s weakness is the breadth of the catalog, not the number of devices in it, and the paper does not test that. What it does give you is the part the pattern description leaves out: how a template set is maintained as the device catalog changes underneath it, which is the work that makes per-platform translation expensive.

Rendering and Translation#

The adapter receives technical-layer data, such as the VLAN record of Chapter 4. Its first job is to turn that record into the syntax its platform accepts, whether CLI lines, a YANG payload, or a REST API model. This is where vendor syntax enters the NAP, and it is the Executor’s responsibility, not the Intent block’s (Chapter 4 draws the boundary).

There are two ways to do it:

  • Rendering: your own templates fill in the data and produce a complete configuration artifact. Jinja2 is the popular choice for CLI-based configuration, because it is human-readable and integrated with Python and Ansible. Payload-based interfaces (REST API, gRPC Network Management Interface (gNMI)) usually rely on data structures built in a programming language.
  • Translation: a module someone else wrote turns the data into the device’s syntax, often after reading the device. Declarative resource modules, such as Ansible’s cisco.ios.ios_vlans, cloud providers in infrastructure-as-code tools, and the device drivers inside network orchestration products all work this way.

Do not confuse either one with configuration backups. A backup belongs to the Observability block: it is the configuration actually running, and it tells you what your intent may have been in the past, not what it is now. Rendering and translation produce their output on the fly, from current intent.

Rendering with templates

Templates turn technical-layer data (“VLAN 412, named app-payments”) into actual configuration artifacts (e.g., CLI commands). But keep something in mind: templates contain logic, not data. The template says “use the VLAN ID from the data model, output it here.” The actual VLAN ID comes from the data, not the template. This decouples data from implementation details, so you can reuse it in many cases and easily test it against a common schema.

For example, given interface data like this from the technical layer:

interfaces:
  - name: Ethernet1
    description: Uplink to core
    enabled: true
  - name: Ethernet2
    description: Server port
    enabled: false
Listing 6.4: The interface data that feeds the template.

And this Jinja2 template in the adapter:

# Interfaces
{% for iface in interfaces %}
interface {{ iface.name }}
  description {{ iface.description }}
  {% if iface.enabled %}
  no shutdown
  {% else %}
  shutdown
  {% endif %}
{% endfor %}
Listing 6.5: A Jinja2 template that renders interface configuration from the data.

It generates the following CLI output:

# Interfaces
interface Ethernet1
  description Uplink to core
  no shutdown
interface Ethernet2
  description Server port
  shutdown
Listing 6.6: The CLI configuration rendered from the data and the template.

The data comes from the technical layer, the template belongs to the adapter, and the configuration artifact is the result. Each one changes without editing the others.

Constants are data too. It is quite normal to start with static values in the templates, such as the MTU when every interface in your network runs the same one, because it is the fastest way to get the first configuration out. But it bites back sooner than you think. The day one interface needs a different value, a GRE tunnel at 1476 say, the constant is copied into every adapter’s template, and nothing in the intent tells you where. So work towards decoupling the intent from the adapter. Keep the value in the intent as one default, set once in the design rather than on thousands of objects, and let the exception override it where needed: Listing 4.4 in Chapter 4 models the tunnel that way. The template keeps only the logic that converts the data into vendor syntax.

An interesting alternative to Jinja is CUE, a declarative configuration language that unifies raw data (like YAML), validation (like JSON Schema), and generation (like Jinja). It treats configuration as typed, composable data with enforced invariants rather than as loosely structured text. Its validation side belongs to the Intent block’s schema enforcement (Chapter 4); its generation side is rendering. If you adopt it, keep the schema with the intent and the generation code in the adapter, even though both are CUE.

Rendering or translation

Rendering and translation do the same job and differ in who writes the code and what it needs. Table 6.3 compares them.

RenderingTranslation
Code written byYou, as templatesThe module’s author
Needs device stateNoOften, to compute the delta
Reviewable before applyYes: the rendered artifactOnly via the module’s dry-run diff
Best fitFull-replace interfacesMerge-only CLI, cloud APIs, controllers
Main riskTemplate sprawlBehavior tied to a module version
Table 6.3: The two ways an adapter produces device syntax.

To choose, ask one question: does it need the device’s current state? Rendering takes the full intended state in and produces the full payload, so it needs nothing from the device. It fits any interface that can replace a whole section of configuration, such as NETCONF or gNMI with replace semantics. Translation through a module can read the device first, and sometimes it has to. Removing VLAN 412 through a merge-only CLI means sending no vlan 412, and only something that has read the device knows to send it.

One rule holds for both: the change is visible before it is applied. With rendering, the artifact is that evidence. With translation, the module’s dry-run diff is, and the Dry Run section above builds it into the engine. A module that cannot show its diff should not run unattended.

Render first, deploy later

Rendering is an operation of its own, not only a step inside deploy. The Orchestrator calls it during validation, before anyone approves the change: the Executor renders the artifact for every device in scope, and the artifact goes to the artifact store. Simulation runs against it, reviewers read it, and the deploy step later pushes exactly those bytes instead of rendering again, so what was approved is what reaches the device (Chapter 11 runs this inside the change workflow). For translation, the stored evidence is the module’s dry-run plan. Deploy runs the same module version later, and if the device changed in between, the plan no longer matches and the run stops.

Versions and contracts

An adapter is a package per platform, and per OS version where the platform’s behavior differs (Chapter 10). It bundles the templates or the pinned module with the delivery code described next, and it is released as one versioned unit, with semantic versioning like everything else the NAP publishes. Transports such as SSH, NETCONF, and gNMI clients are shared libraries underneath every adapter, not part of any one of them.

The technical-layer schema is the contract between the adapters and the Intent block, and the Intent block versions it. Each adapter declares which schema versions it accepts, and its CI runs contract tests: fixtures generated from the schema go through the adapter, and the output is compared with the expected configuration. A breaking schema change ships only after every adapter that consumes it has released a version that accepts it. Each run records the adapter version next to the schema version, so any rendered artifact can be traced back to both.

That discipline is why rendering belongs in the Executor. Templates are code that adapts the agnostic model to a platform-specific one. If you keep them in the intent, your intent has to change when a new OS release changes some configuration syntax, but in reality, your intent is the same; only the artifact has to change. Obviously, the adapter should version and track the templates or other translation logic in sync with the data contract the intent offers.

That said, many Source of Truth products ship rendering features, such as configuration templates or generated artifacts. Using them is fine if the template code follows the same versioning and testing: the SoT tool is then hosting part of the Executor.

Delivery#

Which interfaces a device exposes, what each one is good for, and which one to choose per device are properties of the network, and Chapter 10 covers them. The delivery half of the adapter speaks them. Beyond the traditional CLI over SSH (or Telnet), the industry has built interfaces that return structured data instead of screen output, and Table 6.4 lists the libraries that implement adapters for the most widely used ones:

InterfaceExample libraries and tools
SSH / CLINetmiko (Python), Paramiko (Python), scrapli (Python), scrapligo (Go)
NETCONF / RESTCONFncclient (Python), scrapli-netconf (Python), nemith/netconf (Go)
gNMI / gNOIpygnmi (Python), gnmic (Go CLI), openconfig/gnmi (Go)
REST APIsrequests/httpx (Python), net/http + OpenAPI-generated clients (Go)
JSON-RPC / vendor gRPCArista eAPI (JSON-RPC), vendor gRPC SDKs
Table 6.4: Adapter libraries per device management interface.

All the libraries above are open source, though some also come with commercial support from the companies behind them.

Some of these interfaces still expose vendor-specific data models. But to keep code reusable, other libraries and products provide an abstraction layer with a common interface across platforms, such as:

  • NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support): Python library that provides a unified API across vendors.
    • Supports Cisco, Arista, Juniper, and others
    • Under the hood, uses the appropriate protocol (SSH, API, NETCONF)
    • Use case: Multi-vendor environments where you want consistent automation code
  • Cisco NSO (Network Services Orchestrator): A commercial product, not a library. Its Network Element Drivers (NEDs) put every device, whatever its interface, behind one YANG-modeled API.
    • Computes the diff against the device itself, and commits changes across many devices as one transaction, with rollback
    • Service packages can translate a vendor-agnostic service model into per-device configuration, which makes NSO a whole adapter layer at product scale: translation and delivery in one. Adopting it moves your adapters into the product
    • Use case: Multi-vendor service provisioning where the team accepts a commercial product’s model in exchange for transactions and ready-made drivers

Why use an abstraction layer? Instead of writing different code for Cisco vs. Juniper, NAPALM gives you one API. Call get_facts() and NAPALM figures out how to get device facts whether it is a Cisco IOS device (via SSH), Arista EOS (via eAPI), or Juniper Junos (via NETCONF).

The trade-off: abstraction hides vendor-specific features. For common operations (get config, push config, get facts), it is great. For more advanced operations or exotic vendor features, you drop back to native interfaces, because the abstraction likely does not implement them.

A library like NAPALM hides the interface. A declarative resource module goes one step further and hides the syntax too: it takes technical-layer data and produces the platform’s configuration itself, which makes it the translation half of an adapter. Three habits keep it safe: send it vendor-agnostic data and never pre-baked syntax, pin its version in the adapter’s release, and require its dry-run diff before it applies anything.

Speaking the protocol is the visible part of delivery. The other part is the connection lifecycle, and that is where scale problems show up. A CLI session over SSH is expensive: TCP handshake, key exchange, authentication, then a shell that has to be driven and parsed. Paying that cost once per task, across hundreds of devices, is how an executor overwhelms the systems around it. So the adapter keeps and reuses its connections:

  • Connection reuse: open one session per device and run every task in the job through it, instead of reconnecting per task.
  • Pooling and caps: limit simultaneous sessions, both per device and in total, so a parallel job cannot open 800 at once. The cap protects the device control plane and the authentication system behind it.
  • Session state: a CLI session has modes (enable, config, commit). The adapter tracks which one it is in, so a task never sends a config line to a prompt that cannot accept it.
  • Teardown: close sessions explicitly. Devices cap concurrent management sessions, often at single digits, and an executor that leaks them locks out the engineers who need to log in.

Structured interfaces change the economics, not the principle. NETCONF and gNMI keep a long-lived channel open by design; a REST API is stateless per request but still wants a pooled HTTP connection and a cached token rather than a fresh login per call.

Moreover, network execution is not just configuration management. You may need to run other types of operations, listed in Table 6.5:

Operation TypeWhat It CoversNotes
Configuration changesPush full configs/snippets/declarative state; merge/replace/delete modesMost common operation type and best supported by tooling
Zero Touch ProvisioningAutomated onboarding at first bootA distinct execution pattern, detailed later in this chapter
File transfersUpload images, download logs/backupsCommon protocols: SCP, SFTP, TFTP, HTTP
Software upgradesStage the image, install, reload, verify the running versionPre-checks (disk space, redundancy), post-checks, a rollback image, and mixed versions during the rollout (Chapter 10)
Device operationsReboot/reload, operational commands (ping/traceroute), backupsCommon for day-2 operations and remediation
RollbackRevert configuration to previous known-good stateNative rollback on some platforms; backup restore on others
Table 6.5: The types of operations the Execution block performs.

Each operation type has its own error modes and needs specific handling. The results should be exposed to Orchestration for decisions, while Execution can still handle local guardrails and retries.

Where rendering and validation belong: The Intent block owns intent and validates it when it is written. Execution owns rendering or translating that intent into platform syntax, through the adapters, along with the device-level safety checks and operational validation (reachability, pre/post checks) when it is necessary to do just before execution. Orchestration decides when to validate and what to do with outcomes (approve, pause, rollback, or escalate). If you want a simple rule: validation that changes workflow belongs to Orchestration; validation that changes device actions belongs to Execution.

The Execution block is one of the most popular blocks of any network automation strategy because it is the one that makes things happen. Almost every network automation product you can think of, even those focused on observability, has some execution capabilities.

Practical Considerations#

Three realities complicate the picture above: devices with no configuration yet, targets that are not devices, and the write access that makes this block the most consequential one to secure.

Zero Touch Provisioning#

Zero Touch Provisioning (ZTP) is a distinct execution pattern where a device boots for the first time and automatically retrieves and applies its full configuration without any human intervention at the device. Its data flow is different enough from day-2 operations to deserve its own design.

The ZTP flow

The flow runs in five steps, shown in Figure 6.5.

ZTP

Figure 6.5: The Zero Touch Provisioning flow.

Before the device ships, it is enrolled in the Source of Truth, usually by serial number, which at that point is the only thing known about it. It boots with no configuration, and DHCP hands it a management address plus a pointer to a bootstrap server. It fetches a minimal bootstrap configuration from that server, which the Executor rendered from the device’s enrollment record in the Source of Truth, and comes online on the management network. Observability notices a device that is reachable and in the expected state, and signals Orchestration. The Executor then pulls the full intent from the Source of Truth, renders it, and applies it.

The bootstrapping step is minimal on purpose: just enough configuration to get the device onto the management network and able to authenticate. Full provisioning runs after that as a standard Executor job, pulling complete intent from the Source of Truth. This means ZTP reuses the same execution path as day-2 operations, with no separate provisioning system.

Common ZTP patterns

Table 6.6 compares the common patterns.

PatternHow it worksTrade-off
DHCP + static fileDHCP points to a static config file per device (matched by MAC or serial)Simple to implement; does not pull from SoT; breaks at scale
DHCP + dynamic generationBootstrap server has the Executor render the device-specific initial config from its SoT record at request timeSoT-driven from day zero; requires the SoT to have the device enrolled before it boots
OS image + configDevice downloads both OS image and config during boot (needed for devices requiring an OS provision)Handles bare-metal or factory-reset devices; increases bootstrap server complexity
Table 6.6: Common Zero Touch Provisioning patterns.

ZTP introduces a sequencing dependency: the device must be enrolled in the Source of Truth before it physically boots. Otherwise the bootstrap server cannot confirm the device is expected, and has nothing to generate a config from.

Trusting the first boot

Enrollment tells the bootstrap server which device to expect. It does not prove that the device asking is that device, and it does not prove to the device that the server is yours. A serial number can be copied, and anyone on the bootstrap segment can answer a DHCP request. Classic ZTP trusts both sides of that exchange.

Secure Zero Touch Provisioning (SZTP, RFC 8572) closes both gaps. The device proves its identity with a certificate the manufacturer installed at the factory, known as an IDevID. It accepts bootstrap data only when the data is signed and comes with an ownership voucher: a statement from the manufacturer that this device belongs to you. Where your platforms do not support SZTP yet, contain the risk instead. Put bootstrap on a VLAN that reaches only the bootstrap server, keep long-lived secrets out of the bootstrap configuration, and rotate the initial credential in the first full provisioning run.

An important consideration for the Executor is working well with two very different types of network infrastructure: physical and cloud-based.

Hybrid Execution#

Nowadays, in many cases, the Executor has to operate across two very different environments: traditional network devices and cloud-native platforms. These environments have different API paradigms, authentication models, and failure modes. Handling both of them the same way leads to fragile automation, but approaching them as completely separate systems duplicates effort and creates inconsistent operations.

The divergence problem

Table 6.7 shows where network devices and cloud platforms diverge.

DimensionNetwork devicesCloud platforms
API styleSSH, NETCONF, gNMI (stateful, long-lived connections)REST/HTTP (stateless, short-lived requests)
Auth modelShared credentials (username/password, SSH keys)Temporary tokens, service accounts, instance roles (AWS SigV4, Azure AD, GCP service accounts)
Operation completionUsually synchronous (the command either succeeds or fails before the session ends)Often asynchronous (API returns “accepted”, requires polling for final status)
Failure ambiguityA session that drops during a commit may or may not have applied the change; confirmed commit or a read-back settles itA cloud API timeout may or may not have applied the change; you must query to find out
Idempotency approachImperative by default; declarative requires careful module designDeclarative through infrastructure-as-code tools (Terraform, CloudFormation, Pulumi) over imperative REST APIs
Table 6.7: How network devices and cloud platforms diverge.

My recommendation is to keep Intent and Orchestration unified for all the network infrastructure. The same service request that creates a VLAN on campus switches may also need to create a security group in AWS. The Source of Truth holds both. The Orchestrator coordinates both. Only at the Network Adapter layer does the execution path diverge: one adapter handles NETCONF/Ansible against campus switches; another handles Terraform or cloud provider APIs against the cloud environment.

A cloud API change and a network device change then go through the same approval and audit trail, even though the protocols are completely different.

The secrets manager strategy must accommodate both long-lived network device credentials and short-lived cloud tokens. This is one of the security considerations the Executor has to account for, because it is the block of the architecture that changes the real network.

Security Considerations#

The Executor is the component in your architecture that has write access to the network. It can push configurations, restart services, upgrade firmware, and alter routing policies across hundreds of devices simultaneously. That makes its security posture more consequential than almost any other component, and yet it is frequently the most neglected from an architectural standpoint. A compromised Executor is a data-breach risk like any other system, and an outage risk that most systems are not.

Chapter 13 covers the security model of the whole NAP: identities, secrets, least privilege, separation of duties, and the evidence an auditor asks for. Four points are specific to the block that writes to the network.

Credentials arrive at runtime and leave with the job. Device credentials never appear in playbooks, templates, job definitions, or version control. The Executor fetches them from the secrets store at job start and discards them at the end (Chapter 13 covers the store). For cloud targets the rule takes a stronger form: generate the credential at job start and never store it at all, using the provider’s own mechanism (AWS instance profiles, Azure managed identities, GCP workload identity). Rotation then stops being an event: rotate device passwords on a schedule, and the next run picks up the new value, with no window where half the fleet still answers to the old one.

Device credentials are scoped per operation. Read operations (gathering facts, dry-run checks, pre-deployment validation) use read-only credentials. Write operations use credentials scoped to the change type: a job deploying VLAN changes does not hold credentials that allow BGP configuration changes. Where the network platform supports role-based access (Arista roles, Cisco privilege levels, NETCONF access control), use it to limit the blast radius of any single compromised session.

The person who launches a job is not the person who wrote it. An operator launching a VLAN deployment does not need, and should not have, access to the roles or templates that implement it. In AWX and AAP, for example, the Execute role on a job template lets an operator launch it, while changing the playbooks underneath it takes a role on the project. The person initiating a firmware upgrade across 800 switches should not also be the person who wrote the upgrade playbook, and a second reviewer approves the playbook before it is available for production.

The Executor lives on the management network. The Executor and its control plane (AWX, Ansible control nodes) sit in a management segment, and execution traffic reaches devices through the out-of-band network where one exists, not through the data plane the Executor might be changing. Inbound access to trigger jobs requires authentication and is not reachable from untrusted networks: an Executor reachable from the production user VLAN lets any compromised host there trigger network changes.

Every execution also leaves a record: who triggered it, which template and parameters, which devices, and the per-device outcome. Chapter 8 makes that part of the workflow’s audit record, and Chapter 13 turns it into evidence. Design it into the Executor from the start; retrofitting it later costs far more.

With the functionalities and the practical realities covered, one question remains before the example: which tools implement them.

Solutions Landscape#

The list of Execution solutions is very long. These are the most popular ones, even though some of them also implement other architecture functions.

The tools listed here are examples for explanatory purposes, not recommendations. Evaluate them against your team’s capabilities, existing tooling, and the platforms in your fleet.

Frameworks and engines

  • Ansible: a YAML DSL, agentless, with a large module ecosystem that covers servers and network devices alike. The quick win for most teams; at large scale it needs tuning, and complex logic gets hard to maintain in YAML.
  • Terraform: declarative infrastructure as code in HCL, with a strong plan-and-diff engine and stateful workflows. Excellent for cloud; network provider maturity varies, the state file adds operational work, and day-2 operations are its weak side.
  • Salt: Python-based, agent or agentless, with an event-driven architecture that scales well. A good fit for existing Salt shops and event-heavy operations; its network-automation community is smaller and onboarding steeper.
  • Nornir: a Python framework with threaded parallelism, flexible and easy to debug. For Python-capable teams with custom or performance-sensitive needs; it ships fewer ready-made components, so you own more of the engineering.

Commercial and vendor-specific

  • Cisco NSO: model-driven, with YANG service models, one Network Element Driver per platform, and transactional multi-device commits with rollback. Common for multi-vendor service provisioning in service provider networks; the licensing is commercial, and the device models and service logic live inside the product, so leaving it means rebuilding them.
  • Vendor controllers (Cisco Catalyst Center, Aruba Central, Juniper Mist): intent and policy with vendor-native workflows. Strong when you standardize on one vendor with good controller APIs; the patterns do not carry over to a multi-vendor fleet.

Building your own in Python or Go is always an option, and it gives you maximum control for domain-specific logic, edge cases, and specialized workflows. The price is that you own everything: standards, reliability patterns, testing, and lifecycle.

Many teams use multiple tools depending on the use case and network infrastructure. Do not underestimate the benefits of adopting an existing tool versus building from scratch. Most of the features you need are likely already in place, and if the tool lets you extend it, the rest is within reach.

To close the chapter, an example.

Implementation Example#

We continue with the campus network from Chapter 4. The VLAN service definition (its ID, subnet, and target switch groups) is now stored in the Source of Truth as technical-layer data. This example focuses on how the Execution block turns that intent into three platforms’ syntax and deploys it reliably across the campus, using both ways an adapter has to do it: rendering and translation.

Scenario: The application team’s VLAN service, app-payments, went live in Building B first. The request arrived through a ticketing system (service name, building, profile, approval) and expanded from the service layer into the technical layer. A month later the team asks for it in every building. This job targets all 800 access and distribution switches, from three vendors; Building B’s 24 already have it.

Requirements:

  • Deploy VLAN configuration to multiple switches in parallel
  • Render or translate the same technical-layer record for three platforms, and store each rendered artifact before deploy
  • Verify pre-conditions (switches are reachable; where the VLAN already exists, it matches the intent)
  • Perform a dry run to show what would change
  • Execute actual deployment with rollback capability if failures occur
  • Verify at three levels: the configuration reads back as intended, the VLAN is active on the device, and a host in the new VLAN reaches its gateway

Blocks involved:

  1. Source of Truth: holds the inventory and the VLAN service definition
  2. Orchestration: coordinates the phases and owns the triggering surface (API, webhook, schedule) and the approval gate
  3. Observability: supplies the pre and post data the validation gates read
  4. Execution:
    • Data Integration: a dynamic inventory source that queries the Source of Truth at job start, the technical-layer record for each device, and a secrets backend that injects credentials
    • Triggering: an API call from the Orchestrator, which subscribes to the Source of Truth’s change events, plus manual and scheduled entry points
    • Engine: five phases (pre-check, dry run, deploy, verify, rollback), executed in batches of 50, with a separate concurrency cap for the authentication system
    • State Management: per-phase and per-device status, with a rollback point captured per device
    • Network Adapter: one adapter per platform. The Vendor A and Vendor B adapters render the record with your templates; the Vendor C adapter translates it with a declarative module. Each one delivers over its device’s interface and reads its responses
    • Workers: one worker per campus building, close to its devices; execution state stays central

This example names no automation products on purpose. Several tools can play each role, and naming them would date the chapter faster than anything else. The device platforms stay generic for the same reason: what matters is that there are three of them, speaking three different configuration syntaxes.

The fleet uses both, chosen per platform with the question from the Rendering and Translation section: does it need the device’s current state?

  • Vendor A and Vendor B: rendering. Their interfaces accept a full replace of the VLAN section, so rendering needs nothing from the device. The templates in their adapters render a complete artifact per switch, and the adapter delivers it.
  • Vendor C: translation. Its trunks accept only the whole allowed-VLAN list. Tagging VLAN 412 on an uplink that already carries VLANs 10 and 20 means sending 10,20,412, and only something that has read the device knows the 10,20 part. A template cannot, so the Vendor C adapter uses a declarative module that reads the trunk first.

Listing 6.7 shows the Vendor B template, from the Vendor B adapter, applied to the record of Listing 4.7 in Chapter 4.

{% for sw in vlan.switches if sw.platform == "vendor-b" %}
! ===== {{ sw.name }} =====
vlan {{ vlan.vlan_id }}
  name {{ vlan.name | upper }}
{% if sw.role == "distribution" %}
interface Vlan{{ vlan.vlan_id }}
  description {{ vlan.name }} gateway
  ip address {{ vlan.gateway.address }} {{ vlan.gateway.mask | to_netmask }}
  mtu {{ vlan.mtu }}
  service-policy input QOS-{{ vlan.qos_class | upper }}-IN
{% endif %}
{% endfor %}
Listing 6.7: The Vendor B adapter’s template, rendering the agnostic record into one platform’s syntax.

Note the filter on the loop. This template renders one platform, and the Vendor A adapter has its own template, selected by that same platform field, producing different syntax from this identical record.

Two details worth pausing on. to_netmask is a filter you supply, not something Jinja ships; every real template library grows a handful of these for address arithmetic. And the MTU comes from the record, even though the campus standardized on jumbo frames everywhere: the 9216 is set once in the profile (Listing 4.6), not hardcoded in the template, as the Rendering and Translation section recommends.

Rendering for sw-b-dst-01 gives the configuration artifact the adapter stores and later delivers:

! ===== sw-b-dst-01 =====
vlan 412
  name APP-PAYMENTS
interface Vlan412
  description app-payments gateway
  ip address 10.12.4.1 255.255.255.0
  mtu 9216
  service-policy input QOS-AF21-IN
Listing 6.8: The rendered configuration artifact for one distribution switch.

Listing 6.9 shows what each adapter works from.

# vendor-a, vendor-b: rendering
device: sw-e-acc-07
platform: vendor-a
adapter: vendor-a 4.2.0             # templates; accepts schema 2.x
input: vlan-service app-payments, schema 2.1
artifact: artifacts/REQ-4519/sw-e-acc-07.cfg   # rendered during validation
---
# vendor-c: translation
device: sw-d-acc-03
platform: vendor-c
adapter: vendor-c 2.3.1             # pins module vendor-c-vlans; schema 2.x
input: vlan-service app-payments, schema 2.1
vlan: { id: 412, name: app-payments, tagged_on: [Po1, Po2] }
Listing 6.9: What each adapter works from.

Neither input carries syntax. Nothing in them would change if the campus replaced Vendor C tomorrow: only the Vendor C adapter would. From here on, the phases are the same for every switch. Only two of them behave differently by adapter: the dry run, and what the adapter delivers.

Implementation Flow#

The Executor job starts as soon as the Source of Truth reports a change and the Orchestrator decides it is time to make the network match the new intent. Figure 6.6 groups the five phases into four steps and shows who owns each one; the list below walks through them.

Execution Workflow

Figure 6.6: The execution workflow.
  1. Trigger and prepare. The Source of Truth’s change event reaches the Orchestrator, which starts the workflow. It syncs inventory from the Source of Truth, so the target list reflects what is enrolled right now, not when the job was written. Then it fetches the technical-layer record for every switch in scope, and the Vendor A and Vendor B adapters render their artifacts, which are stored before anything else happens.

  2. Decide. The pre-check phase validates reachability, the existing VLAN state, and the site guardrails, and records the before snapshot that verification will compare against. The dry-run phase reads each device and computes what would change, without applying anything. For Vendor A and Vendor B it compares the rendered artifact with the running configuration; for Vendor C the module reads the trunk lists and reports the commands it would send. Both paths produce the same change plan, so the approver reviews one format. The approval gate, which belongs to Orchestration, then holds for a human who, by design, is not the person who wrote the automation. Nothing has touched a device yet, so walking away undoes everything up to here.

  3. Change. The deploy phase applies the VLAN intent in batches of 50, capped separately against the authentication system. Where devices fail within the change’s threshold, the rollback phase restores those devices only. Beyond the threshold, the job stops and reports, and the Orchestrator’s Saga takes over, as Chapter 8 describes.

  4. Confirm. The verify phase checks configuration, operational state, and the service itself, waiting for convergence before it believes the answer. Observability supplies the after data, final validation compares it against the before snapshot, and the execution summary goes back to the ticket.

Each handover between phases carries an artifact.

The Artifacts Between Phases#

Four artifacts carry the job. Their shape matters more than their syntax: whatever tool you use produces something equivalent, and if it does not, you have found a gap.

The dry-run phase produces one change plan per inventory item. This is what the approver signs off on, so it has to answer three questions: what is there now, what would change, and what is at risk if it goes wrong. Listing 6.10 shows the plan for one Vendor A switch. The source field records where the diff came from, which applies the visibility rule from the Rendering and Translation section. A Vendor C plan has the same shape: source names the module’s dry run instead, and current adds the trunk lists the module read before computing the change.

device: sw-e-acc-07
platform: vendor-a
source: rendered artifact vs running config
reachable: true
current:
  vlan_412: absent
planned:
  - create vlan 412, name app-payments
  - tag vlan 412 on uplinks Po1, Po2
risk:
  users_behind_this_switch: 46
  redundant_uplink: true
rollback_point: cfg-20260414-1431.bak
Listing 6.10: The change plan for one switch.

Similarly, the deploy phase produces one result record per device, or per inventory item. Note the two fields that make a retry safe: attempts tells you this device was tried twice, and rollback_point names the configuration it can be returned to. A configuration backup contains secrets, so store the rollback point with the same protection as the credentials, or strip the secrets the Executor resolves at run time.

Every artifact from the deploy phase onward carries the same two identifiers. The request_id is the change ticket that asked for this, and the job_id is this particular execution of it. A re-run after a partial failure keeps the same request_id and gets a new job_id, which is how you tell “we tried twice” from “two people asked for the same thing”. Without that pair the audit trail described in the Security Considerations section cannot be reconstructed: you end up with device changes that have no request behind them, and requests with no evidence of what they did. Listing 6.11 shows a deploy record.

{
  "request_id": "REQ-4519",
  "job_id": "JOB-20260414-1431",
  "device": "sw-e-acc-07",
  "phase": "deploy",
  "status": "changed",
  "started": "2026-04-14T14:31:08Z",
  "duration_s": 3.4,
  "attempts": 2,
  "first_error": "connection timeout",
  "rollback_point": "cfg-20260414-1431.bak"
}
Listing 6.11: The deploy record.

The verify phase produces its own record, and waited_s is the field that makes it trustworthy: the check did not run the instant the config landed, it waited for the protocols to settle.

{
  "request_id": "REQ-4519",
  "job_id": "JOB-20260414-1431",
  "device": "sw-e-acc-07",
  "phase": "verify",
  "status": "passed",
  "config": "match",
  "operational": "vlan 412 active, tagged on Po1 and Po2",
  "service": "test host in vlan 412 reached its gateway",
  "waited_s": 12
}
Listing 6.12: The verify record.

The batch summary aggregates those records while the job is still running. This artifact is the one missing in the opening story: at any moment it says exactly which devices are done, which failed, and which have not been touched.

request_id: REQ-4519            # the change ticket
job_id: JOB-20260414-1431       # this execution of it
name: vlan-412-app-payments
batch_size: 50
auth_concurrency_cap: 20   # the AAA server, not the switches, sets this
batches_completed: 11 of 16
devices:
  ok: 24          # already compliant, no change made
  changed: 524
  failed: 2
  pending: 250
failed_devices:
  - sw-c-acc-12   # authentication failure, not retried
  - sw-a-acc-04   # unreachable after 3 attempts
halt_threshold: 5% per batch, not reached
Listing 6.13: The batch summary, mid-job.

The split between ok and changed is idempotency made visible: Building B’s 24 switches already had VLAN 412 and were left alone; 524 did not and were configured. Re-run the job and changed drops to zero.

Solution Summary#

This implementation demonstrates all key execution capabilities:

  • Data Integration: pulls inventory and the technical-layer record from the Source of Truth at job start, and credentials from the secrets backend
  • Triggering: an API call from the Orchestrator, which owns the webhook, schedule, and approval gate in front of it
  • State Management: per-phase and per-device status tracks progress and failure domains; the rollback path is explicit
  • Engine: parallel execution in batches, error handling, and dry run
  • Network Adapter: one adapter per platform turns the same record into three configuration syntaxes, delivers each over its platform’s interface, and interprets the responses and error codes. Two adapters render with your templates; the third uses a declarative module
  • Verification: pre and post data from Observability supports final validation and reporting

Resiliency features:

  • Pre-checks prevent deploying to unreachable devices or creating duplicate VLANs
  • Dry run shows changes before applying, in the same change plan format for rendering and translation
  • Safety checkpoints render and store the intended artifact, and gather the current config, before any apply step runs
  • Idempotent adapters make re-running safe
  • Post-verification catches silent failures
  • Rollback runs as a separate phase, limited to the failed devices; beyond the threshold, the Orchestrator’s Saga takes over

Scaling considerations:

  • Parallel execution in batches of 50 switches, verified before the next batch starts
  • At this size, batch sequencing belongs to the Orchestrator; the engine runs one batch well
  • The concurrency cap comes from the weakest shared dependency, here the AAA server, not from the device count

None of this needed an exotic tool. It needed the five functionalities wired together in the right order, with an artifact at every handover and a way back at every step.

Summary#

The Executor is what makes automation something real. The Intent is the plan, and the Executor picks up that plan and makes it happen.

To make that possible, the Executor needs several functionalities (Data Integration, Triggering, State Management, Engine, and Network Adapter) that support the design principles that make network automation trustworthy and reliable, while owning the platform-specific details via the Adapter Pattern (i.e., how to render or translate from the agnostic intent to each platform’s syntax).

Its main focus is on per-device interaction, leaving complex workflows to the Orchestration block that governs the network automation process, and provides data from the Intent and Observability as needed for the Executor. The Executor has to remain as simple as possible because it is powerful and risky.

Next, in Chapter 7, we cover its counterpart (the Collector), and the whole validation of the outcome that the Executor produced in the network.

References#

💬 Found something to improve? Send feedback for this chapter

📖 Enjoying the book? It is also available on Kindle and in paperback. Get it on Amazon →