gantsign / ansible-role-java

Ansible role for installing Java from Adoptium

Home Page:https://galaxy.ansible.com/gantsign/java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installing two different JDKs in one run fails

JoepWeijers opened this issue · comments

I am using the following playbook to install two different JDKs. It installs the first one twice, instead of installing both.

Workaround 1: do an Ansible-playbook run, then swap the JDKs in the playbook and do another run, and both will be installed.
Workaround 2: ensure both java_version and java_release_name are set.

---
- hosts: servers
  roles:
    - role: gantsign.java
      java_version: '11.0.8+10'
      java_is_default_installation: no
      java_fact_group_name: java_11

    - role: gantsign.java
      java_version: '8.0.262+10'
      java_is_default_installation: yes
      java_fact_group_name: java_8

From the output it looks like java_release_name is not set the second time, because the step gets skipped:

...
TASK [gantsign.java : querying java version] ******************************************************************************************************************************
ok: [server] => {
    "java_release": "11.0.8+10"
}
...
TASK [gantsign.java : set release name var from API] **********************************************************************************************************************
ok: [server]
...
TASK [gantsign.java : java version to install] ****************************************************************************************************************************
ok: [server] => {
    "java_release_name": "jdk-11.0.8+10"
}
... Installs jdk-11.0.8+10 ...
TASK [gantsign.java : querying java version] ******************************************************************************************************************************
ok: [server] => {
    "java_release": "8.0.262+10"
}
...
TASK [gantsign.java : set release name var from API] **********************************************************************************************************************
skipping: [server]
...
TASK [gantsign.java : java version to install] ****************************************************************************************************************************
ok: [server] => {
    "java_release_name": "jdk-11.0.8+10"
}
... Installs jdk-11.0.8+10 again, instead of the 8.0.262+10 ...

That is due to java_release_name not being overwritten (i.e. the step is skipped) because the variable is still set from the first run: https://github.com/gantsign/ansible-role-java/blob/master/tasks/adoptopenjdk-query.yml#L15

@JoepWeijers thanks for reporting this issue, you can find the fix in version 9.0.1 of this role.