Okay thanks, maybe I got some problem with the semantics:

  failed_when:
    - "'already installed' not in command_result.stderr"
    - "command_result.rc == 1"
>> Does not fail if either of the conditions is false ( so it does not fail 
if result.rc == 1 and 'already installed' is in stderr) which in this case 
is the desired behaviour.
If one reads this task one could think that any of the list is a fail 
condition (so if one condition is true, everything fails), so this is not a 
real 'OR'?
Maybe there should be a module with 'passed when:' ?

Thanks

Am Montag, 17. November 2014 22:11:23 UTC+1 schrieb Michael DeHaan:
>
> Multiple checks looks like:
>
> failed_when: color == 'blue' or number == 5
>
> Note that if you are telling when not to fail, you will need to negate 
> your condition.
>
> Ansible denotes lists of conditions as "ORs" so:
>
> failed_when:
>    - color == 'blue'
>    - number == 5
>
> Is equivalent syntax.
>
>
>
> On Thu, Nov 13, 2014 at 8:18 AM, ProfHase <[email protected] 
> <javascript:>> wrote:
>
>> Hi,
>> when trying to install keys to a java keystore I am using the following 
>> task:
>>
>> - name: java install ssl certs
>>   shell:
>>     source /etc/profile.d/java.sh;
>>     cd $JAVA_HOME/jre/lib/security;
>>     $JAVA_HOME/bin/keytool -import -noprompt -keystore cacerts -alias {{ 
>> item }} -file /tmp/{{ item }}.crt -storepass storepass
>>   register: command_result
>>   changed_when: "'already exists' not in command_result.stdout"
>>   failed_when: "'already exists' not in command_result.stdout"
>>
>>
>> If the key has already been added, keytool returns '1' and writes 
>> '...already exists' to stdout.
>> I would like the task not to fail either:
>> - if the key has been added
>> or 
>> the key already exists.
>>
>> I tried the condition
>> failed_when: "'already exists' not in command_result.stdout and 
>> command_result.rc != 0"
>>
>>
>>
>> But that one does not work (error while evaluating conditional).
>>
>> Any ideas how to achieve this task?
>> Thanks a lot
>>
>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/b537bc57-b9a4-4543-8cf7-40981a0faa9a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/b537bc57-b9a4-4543-8cf7-40981a0faa9a%40googlegroups.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 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/d453f861-140d-4673-89e7-e76ea52c829f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to