{"id":15679284,"url":"https://github.com/ishuar/terraform-ansible-azure","last_synced_at":"2025-04-19T12:57:11.403Z","repository":{"id":185209223,"uuid":"673146901","full_name":"ishuar/terraform-ansible-azure","owner":"ishuar","description":"Terraform and Ansible: Teaming Up for Automated Azure Cloud Magic","archived":false,"fork":false,"pushed_at":"2025-03-01T11:30:15.000Z","size":473,"stargazers_count":14,"open_issues_count":11,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T18:23:52.375Z","etag":null,"topics":["ansible","ansible-dynamic-inventory","azure","githubactions","iac-terraform","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ishuar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-01T01:33:52.000Z","updated_at":"2024-12-17T21:42:03.000Z","dependencies_parsed_at":"2023-08-16T23:44:29.397Z","dependency_job_id":"de0b9937-8129-4717-84f6-62a5e6917edd","html_url":"https://github.com/ishuar/terraform-ansible-azure","commit_stats":null,"previous_names":["ishuar/terraform-ansible","ishuar/terraform-ansible-azure"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishuar%2Fterraform-ansible-azure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishuar%2Fterraform-ansible-azure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishuar%2Fterraform-ansible-azure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishuar%2Fterraform-ansible-azure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ishuar","download_url":"https://codeload.github.com/ishuar/terraform-ansible-azure/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246156403,"owners_count":20732396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-dynamic-inventory","azure","githubactions","iac-terraform","terraform"],"created_at":"2024-10-03T16:28:14.283Z","updated_at":"2025-03-30T21:32:00.083Z","avatar_url":"https://github.com/ishuar.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- PROJECT SHIELDS --\u003e\n\u003c!--\n*** declarations on the bottom of this document\n--\u003e\n[![License][license-shield]][license-url] [![Contributors][contributors-shield]][contributors-url] [![Issues][issues-shield]][issues-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url]\n\n\n\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n\n   \u003ca href=\"https://github.com/ishuar/terraform-ansible\"\u003e\n    \u003cimg src=\"https://github.com/ishuar/terraform-ansible/blob/main/.vscode/extras/terraform-ansible-webservers.gif\" alt=\"Logo\"\u003e\n  \u003c/a\u003e\n\n  \u003ch1 align=\"center\"\u003e\u003cstrong\u003eTerraform and Ansible Hand In Hand\u003c/strong\u003e\u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\n    🌩️ Terraform and Ansible: Teaming Up for Automated Cloud Magic 🌩️\n    \u003cbr/\u003e\n    \u003ca href=\"https://github.com/ishuar/terraform-ansible/issues\"\u003e\u003cstrong\u003eReport Bug\u003c/a\u003e\u003c/strong\u003e or \u003ca href=\"https://github.com/ishuar/terraform-ansible/issues\"\u003e\u003cstrong\u003eRequest Feature\u003c/a\u003e\u003c/strong\u003e\n    \u003cbr/\u003e\n    \u003cbr/\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n- [Introduction](#introduction)\n- [Prerequisites](#prerequisites)\n    - [Conclusion](#conclusion)\n- [Examples in the Repository](#examples-in-the-repository)\n  - [Nginx Linux Webserver with Azure VMs Behind Azure Load Balancer](#nginx-linux-webserver-with-azure-vms-behind-azure-load-balancer)\n    - [Terraform Configuration](#terraform-configuration)\n    - [Ansible Playbook for Configuring Web Servers](#ansible-playbook-for-configuring-web-servers)\n      - [Conclusion](#conclusion-1)\n    - [Automation with GitHub Actions](#automation-with-github-actions)\n      - [GitHub Actions Workflows](#github-actions-workflows)\n      - [Conclusion](#conclusion-2)\n  - [Local Development vs. Automation](#local-development-vs-automation)\n- [Contributing](#contributing)\n- [License](#license)\n- [Contact](#contact)\n\n## Introduction\n\nTerraform and Ansible 🤝 are powerful tools that can work synergistically to provision and configure cloud infrastructure. In this repository, we'll explore how to utilize Terraform for infrastructure provisioning and Ansible for configuration management, all within the context of Microsoft Azure.\n\n## Prerequisites\n\nBefore diving into using Terraform and Ansible for your Azure cloud infrastructure, ensure you have the following prerequisites in place:\n\n| Prerequisite                       | Description                                                                                                                                                                                                                                                                                |\n|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Azure Account                      | You must have a valid [Azure account](https://azure.com) to create and manage resources on the Azure cloud platform.                                                                                                                                                                       |\n| Terraform Installed                | [Install Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) on your local machine. Terraform is an Infrastructure as Code (IaC) tool that enables you to define and manage cloud resources using configuration files.                             |\n| Ansible Installed                  | [Install Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) on your local machine. Ansible is an automation tool that allows you to configure and manage servers.                                                                                |\n| Azure CLI Installed                | [Install Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) to provide command-line access to Azure resources. Essential for both Terraform and Ansible to interact with your Azure account.                                                                         |\n| Azure Service Principal            | [Create an Azure service principal](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli) to authenticate Terraform and Ansible to access your Azure resources. The service principal should have sufficient permissions to create and manage resources. |\n| Version Control System (e.g., Git) | A version control system is crucial for managing and collaborating on code changes. If you're not already using one, consider setting up a [Git repository](https://docs.github.com/en/get-started).                                                                                       |\n\n#### Conclusion\n\nEnsuring you have the necessary prerequisites in place is the foundation for successfully integrating Terraform and Ansible for Azure cloud infrastructure provisioning and configuration. With the right tools and a solid understanding of the prerequisites, you'll be well-prepared to leverage the combined power of Terraform and Ansible in your cloud projects.\n\nIn the next sections of this guide, we'll delve into creating Azure resources using Terraform, configuring those resources using Ansible, and automating these processes through GitHub Actions. Stay tuned for the continuation of this guide.\n\n## Examples in the Repository\n\n### Nginx Linux Webserver with Azure VMs Behind Azure Load Balancer\n#### Terraform Configuration\n\nIf you're looking to provision a Linux web server with a load balancer in your Azure environment, we've provided a working example in the `terraform/linux-webserver-with-loadbalancer` directory of this repository. To get started, follow these steps:\n\n1. Navigate to the [terraform/linux-webserver-with-loadbalancer](./terraform/linux-webserver-with-loadbalancer) directory.\n2. Refer to the `Readme.md` file in that directory for detailed information on the Terraform configurations, step-by-step instructions, and best practices.\n3. Follow the instructions in the `Readme.md` file to deploy the Linux web server and load balancer using Terraform.\n\n#### Ansible Playbook for Configuring Web Servers\n\nOnce you've successfully provisioned the Linux web servers using Terraform, you can now configure them as web servers hosting a customizable static website. In the `ansible/` directory of this repository, you'll find the `set-up-ubuntu-nginx-webserver.yaml` playbook that automates the configuration process. Here's how to proceed:\n\n1. Navigate to the [ansible/](./ansible) directory.\n2. Locate the `set-up-ubuntu-nginx-webserver.yaml` playbook.\n3. Open the playbook to explore its contents and understand the configuration steps.\n4. Modify the playbook as needed to customize the static website you want to host.\n5. Execute the playbook using Ansible to apply the configuration to your provisioned web servers.\n\nPlease note that this example playbook demonstrates the power of using Ansible for configuration management. You can adapt and expand this playbook to suit your specific requirements and deploy more complex configurations.\n\n##### Conclusion\n\nBy exploring the examples provided in this repository, you can gain hands-on experience with combining Terraform and Ansible for Azure cloud infrastructure provisioning and configuration. These practical examples will help you better understand the concepts and workflows involved, enabling you to apply them effectively in your projects.\n\n\nIf you have any questions or need further assistance, feel free to reach out to me via contact section or create a `Issue` in this repository.\n\n#### Automation with GitHub Actions\n\nWe understand that local development is an essential part of the process, but once you've mastered your Terraform configurations and Ansible playbooks, it's time to take advantage of automation for seamless deployments. In this repository, we've provided GitHub Actions workflows in the `.github/workflows` directory that enable you to automate the entire process from provisioning to configuration.\n\n##### GitHub Actions Workflows\n\nIn the `.github/workflows` directory, you'll find predefined workflows that leverage GitHub Actions to automate the Terraform provisioning and Ansible configuration steps. These workflows ensure consistency, reliability, and efficiency throughout your deployment process.\n\nTo utilize these workflows:\n\n1. Navigate to the `.github/workflows` directory.\n2. Review the available [reusable workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows), such as [`ansible-set-up.yaml`](./github/workflows/ansible-set-up.yaml) and [`terraform-infra-set-up.yaml`](./.github/workflows/terraform-infra-set-up.yaml).\n3. Customize the workflows as needed to match your environment and preferences.\n4. GitHub Actions will trigger these workflows based on specific events, such as `pushes` and `pull request` to the repository.\n\nPlease note that these GitHub Actions workflows are designed to eliminate the need for manual intervention during deployments. This means that the steps you previously followed for local development are now automated through GitHub Actions.\n\n-  Infra provisioning can be understood using the below diagram where terraform configurations and `webservers-infra-terraform.yaml` github action are involved.\n```mermaid\ngraph TD\n    subgraph Developer\n    A[Write Terraform Code] --\u003e|Push to GitHub| B[GitHub Repository]\n    B --\u003e|GitHub Action| C[Terraform: Provision Infrastructure]\n    end\n\n    subgraph GitHub\n    B --\u003e C\n    end\n\n    subgraph Azure\n    C --\u003e D[Provisioned Infrastructure]\n    end\n\n    style A fill:#86c5da,stroke:#333,stroke-width:2px\n    style B fill:#f9c270,stroke:#333,stroke-width:2px\n    style C fill:#6bb46b,stroke:#333,stroke-width:2px\n    style D fill:#86c5da,stroke:#333,stroke-width:2px\n\n```\n-  Infra configuration can be understood using the below diagram where ansible configurations and `webservers-config-ansible.yaml` github action are involved.\n\n```mermaid\ngraph TD\n    subgraph Developer\n    A[Write Ansible Config] --\u003e|Push to GitHub| B[GitHub Repository]\n    B --\u003e|GitHub Action| C[Ansible: Configure VMs]\n    end\n\n    subgraph GitHub\n    B --\u003e C\n    end\n\n    subgraph Azure\n    D[Provisioned Infrastructure] --\u003e C\n    end\n\n    style A fill:#86c5da,stroke:#333,stroke-width:2px\n    style B fill:#f9c270,stroke:#333,stroke-width:2px\n    style C fill:#6bb46b,stroke:#333,stroke-width:2px\n    style D fill:#86c5da,stroke:#333,stroke-width:2px\n\n```\n##### Conclusion\n\nBy embracing GitHub Actions workflows available in the `.github/workflows` directory, you can streamline your deployment process, eliminate manual intervention, and ensure efficient provisioning and configuration of your Azure cloud infrastructure. This automation empowers you to focus on refining your Terraform configurations and Ansible playbooks while maintaining confidence in your deployments.\n\nIf you're new to GitHub Actions, refer to the [GitHub Actions Documentation](https://docs.github.com/en/actions) for comprehensive guides and best practices.\n\n### Local Development vs. Automation\n\nWhile the steps outlined earlier in this README were intended for local development and learning purposes, we highly recommend transitioning to using the GitHub Actions workflows for your production deployments. This automated approach enhances consistency, reduces human error, and increases the speed at which you can deploy and manage your Azure resources.\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have any suggestion that would make this project better, feel free to  fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\" with your suggestion.\n\n**⭐️Don't forget to give the project a star! Thanks again!⭐️**\n\nSee [`CONTRIBUTING`](/CONTRIBUTING.md) for more information.\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nReleased under [MIT](/LICENSE) by [@ishuar](https://github.com/ishuar).\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\n- 👯 [LinkedIn](https://linkedin.com/in/ishuar)\n\n\u003cp align=\"right\"\u003e\u003ca href=\"#top\"\u003eBack To Top ⬆️\u003c/a\u003e\u003c/p\u003e\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n\n[contributors-url]: https://github.com/ishuar/terraform-ansible/graphs/contributors\n[contributors-shield]: https://img.shields.io/github/contributors/ishuar/terraform-ansible?style=for-the-badge\n\n[forks-url]: https://github.com/ishuar/terraform-ansible/network/members\n[forks-shield]: https://img.shields.io/github/forks/ishuar/terraform-ansible?style=for-the-badge\n\n[stars-url]: https://github.com/ishuar/terraform-ansible/stargazers\n[stars-shield]: https://img.shields.io/github/stars/ishuar/terraform-ansible?style=for-the-badge\n\n[issues-url]: https://github.com/ishuar/terraform-ansible/issues\n[issues-shield]: https://img.shields.io/github/issues/ishuar/terraform-ansible?style=for-the-badge\n\n[license-url]: https://github.com/ishuar/terraform-ansible/blob/main/LICENSE\n[license-shield]: https://img.shields.io/github/license/ishuar/terraform-ansible?style=for-the-badge","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishuar%2Fterraform-ansible-azure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fishuar%2Fterraform-ansible-azure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishuar%2Fterraform-ansible-azure/lists"}