I've run into subtle and hard-to-spot logic bugs (Ansible and elsewhere)
that were 'correct' but magically solved when rewritten.  I agree that your
syntax looks spot on, but breaking it out into multiple statements might
make it easier to troubleshoot later on too.

Glad it worked!

On Sun, May 27, 2018 at 12:24 PM, Pranay Nanda <pranaynanda...@gmail.com>
wrote:

> You're a hero! Splitting does the job. I still wonder why previous logic
> did not work.
>
> On Sunday, 27 May 2018 21:21:15 UTC+5:30, Pranay Nanda wrote:
>>
>> I want to run few tasks in shell if they satisfy a condition. Strangely
>> the task runs if the second condition is satisfied even though the first
>> one fails.
>>
>>   name: ods
>>   shell: "/something {{state}}"
>>   when: ((ods) and (not (ansible_hostname | search("demlh*"))))
>>   register: sss_ods_out
>>   notify: output ods
>>   ignore_errors: yes
>>
>> Here sss_ods is a variable defined in a vars file. If I remove the latter
>> condition the task would run but I want both the conditions to be satisfied
>> for the task to run and I can't understand where am I going wrong.
>>
> --
> 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/s3I_l8M-7SU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/801d7920-39c0-40a1-a173-2c4cabf7db34%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/801d7920-39c0-40a1-a173-2c4cabf7db34%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
***************** ************* *********** ******* ***** *** **
"If you wish to make an apple pie from scratch,
  you must first invent the universe."
  -- Carl Sagan

"Quis custodiet ipsos custodes?"
    (Who can watch the watchmen?)
    -- from the Satires of Juvenal

"I do not fear computers, I fear the lack of them."
    -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGYusaOjFsWTbkniu7HmeMu%3DQ0VwfH7Ws-BCzPfNy1M%3DTdf5%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to