-
Terraform Module that does the following:
- 1 VPC
- 3 Subnets
- 1 Keypair
- 3 EC2 Instances - 2 Web and 1 DB
- 1 Elastic Load Balancer
-
Ansible Playbook that performs the following:
- Dynamically fetches your resources based on the tags you defined in the terraform IaC.
- Performs the Installation of the MySQL Database
- Creates the Database and Users and other Validations.
- Encrypts the passwords into a vault.
- Role that installs Apache HTTPD, PHP from third-party repositories (remi, epel)
- Configures the webserver
- Makes it ready for the Launch on the browser.
- Terraform is installed and the PATH is set.
Tip:
If not, download the setup using the instructions in the link below: https://www.terraform.io/intro/getting-started/install.html - AWS Secret variables are set:
Tip:
export AWS_ACCESS_KEY_ID='****' export AWS_SECRET_ACCESS_KEY='***' - Python 2.7+ and Ansible 2.x is installed
Tip: If you are on centos like platform, perform the below with sudo privs.
More info on: https://docs.ansible.com/ansible/devel/installation_guide/intro_installation.html
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm yum install ansible -y
-
Clone and switch the directory to the Repository.
-
Navigate to the folder: infra-on-aws-terraform:
cd infra-on-aws-terraform -
Initialize the working directory.:
terraform init -input=false -
Create a plan and save it to the local file tfplan:
terraform plan -out=tfplan -input=false -
Apply the plan stored in the file tfplan.
terraform apply -input=false tfplan -auto-approve -
Output the autogenerated keypair into a file for ansible.
terraform output pem > ..\ansible-playbook\mediawiki.pem -
Run Ansible Playbook for the DB Role:
cd ..\ansible-playbook
ansible-playbook site.yml -i ec2.py -vv --private-key mediawiki.pem -i ec2.py --limit "tag_group_db" --tags "install_db" --ask-vault-pass -u ec2-user
8. Run Ansible Playbook for the DB Role:
ansible-playbook site.yml -i ec2.py -vv --private-key mediawiki.pem -i ec2.py --limit "tag_group_web" --tags "install_web" --ask-vault-pass -u ec2-user
Note: tw is the vault key
- Open the Browser and complete the installation wizard.