How can we write if else logic using shell or command… I can not use when clauseas it does not give me expected result
What is it that you are trying to do? It might be possible to do another way.
Sometimes I use two set_fact tasks with mutually exclusive when conditions.
As long as you remember that you don't need "{{ }}" on your when conditions and the conditions evaluate to a boolean, when conditions can be useful.
Jon
Hi,
Can you please once review my question -Ansible -Need to reset the value of variable before command.
I need assistance for that question, and i am trying different ways for it.
This is below question in which i need to reset the value of one of the variable -
Query: I need to fetch the latest java version from host servers and display the same on web page, using apache server which is installed on my local server(local server means server with ansible installed).
I am able to fetch the value, but need to reset the value of one of the variable to blank , below are the details.
I need to make it run time activity like —
when i have Both Hosts : zlp12036 and zlp12037, it must show the java version for both on my local server which has apache installed
when i have Only one Host i.e.zlp12036, it must show the java version for zlp12036 only on my local server which has apache installed.
Host File Details -
[myserver]
zlp12036 ansible_ssh_host=zlp12036.vci.att.com ansible_ssh_user=abc
#zlp12037 ansible_ssh_host=zlp12037.vci.att.com ansible_ssh_user=abc
Playbook: