0

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

  • Please do consider [editing your question](https://stackoverflow.com/posts/63450072/edit) to show what **is** happening along with what you'd **rather** happen. This concept is described in the [MCVE](https://stackoverflow.com/help/mcve) section of the [how to ask](https://stackoverflow.com/help/how-to-ask) page – mdaniel Aug 17 '20 at 21:00

0 Answers0