dhamith93 / terraform_ansible_example

Example of creating infrastructure in AWS with Terraform and setting up LAMP stack through Ansible

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example of creating infrastructure in AWS with Terraform and setting up LAMP stack through Ansible

Terraform creates the infastructure and generates the inventory file to be used with Ansible.

Usage

cd terraform
terraform init
terraform plan
terraform apply

cd ../ansible
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook base.yml -i ../terraform/inventory

Design

  • DB server
    • 10.0.1.100
    • CentOS 7
    • MariaDB
  • UAT
    • 10.0.1.101
    • CentOS 7
    • Apache, PHP 7.4, RabbitMQ
  • PROD
    • 10.0.1.102
    • CentOS 7
    • Apache, PHP 7.4, RabbitMQ
  • DEMO
    • 10.0.1.103
    • CentOS 7
    • Apache, PHP 7.4, MariaDB RabbitMQ

Example of inventory file generated by Terraform

[db_server]
3.236.167.103 ansible_user=centos ansible_ssh_private_key_file=/Users/dhamith93/Desktop/dhamith93-us-east-new.cer

[uat_server]
3.236.181.81 ansible_user=centos ansible_ssh_private_key_file=/Users/dhamith93/Desktop/dhamith93-us-east-new.cer

[prod_server]
3.91.14.189 ansible_user=centos ansible_ssh_private_key_file=/Users/dhamith93/Desktop/dhamith93-us-east-new.cer

[demo_server]
52.3.224.219 ansible_user=centos ansible_ssh_private_key_file=/Users/dhamith93/Desktop/dhamith93-us-east-new.cer
44.195.37.79 ansible_user=centos ansible_ssh_private_key_file=/Users/dhamith93/Desktop/dhamith93-us-east-new.cer

About

Example of creating infrastructure in AWS with Terraform and setting up LAMP stack through Ansible


Languages

Language:HCL 100.0%