I’m installing a specific version of java binar that is been executed every time I run the playbook, I’m trying to include a check to repeat the installation steps only if java is not installed :
playbook :
name: register if java is installed
shell: rpm -qa | grep jdk
register: java_version
name: downloading java binary from s3
shell: /usr/bin/s3cmd get s3://my-bucket/packages/jdk-$JDK_VERSION-linux-x64-rpm.bin --force
when_string: $java_version != ‘jdk-1.6.0_26-fcs.x86_64’
tags:
The above is not working as it will always run anyway and I’m not able to see what is the value of java_version registered when running in verbose mode… can you please advise ?
This is fine. Since you don’t have jdk installed, your “rpm -qa | grep jdk” returns status code 1 (because that command did not return any output). You can check it by executing “rpm -qa | grep jdk; echo $?” in your console.
Use ignore_errors = True in your task where you check jdk version and you should be fine