Study FAQ
How do Ansible and Terraform differ for network automation?
Also asked as 2
- 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?
Answer
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
Full explanation
Network Automation, REST APIs, JSON, Ansible, Terraform, and AI
Study guide · 200-301
Read the full explanation