Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud

Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud

๐—›๐—ฒ๐—น๐—น๐—ผ ๐—–๐—ผ๐—ป๐—ป๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป๐˜€ !!, curious to learn how we can Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud. An overview of Ansible and AWS Services will be present. How can we utilize Ansible Scripts with AWS for webserver deployment? We are utilizing or building Ansible Playbooks as a script to create this application, as well as installing the webserver on AWS. The first thing we need to know is what Ansible is and what Amazon Web Services is. At the end we will know about Automating of Deployment the web Application by Integration of Ansible with AWS Cloud.

What is Ansible?

Ansible is also a free and open-source tool for managing, deploying, and orchestrating IT configurations. Its goal is to boost productivity across a wide range of automation difficulties. This solution is easy to use while still being strong enough to automate complicated multi-tier IT application infrastructures

Ansible

What is Amazon Web Services?

Amazon Web Services (AWS) is the most complete and widely used cloud platform in the world, with more than 180ย fully featured services available from data centers all around the world. AWS is also use by millions of clients, including the fastest-growing startups, largest corporations, and top government agencies, to reduce costs, improve agility, and accelerate innovation.

AWS

Steps to achieve Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud.

1. With the helpย of ansible, create an AWS instance.
2. Get the public IP assigned to the newly launch instance.
3. Configure the web server in the launched instance using the received Public IP.

So Letโ€™s Start:
  1. To install boto library use the command โ€“>
pip3 install boto
Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud

2. To utilize Ansible to launch an instance on AWS, we use the Ansible ec2 module, which instructs Ansible to launch an EC2 instance on AWS. We need two sorts of keys for AWS login: a public access key and a secret access key. I utilize IAM users to establish security keys for the AWS accountโ€™s authentication.

Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud

3. Itโ€™s also usually a good idea to keep security credentials in separate files and utilize variables in the main script from a security standpoint. Ansible vault is use here to encrypt the security credential file in which we store our AWS security keys using variables.
Use the command to encrypt the file using Ansible vault->

  ansible-vault encrypt file_name

Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud

4. Ansible can also provision an ec2 instance on AWS cloud by utilizing the ansible.yml file, which contains security keys that are encrypt using vault for AWS cloud authentication.

Playbook

Ansible successfully built an ec2 instance, as shown in the AWS interface.

AWS

5. Now we must set up a web server on the newly created ec2 instance. To accomplish so, weโ€™ll need to connect in to the ec2 instance using SSH. All of this will be complete with Ansible, which requires the public IP of the ec2 instance as well as the SSH Private key to log in. Since then, ec2 Instance has become a controlled node for Ansible. Ansible also uses the Inventory file in the ansible.cfg file to reach the controlled node. However, in this , we will use the term add_host to dynamically add an EC2 instance to the Ansible host group.

Ansible Playbook


The add_host keyword is use to dynamically add hosts to ansible inventory files by forming a host group. The IP of ec2 has been dynamically obtain and set as host for the Ansibleย by utilizing these.

Playbook

The term with items offers the output in JSON format, while the keyword wait_for is use to waitย for the ec2 instance to start using port 22 for SSH login also.

6. The next step is also to log into the ec2 instance via SSH, which requires the SSH private key and the IP address of the instance. The private key file should be give with the ansible setup file.

[defaults]

host_key_checking = FALSE

private_key_file = /root/Ansible-tasks/key17.pem

Another thing to do is adjust the permissions of the key file, which are also limit by default under the root user. Ansible also may utilize the key file for login by altering the permissions using the following command.

chmod 400 key17.pem

7. Ansible will configure webserver on their managed node, ec2 Instance, using the private key file and the returned public IP.

Playbook

So also the Ansible tasks are complete successfully, we can check the output using the public IP of the ec2 instance to determine if the website is configure properly.

Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud

8. Finally We run the ansible playbook which done all the above tasks successfully by using following command .

ansible-playbook  --ask-vault-pass  playbook_file_name

also we saw in One click how the the entire set up complete by end to end automation .

Related Articles: Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud

Automating the Deployment of Web Application by Integrating Ansible with AWS Cloud
Spread the love

4 thoughts on โ€œAutomating the Deployment of Web Application by Integrating Ansible with AWS Cloudโ€

  1. Pingback: Limiting The Storage In Hadoop Cluster By Data Node ยป Coresumo

  2. Pingback: Deployment of Haproxy Load Balancer and Multiple Web Servers on AWS Cloud Using Ansible ยป Coresumo

  3. Pingback: Deployment of Web Application On Local Kubernetes Cluster by Integrating with AWS RDS using Terraform ยป Coresumo

Leave a Comment

Your email address will not be published. Required fields are marked *