Invest in Brazilian Real Estate

ReitBZ is the first security token backed by Brazilian real estate, powered by BTG Pactual, the largest investment bank in Latin America. Token holders will be able to participate in Brazil’s…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Setting up Apache Web Server on AWS EC2 Instance Using Ansible

Ansible is an open source automation and orchestration tool for software provisioning, configuration management, and software deployment.

Ansible can easily run and configure Unix-like systems as well as Windows systems to provide infrastructure as code. It contains its own declarative programming language for system configuration and management.

This task is a little bit tricky and there are few things we need to know beforehand to perform this task. Let’s see those pre-requirements…

Launch two EC2 ubuntu machines

And Configure Security Group of the machines by adding inbound rules shown below

To begin using Ansible as a means of managing your server infrastructure, you need to install the Ansible software on the machine that will serve as the Ansible control node.

Following this update, you can install the Ansible software with:

The inventory file contains information about the hosts you’ll manage with Ansible. You can include anywhere from one to several hundred servers in your inventory file, and hosts can be organized into groups and subgroups.

To edit the contents of your default Ansible inventory, open the /etc/ansible/hosts file using your text editor of choice, on your Ansible Control Node:

The default inventory file looks like above.

Now we can Add our host ip and save it.

Now we added our hosts

where 3.86.209.10 is our remote machine ip

When you’re finished, save and close the file.

if you want to check your inventory, you can run:

You can use the option — list-hosts. It will show all the host IPs from your inventory file. You can use the below-given command.

After setting up the inventory file to include your servers, it’s time to check if Ansible is able to connect to these servers and run commands

Generate a new SSH-key

Now we have to add this public key to all the remote hosts.

Copy the public key and add to the Remote machines

Now login to your remote machine and Add the public key there

From Your Ansible control node, run:

You should get output similar to this:

The ping module will test:

Create a yaml playbook file named sample.yml

And then add your playbook yaml content to deploy the apache webserver

You can verify your yaml syntax is correct or not using the command

if the syntax is correct , it will return your yaml file name.

otherwise error message will come.

Now we can run our playbook since, there is no syntax errors

The command to run the playbook is

The playbook is executed successfully.

Now we can check our remote machine, whether apache2 installed or not.

apache2 is successfully installed in our remote machine.

Now we can go to the web browser and access the host or IP address of the remote machine.

yaas……The welcome message is displayed there !!!

Add a comment

Related posts:

How to improve your writing on treatments

Writing treatments is an essential part of tv development. Ideas are easy — generated by the hundreds in conversation, like infantry soldiers they pop their heads over the ramparts to be shot down by…

The Impact of Conversational AI On B2B Sales

There are different forms of AI used by both B2C and B2B companies in order to boost sales and engage customers, yet one form of AI sticks out to be one of the best for both initiating and closing…