This repository contains an exercise which leverages Ansible and Terraform to provision infrastructure on AWS and deploy a simple webpage on EC2 instances.
- Getting Started
- Instructions
- Project Structure
- Files and Configuration Details
- Credits
- Acknowledgements
- See Also
-
Clone this repository to your local machine.
git clone https://github.com/MathoAvito/Ansible-Exercise.git
-
Ensure you have Ansible, Terraform, and AWS CLI installed.
sudo apt-get update && sudo apt-get install ansible terraform awscli -y
If not installed, you need to install them according to your OS specifications. Make sure you also have AWS CLI configured with your credentials.
Check out the instructions for this exercise.
The project has the following structure:
/
├── Ansible/
│ ├── ansible.cfg
│ ├── playbook.yml
│ └── Webfile/
│ └── index.html
└── Terraform/
├── main.tf
├── variables.tf
├── modules/
│ ├── compute/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ └── outputs.tf
│ └── network/
│ ├── main.tf
│ ├── variables.tf
│ └── outputs.tf
└── entrypoint.sh
The files within this project are set up as follows:
The Terraform files within the Terraform/
directory and its subdirectories are used to provision and configure AWS resources:
main.tf
: This is the main Terraform configuration file which references thenetwork
andcompute
modules.variables.tf
: This file holds the declarations for variables used within the Terraform configuration files.modules/network
: This module is used to provision network-related resources, such as a VPC, subnets, an internet gateway, and a security group.modules/compute
: This module is used to provision compute-related resources, namely AWS EC2 instances.entrypoint.sh
: This script installs the necessary dependencies for Ansible and sets up the Ansible control node.
The Ansible files within the Ansible/
directory are used to configure the EC2 instances:
ansible.cfg
: This is the main Ansible configuration file which sets Ansible defaults and other configurations.playbook.yml
: This Ansible playbook is used to deploy a simple webpage to the EC2 instances.
This project is maintained by MathoAvito.
This project is licensed under the MIT License. See the LICENSE file for details.