Posts

Showing posts from January, 2024

Ansible is the Answer! | A Three-Part Series Demonstrating the Usefulness of Ansible to HumanGov

This is a three (3) part series that demonstrates how Ansible can be useful/leveraged for configuring your infrastructure. The background story here is that HumanGov is a multi-tenant cloud application that requires that each of the fifty (50) states has its own separate infrastructure. The HumanGov Infrastructure Engineers are trying to figure out how they can get it done, and they are considering using Ansible to help them deploy the application. Part 1 sets up the base infrastructure for the scenario. The HumanGov Infrastructure Engineers are accustomed to using Terraform to efficiently deploy infrastructure, but they are not very experienced with Ansible. Part 1 of 3: HumanGov: Ansible is the Answer! | Terraform | AWS Cloud9 | AWS IAM | AWS EC2 | AWS DynamoDB | AWS S3 Part 2 attempts to setup HumanGov via a MANUAL process. Part 2 goes through the steps to MANUALLY install Python, Nginx AND application files as well as MANUALLY configuring the firewall in Ubuntu. After g...

Part 3 of 3: HumanGov: Ansible is the Answer! | Ansible | Terraform | Python | Git | AWS CodeCommit | AWS Cloud9 | AWS IAM | AWS EC2 | AWS DynamoDB | AWS S3

Image
Background 1 of 29. Open AWS Cloud9 2 of 29. Modify modules/aws_humangov_infrastructure_main.tf Add local-exec provisioners to EC2 resource You will add three provisioners: One just updates the SSH keys in host file Another updates the inventory file with entries for the host information The final one deletes entries based on instance identifier being destroyed. provisioner "local-exec" { command = "sleep 30; ssh-keyscan ${self.private_ip} >> ~/.ssh/known_hosts" } provisioner "local-exec" { command = "echo ${var.state_name} id=${self.id} ansible_host=${self.private_ip} ansible_user=ubuntu us_state=${var.state_name} aws_region=${var.region} aws_s3_bucket=${aws_s3_bucket.state_s3.bucket} aws_dynamodb_table=${aws_dynamodb_table.state_dynamodb.name} >> /etc/ansible/hosts" } provisioner "local-exec" { command = "sed -i '/${self.id}/d' /etc/ansible/hosts" when...

Part 2 of 3: HumanGov: Ansible is the Answer! | Terraform | Python | Git | AWS Cloud9 | AWS EC2 | AWS DynamoDB | AWS S3

Image
1 of 23. Open Cloud9 2 of 23. Download the HumanGov application to the local Git Repository on AWS Cloud9 cd ~/environment/human-gov-application echo "*.zip" >> .gitignore mkdir src cd src wget https://tcb-bootcamps.s3.amazonaws.com/tcb5001-devopscloud-bootcamp/v2/module4-ansible/humangov-app.zip unzip humangov-app.zip 3 of 23. Push the application source to the local Git repository git status git add . git add ../.gitignore git commit -m "HumanGov app 1st commit" 4 of 23. Connect to the EC2 instance Change permissions on your key, or else you will get an error. aws ec2 describe-instances \ --query 'Reservations[*].Instances[*].{Instance:InstanceId,Name:Tags[?Key==`Name`]|[0].Value,PublicIP:PublicIpAddress,PrivateIP:PrivateIpAddress,State:State.Name}' \ --output table chmod 400 /home/ec2-user/environment/humangov-ec2-key.pem ssh -i /home/ec2-user/environment/humangov-ec2-key.pem ubuntu@172.31.18.172 ...