From 5aa4a7ee66413cfe8a3b58ec232b561795d503fc Mon Sep 17 00:00:00 2001 From: lhahn Date: Sun, 17 Sep 2023 10:55:48 +0200 Subject: [PATCH] Git initial commit --- LICENSE | 9 +++++++++ README.md | 3 +++ defaults/main.yml | 20 +++++++++++++++++++ handlers/main.yml | 2 ++ meta/main.yml | 16 +++++++++++++++ tasks/main.yml | 50 +++++++++++++++++++++++++++++++++++++++++++++++ vars/main.yml | 2 ++ 7 files changed, 102 insertions(+) create mode 100755 LICENSE create mode 100755 README.md create mode 100755 defaults/main.yml create mode 100755 handlers/main.yml create mode 100755 meta/main.yml create mode 100755 tasks/main.yml create mode 100755 vars/main.yml diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..2071b23 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100755 index 0000000..92297e5 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# cloud-java + +Ansible role to install Adoptium Temurin JDK needed for several tools. \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100755 index 0000000..7b3e1c8 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,20 @@ +--- +cloud_apps: /opt +cloud_storage: /opt/storage +cloud_stage: prod +cloud_update: false + + +java_home: "{{ java_homepath }}/java" + +java_version: + - stream: 17 + file: 17.0.2_8 + download: jdk-17.0.2+8 + - stream: 11 + file: 11.0.14.1_1 + download: jdk-11.0.14.1+1 + link: true + - stream: 8 + file: 8u322b06 + download: jdk8u322-b06 diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100755 index 0000000..cd21505 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +--- + diff --git a/meta/main.yml b/meta/main.yml new file mode 100755 index 0000000..31d665c --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,16 @@ +--- +galaxy_info: + role_name: java + namespace: hahn-cloud + author: Lars Hahn + company: OpenDevChain + license: MIT + description: Role to setup Java Adoptium / Eclipse Temurin + min_ansible_version: 2.7 + platforms: + - name: Debian + versions: + - 11 + galaxy_tags: + - java +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100755 index 0000000..0132be0 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,50 @@ +--- +- name: install requirements for docker + apt: + update_cache: yes + state: "{% if cloud_update | bool %}latest{% else %}present{% endif %}" + install_recommends: yes + pkg: + - apt-transport-https + - ca-certificates + - gnupg2 + - software-properties-common + - curl + +- name: install java Adoptium Temurin repository key + apt_key: + url: https://packages.adoptium.net/artifactory/api/gpg/key/public + state: present + +- name: install Adoptium Temurin repository + apt_repository: + repo: "deb https://packages.adoptium.net/artifactory/deb {{ ansible_distribution_release }} main" + state: present + +- name: setup java directory + file: + state: directory + path: "{{ java_homepath }}" + mode: 0755 + +- name: download Adoptium Eclipse Temurin JDK + unarchive: + src: "https://github.com/adoptium/temurin{{ java.stream }}-binaries/releases/download/{{ java.download }}/OpenJDK{{ java.stream }}U-jdk_x64_linux_hotspot_{{ java.file }}.tar.gz" + dest: "{{ java_homepath }}" + creates: "{{ java_homepath }}/{{ java.download }}" + remote_src: true + mode: 0755 + loop: "{{ java_version }}" + loop_control: + loop_var: java + label: "{{ java.download }}" + +- name: setup generic java link + file: + state: link + src: "{{ java_homepath }}/{{ java.download }}" + dest: "{{ java_home }}" + loop: "{{ java_version | json_query('[?link==`true`]') }}" + loop_control: + loop_var: java + label: "{{ java.download }}" diff --git a/vars/main.yml b/vars/main.yml new file mode 100755 index 0000000..6298843 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +java_homepath: "{{ cloud_apps }}/java_jdk"