Adoptopenjdk8jre 8.2.3.2 was installed with ansible (win_chocolatey) and we want to install a newer version 8.2.6.2 and do not want to reboot the server (this is on windows by the way).
During the installation the java_home is set to the new JAVA_HOME. When I look on the server I see the JAVA_HOME is changed.
Only ansible is still using the old JAVA_HOME. Is there a way to refresh the JAVA_HOME variable so ansible can use the new JAVA_HOME?
I tried this:
- name: test
win_shell: "[Environment]::GetEnvironmentVariable('JAVA_HOME')"
register: output
- debug:
msg: '{{ output }}'
- name: "get JAVA_HOME"
win_shell: "refreshenv;Get-Childitem -path env:JAVA_HOME"
register: JAVA_HOME
- debug:
msg: "{{ JAVA_HOME }}"
I a second run the java_home is set correct because ansible has reconnected