ARTH 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.( Note: No need to use when keyword here. )

Ansible Facts

Ansible facts are data related to your remote systems, including operating systems, IP addresses, attached filesystems, and more. You can access this data in the ansible_facts variable. By default, you can also access some Ansible facts as top-level variables with the ansible_ prefix.

Lets first check the connectivity:

No alt text provided for this image

To see all available facts, add this task to a play:

No alt text provided for this image

When we run this small playbook we get all the ansible facts info.... and from this we need to see in which OS our managed node is running and in the ("distribution": "RedHat"), we get the information and further in our ansible playbook we are going to this information

No alt text provided for this image

Now, we will use this approach to retrieve the OS name, and with the help of var_files, we are calling the respective OS name yml file which stores the name of the package as we can see below: and from which our software will be installed and run .

Note: The name of the file should be the same as OS-specific name otherwise it will not work!

No alt text provided for this image

And here is the playbook:

No alt text provided for this image

Now let’s run our playbook :

No alt text provided for this image

This will automatically fetch the vars file named RedHat. But how?, {{ ansible_facts[‘distribution’] }} will get replaced with Os name it will replace and since we saved our file with OS name it will replace.

Here, is the output of our webpage showing us the content below:

No alt text provided for this image

Comments

Popular posts from this blog

ARTH TASK 23 [📌 Automate Kubernetes Cluster Using Ansible 🔅 Launch ec2-instances on AWS Cloud eg. for master and slave. 🔅 Create roles that will configure master node and slave node seperately. 🔅 Launch a wordpress and mysql database connected to it in the respectine slaves. 🔅 Expose the wordpress pod and client able hit the wordpress ip with its respective port. ]

Arth Task6 "Create High Availability Architecture with AWS CLI" #awscloud #awscli #aws #vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeudcation #awsbylw #arthbylw

RH294 real used cases workshop #RedHat #vimaldaga #righteducation #educationredefine #rightmentor #linuxworld #makingindiafutureready #righeducation #arthbylw #ansiblebylw #ansible #expertsession #sreejith #arun #practicalimplementation #rh294