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