Task-14.3

Task-14.3

 ???????? ?????????????????????? :

Create an Ansible Playbook which will dynamically load the variable file named same as OS_name and just by using the variable names we can Configure our Target Node.

No alt text provided for this image

In This task we have to create a dynamic var files , with name of remote system which we will used in the playbook.

In this task I am going to used AWS instances 1. RedHat-8 , 2. Ubuntu-20 you can use your local system also. But the challenge is how ansible SSH them , for that we need to configure our host file and ansible.cfg inventory .

In host file we need to add AWS key , which have been used at the time of instance launching , and also we required the user name of OS. Give user name according to their distribution.

So Let’s start the practical :

1 . Launch the two instances on AWS :

No alt text provided for this image

2.Configure the host file :

No alt text provided for this image

Here we need to give the user name according to the distribution and also need same aws key pair which have been used at the time of OS launching. Give your key name in .pem format.

3.Configuring ansible.cfg file :

No alt text provided for this image

Here we need to configure inventory file to ssh the instances.

In a playbook, we may want to execute different tasks, or have different goals, depending on the value of a fact (data about the remote system), a variable, or the result of a previous task. We may want the value of some variables to depend on the value of other variables. Or we may want to create additional groups of hosts based on whether the hosts match other criteria. We can do all of these things with conditionals.

Ansible uses Jinja2 tests and filters in conditionals. Ansible supports all the standard tests and filters, and adds some unique ones as well.

Now I am going to create a var file according to the OS name of distribution.

  1. Create the variable file with the RedHat.yml name
No alt text provided for this image

2. Create the another variable file with the Ubuntu.yml name

No alt text provided for this image

Now create the playbook to configure the webserver

No alt text provided for this image

After that we have to write create the index.html file which we are going to copy to the root document

No alt text provided for this image

Now lets check the list of the hosts

No alt text provided for this image

Here you can see that , lists of remote nodes .

Now I am going to ping all of them . To check the connectivity between the controller node and target node.

No alt text provided for this image

Here you can see we are successfully able to ping with all the target node

Now run the playbook to configure the webserver.

No alt text provided for this image

Here we can see that , playbook run successfully without any error.

Now go to the web-browser and check weather the web pages are copied or not ?

No alt text provided for this image
No alt text provided for this image

Here you can see the webpages are copied successfully.

Thanks!!


要查看或添加评论,请登录

Akanksha Bhatt的更多文章

  • Task-8 Automation with Python

    Task-8 Automation with Python

    ARTH - Task 8 ??????? Task Description?? ?? Create a Menu Using Python integrating all the concepts that have been…

  • Task-14.2

    Task-14.2

    Ansible playbook that will retrieve new Container IP and dynamically update the inventory and Configure web-server…

  • Task-14.1

    Task-14.1

    Task description :- 14.1 Create a network Topology Setup in such a way so that System A can ping to two Systems System…

  • LOAD BALANCING WITH HAPROXY

    LOAD BALANCING WITH HAPROXY

    Task Description 12.1 Use Ansible playbook to Configure Reverse Proxy i.

    1 条评论
  • ARTH TASK-15

    ARTH TASK-15

    Task Description?? Create an ansible role myapache to configure Httpd WebServer. Create another ansible role…

    1 条评论
  • Neural Networks in Netflix

    Neural Networks in Netflix

    What are Neural Networks? Neural networks are a set of algorithms, they are designed to mimic the human brain, that is…

  • Restarting HTTPD Service is not idempotent in nature and also consume more resources suggest a way to rectify this challenge in Ansible Playbook.

    Restarting HTTPD Service is not idempotent in nature and also consume more resources suggest a way to rectify this challenge in Ansible Playbook.

    What is Idempotent nature in Ansible? An operation is idempotent if the result of performing it once is exactly the…

  • CONFIGURING HADOOP CLUSTER USING ANSIBLE

    CONFIGURING HADOOP CLUSTER USING ANSIBLE

    Welcome you all, in this blog I will cover how we can“ CONFIGURE HADOOP CLUSTER USING ANSIBLE” Before starting the…

    1 条评论
  • How Industries are Solving Challenges Using Ansible??

    How Industries are Solving Challenges Using Ansible??

    What Is Ansible ? ?? Ansible is a software tool that provides simple but powerful automation for cross-platform…

  • Configuration of Apache Web Server in Docker Container using Ansible

    Configuration of Apache Web Server in Docker Container using Ansible

    In this article we will perform various tasks: Configure Docker Start and enable Docker Services Pull the httpd server…

    1 条评论

社区洞察

其他会员也浏览了