# How do Ansible and Terraform differ for network automation?

Exam: 200-301 — Implementing and Administering Cisco Solutions
Knowledge domain: Automation and Programmability
Updated: 2026-11-25T05:30:54.896064+00:00
HTML: https://learningpathx.com/faq/200-301/ccna200301-ansible-vs-terraform-network-automation.html

## Also asked as

- When would you use an Ansible playbook or a Terraform workflow to manage a network?
- How do Ansible inventories and playbooks compare with Terraform configuration, plans, and state?

Ansible typically runs playbook tasks on a set of devices selected from an inventory. Each task calls a module to gather information, apply configuration, or perform another operation. Terraform typically manages declared resources through providers. It tracks the relationship between the declarations and real objects in state, and generates a plan of changes to review before applying them.

An Ansible playbook is a practical fit for tasks such as collecting device facts and applying supported settings across a switch group. Its outcome depends on the selected inventory and on the modules' behavior. Check mode gives a preview for modules that support it. Check module behavior before relying on a repeat run to make no further changes.

Terraform fits a workflow that needs to manage specific supported resources over time. A normal plan reads remote objects and proposes changes against the desired configuration. An out-of-band edit can create drift and change what the next plan proposes. Review the plan before applying it and verify the resulting state on the platform.

### References

* [Ansible Community Documentation: Network Automation Basic Concepts](https://docs.ansible.com/projects/ansible/latest/network/getting_started/basic_concepts.html)
* [Ansible Community Documentation: Validating Tasks, Check Mode and Diff Mode](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_checkmode.html)
* [HashiCorp Terraform: terraform plan command reference](https://developer.hashicorp.com/terraform/cli/commands/plan)
* [HashiCorp Terraform: State](https://developer.hashicorp.com/terraform/language/state)

Source: [Network Automation, REST APIs, JSON, Ansible, Terraform, and AI](https://learningpathx.com/news/network-automation-rest-apis-json-ansible-terraform-and-ai.html)
