This project leverages Terraform and Ansible to automate the deployment of infrastructure and application setup. We will deploy a sample Django application that requires a PostgreSQL database.
- VPC with public and private subnets
- Three EC2 instances:
- Two in the public subnet for the application
- One in the private subnet for the database
- Load Balancer to distribute traffic between application instances
- Terraform should generate an inventory file for Ansible
-
Infrastructure Role
- Install PostgreSQL on the database instance
- Create a user and database
- Install necessary software and Nginx on application instances to route traffic to the Django application
-
Deployment Role
- Update code from GitHub
- Refresh configuration files with current database credentials
- Execute database migrations
We will deploy the following sample Django application: Sample Django Application
- Clone the repository:
git clone https://github.com/BlessedXd/terraform_ansible_project
- Navigate to the project directory:
cd terraform_ansible_project
- Initialize Terraform:
terraform init
- Apply the Terraform configuration:
terraform apply
- Configure Ansible: Adjust inventory and configuration files as needed.
- Run the Ansible playbook:
ansible-playbook -i inventory deploy.yml
This project is licensed under the MIT License.
Contributions are welcome! Please open an issue or submit a pull request.
For questions or feedback, please reach out at [email protected]
Feel free to customize any part of the README to better fit your style or project specifics!