← All posts
Deep Dive

Network-as-Code: Why YAML Intent Files Beat CLI Scripts

Stop scripting keystrokes. Start declaring desired state.

NAPT Team8 min read
Network-as-Code: YAML to configintent.yamlpipelinedeployedconfig

A CLI script is a recording of keystrokes — brittle, order-dependent, and dangerous to re-run. An intent file declares the desired end state and lets the platform figure out how to get there.

Imperative vs declarative

The CLI script says "enter config mode, type these lines." The intent file says "this peer should exist with these attributes." The first breaks if the device is already half-configured; the second converges to the same state every time.

yaml
bgp:
  asn: 65001
  neighbors:
    - peer: 10.0.0.2
      remote_as: 65002
      description: edge-peer
      state: present

Why it wins

  • Reviewable — a YAML diff in a pull request reads like English.
  • Idempotent — re-running it is safe; it only changes what drifted.
  • Testable — you can validate the file before any device sees it.
  • Auditable — Git history is your change record.

The pipeline does the translation

Intent compiles to vendor config in the render stage, gets diffed in dry-run, and is pushed only on approval. The engineer thinks in intent; the platform handles the CLI.

Pro tip: Keep the intent file the single source of truth. Out-of-band SSH edits create drift the next reconcile will fight.
#network-as-code#deep-dive#intent

Was this helpful?

Generate scripts for the task covered in this post

Describe what you need and NAPT writes production-ready automation in Netmiko, NAPALM, or Nornir.

Open Script Generator →
New to NAPT? Start with the Setup Guide

Related posts