geerlingguy / ansible-role-java

Ansible Role - Java

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ubuntu 17.04

bkblain opened this issue · comments

Role failed to execute on Ubuntu 17.04 because the Ubuntu-17.04.yml file does not exist in vars/.

TASK [geerlingguy.java : Include version-specific variables for Ubuntu.] *******
fatal: [localhost]: FAILED! => {"ansible_facts": {}, "changed": false, "failed": true, "message": "Unable to find 'Ubuntu-17.04.yml' in expected paths."}

I don't see why the Ubuntu variables have to have the version in the file name when the other distros don't.

Because Ubuntu 12/14 only have JDK 7 in their default repos (https://github.com/geerlingguy/ansible-role-java/blob/master/vars/Ubuntu-14.04.yml#L7), while Ubuntu 16+ has JDK 8 (https://github.com/geerlingguy/ansible-role-java/blob/master/vars/Ubuntu-16.04.yml). I don't usually add official support for non-LTS releases to my roles, but if you can find a better/easier way to support the rule that Ubuntu >= 16.04 uses JDK 8, and Ubuntu <= 14.04 uses JDK 7, then I may be willing to commit it (as long as it passes tests and doesn't add in a bunch of extra tasks).

@bblain7 you could have a look at #31
where I did such logic (but was not accepted), for an even more slightly more advanced case to automatically add a required ppa repos (if an older distro like Ub. 14.04, does not have JDK 8 out-of-the-box)

I'm pretty sure I had this same issue with RedHat 7 a while back. I don't recall the satellite having Java 7. I'm not sure if you think this is too complicated but the role could use the {{ansible_distribution_major_version}} variable. My thought is that the vars directory would have Java version directories vars/7,/8,/9 with each OS file. Some example code for maybe a tasks/setup-Ubuntu.yml

- name: "Determine Java 7 available"
  include_vars: "7/{{ ansible_distribution }}.yml"
  when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version <= '16'

- name: "Determine Java 8 available"
  include_vars: "8/{{ ansible_distribution }}.yml"
  when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version >= '17'

Note that in the fix for #61, I explicitly defined the list of supported Ubuntu versions, and have decided to only maintain support for the LTS releases (I've never trusted any non-LTS release for my infra work :).