generate-terraform
Write Terraform for network infrastructure — NetBox, Palo Alto PAN-OS, FortiOS, Cisco Meraki, Cisco IOS-XE and NX-OS providers — then validate it locally and end with terraform plan. Use when the user asks for Terraform, HCL, or infrastructure-as-code for firewall rules and objects, NetBox IPAM/DCIM records, Meraki networks and SSIDs, VLANs, or interfaces. Arista EOS/CloudVision has no Terraform provider — use generate-playbook. For Ansible use generate-playbook, for Python use generate-automation, for a CI pipeline around it use generate-pipeline.
- License 许可
- MIT
- 最近更新
- 2026-11-02
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- generate-terraform
- description
- Write Terraform for network infrastructure — NetBox, Palo Alto PAN-OS, FortiOS, Cisco Meraki, Cisco IOS-XE and NX-OS providers — then validate it locally and end with terraform plan. Use when the user asks for Terraform, HCL, or infrastructure-as-code for firewall rules and objects, NetBox IPAM/DCIM records, Meraki networks and SSIDs, VLANs, or interfaces. Arista EOS/CloudVision has no Terraform provider — use generate-playbook. For Ansible use generate-playbook, for Python use generate-automation, for a CI pipeline around it use generate-pipeline.
- when_to_use
- Trigger phrases: "Terraform for firewall rules", "HCL for NetBox", "Meraki networks and SSIDs as code", "infrastructure-as-code for VLANs and interfaces", "terraform plan for PAN-OS or FortiOS objects".
- allowed-tools
- mcp__plugin_damira_damira__damira_search_vendor_docs
02 资源文件 1
- 参考文档references/terraform-providers.md3.3 KB
03 SKILL.md 正文
Terraform generation
You write the HCL. Damira supplies the vendor facts and the gate: every configuration goes
through damira validate (fmt + init + validate) before you hand it back, and the hand-back
is always terraform plan, never apply.
Step 1: Gather requirements
- Target — which system (NetBox, PAN-OS/Panorama, FortiGate, Meraki, IOS-XE, NX-OS; Arista EOS/CloudVision routes to generate-playbook)
- Resources — rules, objects, VLANs, prefixes, SSIDs, interfaces
- State — local for a trial; a remote backend with locking for anything shared
- Existing objects — anything already on the device needs
importblocks, not re-creation
Step 2: Look up the provider
Read references/terraform-providers.md (beside this file) for the provider source, a
version-constraint pattern, auth env vars and known quirks. Call
damira_search_vendor_docs for resource names and arguments you are not sure of —
providers rename resources between major versions. If the lookup fails, say so
rather than emitting arguments you could not verify.
Step 3: Write the configuration
Save under terraform/{name}/:
versions.tf—required_versionandrequired_providerswith~>pinsproviders.tf— provider blocks with no credentials; auth comes from the provider's env vars (listed in the reference pack) orsensitive = truevariablesvariables.tf— typed variables withvalidationblocks where values are constrainedmain.tf— resources;for_eachover maps (stable keys), notcountoutputs.tf— what the user needs to see after plan/applyterraform.tfvars.example— example values, no secrets
Run terraform fmt yourself if it is installed; validate fails on unformatted files.
Sources: providers only from the registry namespaces listed in
references/terraform-providers.md; modules only from the Terraform Registry or local
paths. No git::, http(s)://, s3:: or other remote module sources, and no
data "external", unless the user asked for that exact source.
Validate loop
Delegate this loop to the damira:damira-fixer agent (it runs on Haiku). Give it the path, --skill generate-terraform, and <plugin root>. It runs the command below, fixes only what the findings name, and stops after 3 rounds. Read its report: a change to a device command, module or resource is your call, not its. If the agent isn't available, run the loop yourself as below.
The validator ships in this plugin, two levels above this skill's base directory:
<plugin root>/scripts/damira.py. It runs terraform fmt -check, then init -backend=false + validate on a throwaway copy (nothing is left in the user's folder). It
makes no Damira API call; init does download the providers you named. --skill tags the
local workflow event with this skill.
python3 "<plugin root>/scripts/damira.py" validate terraform/{name}/ --skill generate-terraform --host claude-code
- Ask before the first run.
initdownloads every provider and module you named and runs provider binaries on the user's machine. The post-write hook does not run onterraform/at all (it watchesconfigs/,automation/,playbooks/only), so this explicit loop is the only check. List therequired_providerssources/versions and any modulesourcefor the user and run validate only after they approve. Anything outside the pack's namespaces needs their explicit yes. - Run it on the directory you wrote.
- Fix every FAIL and re-run — at most 3 rounds.
- Still failing after 3 rounds: stop, tell the user which checks fail and why. Do not hand it back as finished.
- A
skippedcheck means terraform is not installed — pass the install hint on; it is not a pass. AnUNVERIFIEDresult is not a pass either.
Step 4: Hand back — end with plan
cd terraform/{name}
export <PROVIDER_AUTH_ENV_VARS> # see references/terraform-providers.md
terraform init
terraform plan -out=tfplan # review every change before anything else
Do not tell the user to run apply until they have reviewed the plan. State what validate
reported and any assumption.
04 同仓库更多 Skills
upgrade-plan
Ask Damira to assess a version-to-version upgrade of a network platform and produce the MOP and change control. Use when the user names a product and a target release — "IOS-XE 17.6.5 to 17.9.5", "CUCM 12.5 SU7 to 15", "PAN-OS 10.2 to 11.1" — or asks what breaks, what the risk is, or how long a maintenance window needs to be. Covers CUCM, IOS-XE, IOS-XR, NX-OS, PAN-OS, FortiOS, Junos, ISE, ASA, WLC/Catalyst 9800. Not for platform-to-platform migration (CUCM to Webex Calling, on-prem to cloud) and not for diagnosing a fault after an upgrade — use troubleshoot for that.
troubleshoot
Ask Damira to diagnose an active, in-progress network fault. Use when the user reports something broken right now — an outage, a flapping interface, a BGP or OSPF adjacency down, dropped or blackholed traffic, failed calls, users unable to connect — or pastes show/log output for analysis. Also fires on direct questions like "why is BGP down" or "why is OSPF stuck in EXSTART". Returns vendor-specific diagnosis with exact CLI commands. Do NOT use for "how does X work" protocol questions, for reviewing a config that is not currently broken (use config-audit), or for planning an upgrade (use upgrade-plan).
source-of-truth-change
Turn intended state in the engineer's source of truth (NetBox or Nautobot) into a validated change, then hand it to the automation they already run — an Ansible Automation Platform job in check mode, a pyATS/Genie before-and-after diff, or a Terraform plan. Use when the user asks to make a change "from NetBox" or "from Nautobot", to push what the source of truth says, to bring devices in line with intended state, or to run a validated playbook through AAP or pyATS. Damira never applies the change; the engineer does. For a playbook with no source of truth use generate-playbook, for Terraform alone use generate-terraform, and for an active outage use troubleshoot.
lab-test-change
Test a network change in a throwaway ContainerLab lab before it goes near production — deploy the lab, apply the playbook or script, run show-command or pyATS/Genie checks, report pass/fail, and always destroy the lab. Use when the user says "test this in a lab first", "prove this change before the window", "dry-run this playbook against a lab", or wants evidence a change works before a CAB. Needs docker and containerlab on the engineer's machine; without them it validates only and says so. To only build a lab, use generate-lab; to write the change, use generate-playbook, generate-automation or generate-terraform.
generate-workbook
Build an Excel workbook (.xlsx) for a network procedure — a migration, platform migration, security audit, change control, or incident-response workbook — grounded in Damira evidence, with an HTML preview. Use when the user asks for a spreadsheet, workbook, tracker, or Excel version of a migration plan, cutover, audit findings, change record, or incident timeline. For a version-to-version upgrade, use upgrade-plan (it offers the workbook itself). Not for diagnosing an active fault — use troubleshoot.
generate-tests
Write network tests — pyATS/Genie learn, change, learn, diff jobs that prove a change did what it should and nothing else, and pytest tests for automation scripts — then validate them locally. Use when the user asks for pyATS, Genie, AEtest, a testbed file, pre/post change verification, state snapshots, or unit tests for a Nornir/Netmiko script. For the change itself use generate-playbook, generate-automation or generate-terraform.