- name: Install Oracle JDK win_chocolatey: name: oraclejdk - name: Find Java version win_reg_stat: path: HKLM:\SOFTWARE\JavaSoft\JDK name: CurrentVersion register: reg - name: Find Java home win_reg_stat: path: "HKLM:\\SOFTWARE\\JavaSoft\\JDK\\{{ reg['value'] }}" name: JavaHome register: reg - name: Set JAVA_HOME win_environment: name: JAVA_HOME value: "{{ reg['raw_value'] }}" level: machine - name: Disable Java updates win_regedit: path: HKLM:\SOFTWARE\WOW6432Node\JavaSoft\Java Update\Policy name: EnableJavaUpdate type: dword data: 0