Creating an Ansible Playbook which will dynamically load a variable file named same as OS_Name(14.3)
In this blog, I am going to create an Ansible Playbook which will dynamically load a variable file named the same as OS_Name.
For creating the same playbook you need to follow the steps that are given below:-
STEP-1: Create a folder of any name in my case folder name is webserver
STEP-2: Create a file of any name in the webserver folder
STEP-3: Creating an Ansible host file from any location
STEP-4: Configure your ansible configuration file that is /etc/ansible.cfg
NOTE- Give Location of your Ansible host file:
STEP-5: Content in /etc/ansible/hosts file
STEP-6: Content in file os.yml
STEP-7: Create two more in folder webserver
Creating RedHat.yml file
Creating Ubuntu.yml
NOTE- Both the name of the file are the same as those I gave above
STEP-8: Content of file RedHat.yml
Content in file RedHat.yml
STEP-9: Content in file Ubuntu.yml
Content in file Ubuntu.yml
STEP-10: Use Redhat and Ubuntu OS
This is my Redhat OS that is running in my local VM
Redhat VM
This is my Ubuntu OS that is running on AWS Cloud
STEP-11: Run the ansible-playbook(os.yml) by using the command “ansible-playbook os.yml”
STEP-12: Use Ubuntu Instance Public IP in the browser
Webserver Configure successfully. This shows Webserver in Ubuntu OS is Ready!!✅
STEP-13: Use RedHat VM IP in the browser
Webserver Configure Successfully. This shows Webserver in RedHat VM is Ready!!✅
Thanks for Reading!!