Vagrant provides easy to configure, reproducible, and portable virtual machines
And it uses various technologies like VirtualBox,VMware and AWS as providers.
1.Download the Vagrant package for windows
2.Run and Install the package
3.Navigate to Workspace and run the below command for Setting up
vagrant init
4.Check the output
"A
Vagrantfile
has been placed in this directory. You are now ready tovagrant up
your first virtual environment!"
5.Open the Vagrantfile and remove unnecessary contents
6.Configure the Vagrantfile for Ubuntu Base Image
Box: generic/ubuntu2004
Hostname: devbox
7.Customize the Virtual Box and VM resources
VirtualBox is a powerful virtualization product which has high performance and open source.
1.Download and Install the Oracle VirtualBox
2.Check and Enable Virtualization in Windows Bios
3.Run below command in workspace
vagrant up
4.Open VirtualBox and DevBox should be up and running
Terraform is a tool used to Build,Configure and Version up the Infrastructure efficiently. Terraform uses the configuration files to build and manage the Infrastructure
Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs. Ansible is Agent less and uses YAML syntax Ansible requires to be installed only in controller machine
1.Execute the provision.sh script with chmod 700 permission
sudo ./provision.sh
2.Check and confirm Terraform Installation
terraform --version
3.Check and confirm Ansible Installation
ansible --version
1.Navigate to terraform directory
cd terraform
2.Format the terraform config files
terraform fmt
3.Validate the terraform configurations
terraform validate
4.Check the Plan of resources to be created by config files
terraform plan
5.Apply the terraform config files
terraform apply
6.Approve the execution and resources will be created
1.Navigate to root directory where ansible.cfg exists
cd..
2.Execute the ansible-setup.sh script with chmod 700 permission
sudo ./ansible-setup.sh
3.Execute the ansible playbook
ansible-playbook ansible/site.yml -i ansible/inventory/ec2.py --private-key="YOURPEMFILEHERE"
4.Ansible will execute all the modules in the servers created by Terraform
InSpec 2 introduces the ability to test cloud resources for compliance in addition to the system and application-level resources
1.Automated Testing can be done using Inspec
2.For Installation,Execute the inspec-setup.sh script with chmod 700 permission
sudo ./inspec-setup.sh
3.Setup the AWS Profile by Environment Variables or Configuration File
Export as Environment Variables
export AWS_ACCESS_KEY_ID="YOURAWSACCESSKEYHERE"
export AWS_SECRET_ACCESS_KEY="YOURAWSSECRETKEYHERE"
export AWS_REGION="REGIONHERE"
export AWS_AVAILABILITY_ZONE="AVAILABILITYZONEHERE"
Credentials in Config File
~/.aws/config and ~/.aws/credentials file
4.Make sure aws setup and credentials are set
inspec detect -t aws://
5.For getting the infrastructure output from terraform,Execute tf-output.sh script with chmod 700 permission
sudo ./tf-output.sh
6.Once the outputs are copied to inspec file,run below command to start the testcase in controls directory
inspec exec test/devtest aws://
7.Testcase will be executed and results will be displayed
1.Get the Loadbalancer DNS
2.Launch It
3.Displays the "Hello World of Cloud" with other details
4.Redirects traffic equally to webserver instances since Round Robin type
5.When removing one web server,loadbalancer redirects all the traffic to the other
Like
-
Two Tier Web application architecture is implemented
-
Complete VPC setup is done with Multiple AZs for Web Application
-
Execution steps are automated using simple Shell Scripts
DisLike
- Need to reduce the time taken for automation
1.Tear down Terraform infrastructure
terraform destroy
2.Check whether all the resources are cleaned up in cloud
3.Tear Down the Vagrant to stop and continue after
vagrant suspend