title: playbook need to check java version and if the java version below 1.8* version then playbook install java 1.8*
body: <p>i wrote the below code but not succeed to install java 1.8 version in target server. getting error while executing playbook</p>
  
  <pre><code>---
  - hosts: server
    name: Fetch Java version
    shell: java -version 2&gt;&amp;1 | grep version | awk '{print $3}' | sed 's/"//g'
    register: java_version
  - name: install java 1.8.* version
    yum: name={{item}} state=latest
    with_items:
      - java-1.8.0-openjdk.x86_64
    when: java_version != 1.8.*
  </code></pre>