Terraform interview question · Most asked

Terraform and Ansible: how do they differ, and do you need both?

Summary

Terraform is declarative provisioning of infrastructure through APIs, tracking state to manage the full lifecycle (create, update, destroy). Ansible is primarily configuration management and orchestration: it connects to machines (SSH, WinRM) or APIs and runs tasks, usually without a state file, best for configuring operating systems and software on existing hosts.

Longer Answer

Common split: Terraform creates networks, instances and managed services; Ansible (or images built with Packer) configures the software on hosts. With immutable infrastructure and containers, much of the configuration-management need moves into image builds, so many teams need Ansible less. Both can technically overlap, but using each for its strength avoids fighting the tool.

Key Points

  • Terraform: declarative provisioning with state.
  • Ansible: configuration and orchestration.
  • Often used together.
  • Immutable images reduce config management needs.

More most-asked Terraform questions

← All Terraform questions