Tried below one. However, when condition is not correctly evaluating.

Even following condition true its executing other commands mentioned in
other when condition.
current_image_state <= desire_image_state


  tasks:
   - name: Get the state of the Test version
     shell: alert1=`cat /tmp/test.log |  grep -e "pending" -e "failed" | wc
-l`;
     register: image_state
     tags: image

   - name: Set the output of the Test state
     set_fact: current_image_state=image_state.stdout
     tags: Test1

   - name: Define our static value for the desired Test state
     set_fact: desire_image_state=0
     tags: Test2

   - name: Perform TASK1
     command: sh /tmp/test.sh
     when: current_image_state > desire_image_state
     tags: final

   - name: Message if couldnot able to perform TASK1
     debug: msg="Need to check the status of Pending image"
     when: current_image_state <= desire_image_state
     tags: message



On Thu, Feb 2, 2017 at 1:16 AM, Rodrigo B Brasil <[email protected]>
wrote:

> This should help:
>
> http://docs.ansible.com/ansible/playbooks_variables.html
> http://docs.ansible.com/ansible/set_fact_module.html
>
>
>
> []s,
> Rodrigo B Brasil
>
> On Wed, Feb 1, 2017 at 4:16 PM, DHAVAL JAISWAL <[email protected]> wrote:
>
>> Where i can set this variable so that i can compare it in where
>> condition.
>>
>> Any small test scenario will help me to understand.
>>
>> On Mon, Jan 30, 2017 at 11:53 PM, Brian Coca <[email protected]> wrote:
>>
>>> These are not valid variables for Ansible (not since 1.6).  Also,
>>> setting them in a shell will not make them available.
>>>
>>>   when: $numami > $num
>>>
>>>
>>> ----------
>>> Brian Coca
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Ansible Project" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/ansible-project/yNAVY48KdJ8/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/ansible-project/CACVha7fsDKmiP8DdnS6oqgbc3vp65gYXc-GFZmt
>>> iYFHmgWs8gw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/ansible-project/CACVha7fsDKmiP8DdnS6oqgbc3vp65gYXc-GFZmtiYFHmgWs8gw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Thanks & Regards
>> Dhaval Jaiswal
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/ansible-project/CAH5ShBjg31HeP--wRWzYEJGJVZ5TBGv2QRjnRNW
>> b5K8yBUxmxg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CAH5ShBjg31HeP--wRWzYEJGJVZ5TBGv2QRjnRNWb5K8yBUxmxg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/yNAVY48KdJ8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/CACTtCsFx5jw-jatc3%3DPGoznOJWxv_
> b30FxfCiViADCrGNFvKQQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CACTtCsFx5jw-jatc3%3DPGoznOJWxv_b30FxfCiViADCrGNFvKQQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Thanks & Regards
Dhaval Jaiswal

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAH5ShBhGd3ryP__gsiwQFD%2B-cU19Um8WgH6%3D7heb7uNeFwTSZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to