Skip to content

Configure Ansible server on VM 1 to deploy a webserver to VM2 and VM3 on port 8080 that displays the message: “Hello World from SJSU”

Notifications You must be signed in to change notification settings

archana-kamath/ansible-akatsuki

Repository files navigation

ansible-akatsuki

Problem Statement: • Configure Ansible server on VM 1 to deploy a webserver to VM2 and VM3 on port 8080 that displays the message: “Hello World from SJSU” • Un-deploy all webserver resources Team AKATSUKI:

• Archana Miyar Kamath • Simran Tanvir Memon • Mounica Kamireddy • Limeka Dabre

Implementation: • An AWS EC2 instance was created and Ansible was installed on this server (VM1) • Using Ansible server(VM1) playbook, deployed webservers(nginx) on VM2 and VM3

Step1: • Create an EC2 instance and download the secret key (new_ansible.pem). • Open the terminal and connect to this instance using ssh -i "new_ansible.pem" ubuntu@ec2-54-186-95-252.us-west-2.compute.amazonaws.com

alt text

• Install ansible on this server using the command: sudo apt install ansible and you can check the ansible version using ansible –version

alt text

Step 2: • Like VM1, create two other EC2 instances – VM2 and VM3 • Set the inventory by updating hosts file under /etc/ansible/hosts using command: sudo nano /etc/ansible/hosts in the following format: [ansible_clients] client_1 ansible_host=35.164.161.246 client_2 ansible_host=34.217.4.182 • Check the updated inventory using command: ansible-inventory --list -y

alt text

Step 3: • Make sure that the webservers VM2 and VM3 are reachable by pinging from server VM1 using command: ansible all -m ping --private-key new_ansible.pem

alt text

Step 4: • Install nginx on VM2 and VM3 through playbook(final_webservice.yml) with change of port to 8080 and required message as follows:

alt text

Step 5: Below is the code to change the port to 8080

alt text

Step 6: • Source (src) index.html file in playbook is as follows:

alt text

Step 7: • Run the playbook on VM1 server using: ansible-playbook final_webservice.yml --private-key new_ansible.pem -b

alt text

• Check the status of the webserver deployed using command: sudo service nginx status

alt text

• Simultaneously, check if the desired message from the updated index.html exists on VM2 at http port 8080

alt text

Step 8: • Similarly, check the nginx status for VM3 and corresponding webpage.

alt text

alt text

Step 9: The following playbook (stop_nginx.yml) helps in un-deploying the webserver:

alt text

alt text

• Make sure that the webserver got un-deployed successfully using command: sudo service nginx status

alt text

• Simultaneously check the http port 8080 on webpage.

alt text

Step 10: • Similarly, check the nginx status for VM3 and corresponding webpage.

alt text

alt text

About

Configure Ansible server on VM 1 to deploy a webserver to VM2 and VM3 on port 8080 that displays the message: “Hello World from SJSU”

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages