Received 19.08.2024, Revised 25.11.2024, Accepted 18.12.2024
In the world of IT infrastructure management, the concept of infrastructure as code has firmly established itself. Two popular tools for implementing this approach – Terraform and Ansible – are widely used by DevOps professionals to automate and manage cloud and on-premises resources. Although both tools perform analogous tasks, they have distinct principles of operation, architecture, and application scenarios. The purpose of this study was to provide the key differences between Terraform and Ansible, their strengths and weaknesses, and use cases for each of these tools. Recommendations for choosing a tool depending on specific tasks were offered. Terraform, as a declarative style tool, enables users to describe the end state of the infrastructure, after which it automatically brings it to that state. Ansible, on the other hand, supports both declarative and imperative approaches, making it flexible for managing server configurations and performing orchestration. The study presented practical examples of using both tools. The first example demonstrated how Terraform can be used to automatically deploy cloud infrastructure in Hetzner Cloud. In this example, actions with a cloud service took place using declarative configuration files. The second example described how Ansible can be used to configure servers and how to automate server tasks. The study included scientific aspects related to the evaluation of IaC effectiveness, specifically formulas for calculating the time of application of changes in the infrastructure. The use of formulas helped to quantify the time and overall efficiency of work in the infrastructure to increase overall transparency and control over management processes. Thus, understanding the scenarios in which each tool is most effective will help engineers properly organise infrastructure management processes
infrastructure automation; configuration management; DevOps tools; Infrastructure as Code; optimisation; server deployment
[1] Bhatia, S., & Gabhane, C. (2024). Terraform: Infrastructure as Code. In Reverse engineering with Terraform (pp. 1-36). Berkeley, CA: Apress. doi: 10.1007/979-8-8688-0074-0_1.
[2] De Menezes, A.M. (2021). Hands-on DevOps with Linux. Noida: BPB Publications.
[3] Kadima, S. (2024). IAC: Terraform vs Ansible. Which one should you use? Retrieved from https://medium.com/@kadimasam/iac-terraform-vs-ansible-which-one-should-you-use-56c374dae5a2.
[4] Modi, R. (2021). Terraform Modules. In Deep-dive Terraform on Azure (pp. 115-137). Berkeley, CA: Apress. doi: 10.1007/978-1-4842-7328-9_5.
[5] Noviana, T. (2024). Infrastructure as Code (IaC) for network automation with Ansible. Retrieved from https://blogs.halodoc.io/ansible/.
[6] Sanne, S.H.V. (2023). Strategies for modularizing and reusing Terraform configurations effectively. Journal of Artificial Intelligence, Machine Learning and Data Science, 1(3), 541-545. doi: 10.51219/JAIMLD/harsha-vardhan/144.
[7] Vanbuskirk, M. (2023). What is Terraform & Infrastructure as Code (IaC)? Retrieved from https://www.pluralsight.com/resources/blog/cloud/what-is-terraform-infrastructure-as-code-iac.
[8] Witt, A., & Westling, S. (2023). Ansible in different cloud environments. (Bachelor’s thesis, Mälardalen University, Västerås, Sweden).
[9] Yap, Z. (2024). Implementing Infrastructure as Code with Ansible. Retrieved from https://medium.com/@zacyap/implementing-infrastructure-as-code-with-ansible-14b805614c05.