Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Ansible Difficulty: Advanced ClaudeChatGPTCursor

Ansible Network Device Playbook Authoring Prompt

Author safe network automation plays using network_cli/httpapi connections, config backups, and check-mode diffs before pushing changes to switches and routers.

Target user
Network engineers automating switch/router/firewall config with Ansible network collections
Difficulty
Advanced
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior network automation engineer who treats a config push to a router or switch as more dangerous than almost any Linux task, because a bad line can sever the management plane and isolate an entire site with no way back in.

I will describe network devices and a change I need to make. Author the playbook safely.

Steps:

1. **Connection and inventory**: set the correct `ansible_connection` (`network_cli` or `httpapi`), `ansible_network_os`, and per-platform vars; do not use the default ssh/become path meant for Linux hosts.
2. **Backup first**: use the platform's config backup (e.g. `*_config` with `backup: true` or a facts gather) so you have the running-config before any change.
3. **Check mode + diff**: run with `--check --diff` so the exact config delta is shown and reviewed before it is applied.
4. **Idempotent config modules**: prefer resource modules / declarative `*_config` sections over raw command pushes so re-runs converge instead of appending.
5. **Guardrails**: use `serial` and a canary device, and consider a commit-confirm / rollback mechanism where the platform supports it.
6. **Verification**: gather facts or run show commands after the change to confirm intended state and reachability.

Fill in:
- Platform(s): [ios / nxos / eos / junos / ...]
- Connection: [network_cli / httpapi]
- Change to make: [DESCRIBE]
- Lab/canary device available: [YES/NO]

Output format: the inventory/group_vars connection settings, the backup task, the change task using idempotent modules, the --check --diff run plan, and post-change verification.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

Network automation looks like ordinary Ansible until the first push cuts off the management path and isolates a site with nobody able to log back in. This prompt front-loads the two things that prevent that: an always-on running-config backup and a mandatory --check --diff review so the exact delta is seen before it lands. It also steers toward declarative resource and *_config modules over raw command pushes, which is the difference between a re-run that converges and one that appends duplicate lines forever.

The connection and privilege detail is where network plays quietly go wrong. Devices don’t use become like Linux hosts — privilege escalation and connection type are platform-specific, and getting them wrong applies changes with the wrong privilege or silently no-ops. By pinning ansible_connection, ansible_network_os, serial, and a canary device, the prompt keeps a routine config change from becoming a site-wide blackout.

Related prompts

More Ansible prompts & error guides

Browse every Ansible prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.