From fbd97a5f08829dd5688ec20277e5b1febc066475 Mon Sep 17 00:00:00 2001 From: Victor LABORIE Date: Fri, 23 Mar 2018 11:47:13 +0100 Subject: [PATCH] java: support for Oracle JRE --- CHANGELOG.md | 2 ++ elasticsearch/meta/main.yml | 2 +- {java8 => java}/.kitchen.yml | 0 java/README.md | 14 ++++++++ java/defaults/main.yml | 4 +++ {java8 => java}/meta/main.yml | 3 +- java/tasks/main.yml | 10 ++++++ java/tasks/openjdk.yml | 31 ++++++++++++++++++ java/tasks/oracle.yml | 58 ++++++++++++++++++++++++++++++++++ {java8 => java}/tests/test.yml | 2 +- java8 | 1 + java8/README.md | 11 ------- java8/defaults/main.yml | 2 -- java8/tasks/main.yml | 27 ---------------- jenkins/meta/main.yml | 2 +- logstash/meta/main.yml | 2 +- 16 files changed, 126 insertions(+), 45 deletions(-) rename {java8 => java}/.kitchen.yml (100%) create mode 100644 java/README.md create mode 100644 java/defaults/main.yml rename {java8 => java}/meta/main.yml (81%) create mode 100644 java/tasks/main.yml create mode 100644 java/tasks/openjdk.yml create mode 100644 java/tasks/oracle.yml rename {java8 => java}/tests/test.yml (66%) create mode 120000 java8 delete mode 100644 java8/README.md delete mode 100644 java8/defaults/main.yml delete mode 100644 java8/tasks/main.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 06b92743..2364de7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The **patch** part changes incrementally at each release. * elasticsearch: add http.publish_host variable * kibana: log messages go to /var/log/kibana/kibana.log * mysql: add an option to install the client development libraries (default: `False`) +* java: support for Oracle JRE ### Changed * evolinux-users: add sudo permission for bkctld check @@ -23,6 +24,7 @@ The **patch** part changes incrementally at each release. * rbenv: change default Ruby version (2.5.1) * rbenv: switch from copy to lineinfile for default gems * squid: add a few news sites to the whitelist +* java8: renamed to java (java8 symlinked to java for backward compatibility) ### Fixed diff --git a/elasticsearch/meta/main.yml b/elasticsearch/meta/main.yml index 54156392..cfc69425 100644 --- a/elasticsearch/meta/main.yml +++ b/elasticsearch/meta/main.yml @@ -25,4 +25,4 @@ galaxy_info: # alphanumeric characters. Maximum 20 tags per role. dependencies: - - java8 + - { role: java, alternative: 'openjdk', java_version: 8 } diff --git a/java8/.kitchen.yml b/java/.kitchen.yml similarity index 100% rename from java8/.kitchen.yml rename to java/.kitchen.yml diff --git a/java/README.md b/java/README.md new file mode 100644 index 00000000..72740bb3 --- /dev/null +++ b/java/README.md @@ -0,0 +1,14 @@ +# java + +Install OpenJDK or OracleJDK + +## Tasks + +* `openjdk.yml` : install of OpenJDK +* `oracle.yml` : install or OracleJDK + +## Available variables + +* `java_alternative`: choose between openjdk or oraclejdk (default to openjdk) +* `java_version`: java version (default to 8) +* `java_default_alternative`: make this verison the default alternative (default to true) diff --git a/java/defaults/main.yml b/java/defaults/main.yml new file mode 100644 index 00000000..89f5cdac --- /dev/null +++ b/java/defaults/main.yml @@ -0,0 +1,4 @@ +--- +java_alternative: 'openjdk' +java_version: 8 +java_default_alternative: True diff --git a/java8/meta/main.yml b/java/meta/main.yml similarity index 81% rename from java8/meta/main.yml rename to java/meta/main.yml index 632cd4f4..c5b91643 100644 --- a/java8/meta/main.yml +++ b/java/meta/main.yml @@ -1,7 +1,7 @@ --- galaxy_info: author: Evolix - description: Installation of Java 8 + description: Installation of Java issue_tracker_url: https://forge.evolix.org/projects/ansible-roles/issues @@ -13,3 +13,4 @@ galaxy_info: - name: Debian versions: - jessie + - stretch diff --git a/java/tasks/main.yml b/java/tasks/main.yml new file mode 100644 index 00000000..1249533e --- /dev/null +++ b/java/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- fail: + msg: "This role support only java 8 for now !" + when: java_version != 8 + +- include: openjdk.yml + when: "{{ java_alternative == 'openjdk' }}" + +- include: oracle.yml + when: "{{ java_alternative == 'oracle' }}" diff --git a/java/tasks/openjdk.yml b/java/tasks/openjdk.yml new file mode 100644 index 00000000..9b4f0b7d --- /dev/null +++ b/java/tasks/openjdk.yml @@ -0,0 +1,31 @@ +--- +- name: Decide which Debian release to use + set_fact: + java_apt_release: '{% if ansible_distribution_release == "jessie" %}jessie-backports{% else %}{{ ansible_distribution_release }}{% endif %}' + tags: + - java + +- name: Install jessie-backports + include_role: + name: apt + tasks_from: backports.yml + when: ansible_distribution_release == "jessie" + tags: + - java + +- name: Install openjdk package + apt: + name: "openjdk-{{ java_version}}-jre-headless" + default_release: "{{ java_apt_release }}" + state: present + tags: + - java + - packages + +- name: This openjdk version is the default alternative + alternatives: + name: java + path: "/usr/lib/jvm/java-{{ java_version }}-openjdk-amd64/jre/bin/java" + when: java_default_alternative + tags: + - java diff --git a/java/tasks/oracle.yml b/java/tasks/oracle.yml new file mode 100644 index 00000000..da3473da --- /dev/null +++ b/java/tasks/oracle.yml @@ -0,0 +1,58 @@ +--- +- name: Install dependencies for build java package + apt: + name: "{{ item }}" + state: present + with_items: + - java-package + - build-essential + tags: + - java + +- name: Create jvm dir + file: + path: "{{ item }}" + state: directory + mode: "0777" + with_items: + - /srv/java-package + - /srv/java-package/src + - /srv/java-package/tmp + tags: + - java + +- name: Get Oracle jre archive + get_url: + url: 'http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jre-8u172-linux-x64.tar.gz' + dest: '/srv/java-package/src/' + checksum: 'sha256:f08f25aec2bdc86138ccba8fd5b904451e3afa1d24a88c85f28c2d84bfd45bad' + headers: 'Cookie: oraclelicense=accept-securebackup-cookie' + mode: "0644" + tags: + - java + +- name: Make Debian package from Oracle JDK archive + shell: "yes | TMPDIR=/srv/java-package/tmp make-jpkg /srv/java-package/src/jre-8u172-linux-x64.tar.gz" + args: + chdir: /srv/java-package + creates: /srv/java-package/oracle-java8-jre_8u172_amd64.deb + become: False + tags: + - java + +- include_role: + name: remount-usr + +- name: Install java package + apt: + deb: /srv/java-package/oracle-java8-jre_8u172_amd64.deb + tags: + - java + +- name: This openjdk version is the default alternative + alternatives: + name: java + path: "/usr/lib/jvm/jre-{{ java_version }}-oracle-x64/bin/java" + when: java_default_alternative + tags: + - java diff --git a/java8/tests/test.yml b/java/tests/test.yml similarity index 66% rename from java8/tests/test.yml rename to java/tests/test.yml index 624e2d3b..984c2eb4 100644 --- a/java8/tests/test.yml +++ b/java/tests/test.yml @@ -1,4 +1,4 @@ --- - hosts: test-kitchen roles: - - role: java8 + - role: java diff --git a/java8 b/java8 new file mode 120000 index 00000000..85863977 --- /dev/null +++ b/java8 @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/java8/README.md b/java8/README.md deleted file mode 100644 index 6279675d..00000000 --- a/java8/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# java8 - -Install OpenJDK 1.8 (from jessie-backports) - -## Tasks - -Everything is in the `tasks/main.yml` file. - -## Available variables - -* `java8_default_alternative`: make this verison the default alternative (defaults to true) diff --git a/java8/defaults/main.yml b/java8/defaults/main.yml deleted file mode 100644 index 9f57f290..00000000 --- a/java8/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -java8_default_alternative: True diff --git a/java8/tasks/main.yml b/java8/tasks/main.yml deleted file mode 100644 index 8e24def3..00000000 --- a/java8/tasks/main.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: Decide which Debian release to use - set_fact: - java8_apt_release: '{% if ansible_distribution_release == "jessie" %}jessie-backports{% else %}{{ ansible_distribution_release }}{% endif %}' - -- name: install jessie-backports - include_role: - name: apt - tasks_from: backports.yml - when: ansible_distribution_release == "jessie" - -- name: Java 8 is installed - apt: - name: openjdk-8-jre-headless - default_release: "{{ java8_apt_release }}" - state: present - tags: - - java - - packages - -- name: Java 8 is the default alternative - alternatives: - name: java - path: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - when: java8_default_alternative - tags: - - java diff --git a/jenkins/meta/main.yml b/jenkins/meta/main.yml index eda76a17..0f0b5b69 100644 --- a/jenkins/meta/main.yml +++ b/jenkins/meta/main.yml @@ -24,4 +24,4 @@ galaxy_info: # alphanumeric characters. Maximum 20 tags per role. dependencies: - - java8 + - { role: java, java_alternative: 'openjdk', java_version: 8 } diff --git a/logstash/meta/main.yml b/logstash/meta/main.yml index c74021e7..62a4cf71 100644 --- a/logstash/meta/main.yml +++ b/logstash/meta/main.yml @@ -14,4 +14,4 @@ galaxy_info: - jessie dependencies: - - java8 + - { role: java, java_alternative: 'openjdk', java_version: 8 }