Dynamic Configuration of Target nodes using variable files named same as OS using Ansible
๐ง๐ฎ๐๐ธ ๐๐ฒ๐๐ฐ๐ฟ๐ถ๐ฝ๐๐ถ๐ผ๐ป :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.
Here, weโll be using two target nodes. First one will be Redhat linux and second one will be Ubuntu.
We will set up the ansible over AWS using EC2 instance
Letโs jump into the task
Step 1:
Launch the two instances on AWS :
Step 2:
Configure the host file :
Step 3:
Configuring ansible.cfg file :
Letโs create the yml files for ansible
Step 1:
Create the variable file: RedHat.yml
Step 2:
Create the another variable file: Ubuntu.yml
Step 3:
Now create the playbook to configure the webserver
Finally, configure the index.html file
Now, lets run the playbook:
First letโs check the hosts
We ping to the hosts inorder to check the connectivity between the controller node and target node.
Now run the playbook to configure the webserver