Ansible role to upgrade JRE/JDK to latest version. Tasks in this role will do the following.
- Log information about existing versions of Java (jre/jdk) under C:\JavaPreviousVersions.txt
- Uninstall all existing versions of Java (jre/jdk) from the target machine
- Ugrade to the latest version of Java (jre/jdk)
- Upgrade will maintan bit versions which means if 32 bit version was previously present, the latest version being installed will also be 32bit and likewise for 64bit.
- The above default feature can be overridden by tags that have provided.
- Whichever component of Java (jre/jdk) was previously present on the machine will be upgraded.
- Cleanup packages that were copied to the target machine.
This role assumes that there is a central repository where the downloaded packages of the latest versions are present. Below is the folder structure:
\\your_repository_name\jdk\jdk8_181_64.exe
and \\your_repository_name\jdk\jdk8_181_32.exe
\\your_repository_name\jre\jre-8u181-windows-x64.msi
and \\your_repository_name\jre\jre-8u181-windows-i586.msi
Make sure to replace all occurences of "your_repository_name" with the server name or ip address of the windows share inside the tasks/main.yml
jdk/jre packages will be copied to target machines under the stage directory
---
stage: C:\temp
complete path of packages on the target machines after they have been copied
---
_64_jdk_package_path: C:\temp\jdk\jdk8_181_64.exe
_32_jdk_package_path: C:\temp\jdk\jdk8_181_32.exe
_64_jre_package_path: C:\temp\jre\jre-8u181-windows-x64.msi
_32_jre_package_path: C:\temp\jre\jre-8u181-windows-i586.msi
used for creates_path. This allows installation of packages without knowing the product_id
---
_64jdk: C:\Program Files\Java\jdk
_64jre: C:\Program Files\Java\jre
_32jdk: C:\Program Files (x86)\Java\jdk
_32jre: C:\Program Files (x86)\Java\jre
None
Uninstall all versions of Java and upgrade those versions to the latest
---
- hosts: servers
roles:
- role: rishihegde.windows_java
Use tags to only install specific versions or only uninstall
---
- hosts: servers
roles:
- { role: rishihegde.windows_java, tags: ['uninstall'] }
---
- hosts: servers
roles:
- { role: rishihegde.windows_java, tags: ['uninstall','64_jdk'] }
Available tags
- uninstall - only uninstalls all versions of jre/jdk that currently exists on the target machine
- jdk_both - only installs 64bit and 32bit version of JDK
- 64_jdk - only installs 64bit JDK
- 32_jdk - only installs 32bit JDK
- 64_jre - only installs 64bit JRE
- 32_jre - only installs 32bit JRE
BSD
Rishi Hegde rishihegde810@gmail.com