Skip to content

Commit

Permalink
refactoring: EPMLDI-1748 (#94)
Browse files Browse the repository at this point in the history
* Test refactored code

Signed-off-by: Timur Gadiev <[email protected]>

* Add centos8 tests

Signed-off-by: Timur Gadiev <[email protected]>

* Fix packages

Signed-off-by: Timur Gadiev <[email protected]>

* Fix ubuntu

Signed-off-by: Timur Gadiev <[email protected]>

* Fix trailing space

Signed-off-by: Timur Gadiev <[email protected]>

* Test fixed ubuntu

Signed-off-by: Timur Gadiev <[email protected]>

* Test python-pip Ubuntu

Signed-off-by: Timur Gadiev <[email protected]>

* Fix adoptopenjdk

Signed-off-by: Timur Gadiev <[email protected]>

* Test requirements

Signed-off-by: Timur Gadiev <[email protected]>

* Fix epel

Signed-off-by: Timur Gadiev <[email protected]>

* Fix requirements

Signed-off-by: Timur Gadiev <[email protected]>

* Test debug

Signed-off-by: Timur Gadiev <[email protected]>

* Fix epel

Signed-off-by: Timur Gadiev <[email protected]>

* Fix pip Ubuntu

Signed-off-by: Timur Gadiev <[email protected]>

* Test ubuntu

Signed-off-by: Timur Gadiev <[email protected]>

* Test ubuntu 18

Signed-off-by: Timur Gadiev <[email protected]>

* Test alternate prepare

Signed-off-by: Timur Gadiev <[email protected]>

* Fix trailing spaces

Signed-off-by: Timur Gadiev <[email protected]>

* Remove raw python install

Signed-off-by: Timur Gadiev <[email protected]>

* Remove upgrade pip

Signed-off-by: Timur Gadiev <[email protected]>

* Add executable

Signed-off-by: Timur Gadiev <[email protected]>

* Test full java 12 and openjdk-ga

Signed-off-by: Timur Gadiev <[email protected]>

* Test inventory vars

Signed-off-by: Timur Gadiev <[email protected]>

* Fix group vars

Signed-off-by: Timur Gadiev <[email protected]>

* Add ansible_python_interpreter: /usr/bin/python3

Signed-off-by: Timur Gadiev <[email protected]>

* Add extra_args

Signed-off-by: Timur Gadiev <[email protected]>

* Add aws profile

Signed-off-by: Timur Gadiev <[email protected]>

* Add ansible_python_interpreter

Signed-off-by: Timur Gadiev <[email protected]>

* Enable all tests

Signed-off-by: Timur Gadiev <[email protected]>

* Update scenarios

Signed-off-by: Timur Gadiev <[email protected]>

* Fix debian test

Signed-off-by: Timur Gadiev <[email protected]>

* Make separate tasks for paths settings

Signed-off-by: Timur Gadiev <[email protected]>
tgadiev authored and pavelpikta committed Oct 17, 2019
1 parent beb41b8 commit 38ebbb5
Showing 29 changed files with 402 additions and 202 deletions.
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ AWS java-6:
tags:
- aws

AWS java-7:
.AWS java-7:
variables:
AWS_REGION: us-east-1
stage: deployment test
@@ -78,7 +78,7 @@ AWS openjdk-13 Windows chocolatey:
tags:
- aws

AWS java-11:
.AWS java-11:
variables:
AWS_REGION: us-east-1
stage: deployment test
@@ -132,7 +132,7 @@ AWS openjdk-ga Windows:
tags:
- aws

AWS java-11 Windows:
.AWS java-11 Windows:
variables:
AWS_REGION: us-east-1
stage: deployment test
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ Requirements
- 8
- EL 6: repositories, tarball
- EL 7: repositories, tarball
- EL 8: repositories, tarball
- Ubuntu bionic: repositories, tarball
- Debian stretch: repositories, tarball
- Windows: tarball
@@ -59,12 +60,14 @@ Requirements
- 12
- EL 6: tarball
- EL 7: tarball
- EL 8: tarball
- Ubuntu bionic: tarball
- Debian stretch: tarball
- Windows: tarball
- 13
- EL 6: tarball, openjdk-fallback
- EL 7: tarball, openjdk-fallback
- EL 8: tarball, openjdk-fallback
- Ubuntu bionic: tarball, openjdk-fallback
- Debian stretch: tarball, openjdk-fallback
- Windows: tarball, openjdk-fallback
@@ -98,6 +101,7 @@ Requirements
- EL
- 6
- 7
- 8
- Windows
- all

4 changes: 4 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ galaxy_info:
versions:
- "6"
- "7"
- "8"
- name: "Amazon"
versions:
- "2017.12"
@@ -35,7 +36,10 @@ galaxy_info:
- "java"
- "oracle"
- "jdk"
- "jre"
- "openjdk"
- "adoptopenjdk"
- "zulu"
- "sapjvm"
- "windows"

6 changes: 3 additions & 3 deletions molecule/cloud-aws-adoptopenjdk-11/molecule.yml
Original file line number Diff line number Diff line change
@@ -67,9 +67,9 @@ platforms:
- jdk
- repositories

- name: test-aws-centos7-adoptopenjdk-openj9-jre-repositories-11
image: ami-9887c6e7
platform: centos7
- name: test-aws-centos8-adoptopenjdk-openj9-jre-repositories-11
image: ami-0ed2ad9dc845b42b6
platform: centos8
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
38 changes: 20 additions & 18 deletions molecule/cloud-aws-adoptopenjdk-11/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
---
- name: Prepare Ubuntu / Debian
- name: Include common prepare
import_playbook: ../resources/provisioning/AWS/prepare.yml

- name: Prepare Debian
hosts: debian_family
gather_facts: false
tasks:
- name: Install python for Ansible
raw: test -e /usr/bin/python || (apt install -y python-minimal)

- name: Add universe repository for bionic
apt_repository:
repo: deb http://archive.ubuntu.com/ubuntu bionic universe
state: present
when: ansible_distribution_release == 'bionic'
become: true

- name: Install python packages
apt:
name:
- python-setuptools
state: present
register: status
until: status is succeeded
become: true
changed_when: false
register: update_result
retries: 10
delay: 5
until: update_result.rc == 0

- name: Prepare RHEL
hosts: rhel_family
gather_facts: false
tasks:
- name: Install python for Ansible
raw: test -e /usr/bin/python || (yum install -y python2 python-simplejson)
become: true
changed_when: false

- name: gather facts
setup:

- name: 'Enable EPEL repository'
- name: Enable EPEL repository
yum:
name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-\
{{ ansible_distribution_major_version }}.noarch.rpm"
32 changes: 32 additions & 0 deletions molecule/cloud-aws-adoptopenjdk-12/molecule.yml
Original file line number Diff line number Diff line change
@@ -10,6 +10,26 @@ lint:
options:
config-file: .yamllint
platforms:
- name: test-aws-centos8-adoptopenjdk-hotspot-jre-repositories-12
image: ami-0ed2ad9dc845b42b6
platform: centos8
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: centos
groups:
- rhel_family
- adoptopenjdk
- hotspot
- jre
- repositories
- pip3

- name: test-aws-centos7-adoptopenjdk-openj9-jdk-tarball-12
image: ami-9887c6e7
platform: centos7
@@ -28,6 +48,7 @@ platforms:
- openj9
- jdk
- adoptopenjdk_fallback
- pip2

- name: test-aws-Debian9-adoptopenjdk-openj9-jre-tarball-12
image: ami-003f19e0e687de1cd
@@ -47,6 +68,7 @@ platforms:
- openj9
- jre
- adoptopenjdk_fallback
- pip2

- name: test-aws-ubuntu18-adoptopenjdk-hotspot-jdk-repositories-12
image: ami-012fd5eb46f56731f
@@ -66,6 +88,7 @@ platforms:
- hotspot
- jdk
- repositories
- pip3

- name: test-aws-Debian9-adoptopenjdk-hotspot-jre-repositories-12
image: ami-003f19e0e687de1cd
@@ -85,6 +108,7 @@ platforms:
- hotspot
- jre
- repositories
- pip2

- name: test-aws-Debian9-adoptopenjdk-s3-12
image: ami-003f19e0e687de1cd
@@ -103,6 +127,7 @@ platforms:
- debian_family
- adoptopenjdk
- s3
- pip2

provisioner:
name: ansible
@@ -112,6 +137,13 @@ provisioner:
callback_whitelist: profile_tasks,timer
inventory:
group_vars:
pip2:
pip_executable: pip
python_executable: python
pip3:
pip_executable: pip3
python_executable: python3
ansible_python_interpreter: /usr/bin/python3
adoptopenjdk:
java_distribution: adoptopenjdk
java_major_version: 12
55 changes: 28 additions & 27 deletions molecule/cloud-aws-adoptopenjdk-12/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
---
- name: Prepare Ubuntu / Debian
- name: Include common prepare
import_playbook: ../resources/provisioning/AWS/prepare.yml

- name: Prepare Debian
hosts: debian_family
gather_facts: false
tasks:
- name: Install python for Ansible
raw: test -e /usr/bin/python || (apt install -y python-minimal)

- name: Add universe repository for bionic
apt_repository:
repo: deb http://archive.ubuntu.com/ubuntu bionic universe
state: present
when: ansible_distribution_release == 'bionic'
become: true

- name: Install python packages
apt:
name:
- python-setuptools
state: present
register: status
until: status is succeeded
become: true
changed_when: false
register: update_result
retries: 10
delay: 5
until: update_result.rc == 0

- name: Prepare RHEL
hosts: rhel_family
gather_facts: false
tasks:
- name: Install python for Ansible
raw: test -e /usr/bin/python || (yum install -y python2 python-simplejson)
become: true
changed_when: false

- name: gather facts
setup:

- name: 'Enable EPEL repository'
- name: Enable EPEL repository
yum:
name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-\
{{ ansible_distribution_major_version }}.noarch.rpm"
@@ -35,32 +37,31 @@

- name: Prepare host to S3 transport
hosts: s3
gather_facts: true
tasks:
- name: 'Install pip package'

- name: Install pip package
package:
name: python-pip
name: '{{ python_executable }}-pip'
state: present
register: status
until: status is succeeded
become: true

- name: 'Install boto module'
- name: Install boto module
pip:
name:
- 'pip'
- 'botocore'
- 'boto'
- 'boto3'
- botocore
- boto
- boto3
state: present
executable: '{{ pip_executable }}'
extra_args: --upgrade
register: status
until: status is succeeded
become: true

- name: Prepare host to S3 transport
hosts: localhost
gather_facts: true
vars:
transport_s3_bucket: java-molecule-s3-test
transport_s3_path: /java/adoptopenjdk/OpenJDK12U-jdk_x64_linux_hotspot_12.0.1_12.tar.gz
40 changes: 40 additions & 0 deletions molecule/cloud-aws-direct-12/molecule.yml
Original file line number Diff line number Diff line change
@@ -10,6 +10,26 @@ lint:
options:
config-file: .yamllint
platforms:
- name: test-aws-centos8-oracle_java-12-s3-rpm
image: ami-0ed2ad9dc845b42b6
platform: centos8
instance_type: m5.large
profile_name: epmldi-instance-profile
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: centos
groups:
- rhel_family
- s3
- package
- pip3
- centos

- name: test-aws-centos7-oracle_java-12-s3-rpm
image: ami-9887c6e7
platform: centos7
@@ -27,6 +47,8 @@ platforms:
- rhel_family
- s3
- package
- pip2
- centos

- name: test-aws-ubuntu18-oracle_java-12-s3-deb
image: ami-012fd5eb46f56731f
@@ -45,6 +67,7 @@ platforms:
- debian_family
- s3
- package
- pip3

- name: test-aws-Debian9-oracle_java-12-s3-tb
image: ami-003f19e0e687de1cd
@@ -63,6 +86,7 @@ platforms:
- debian_family
- s3
- tarball
- pip2

- name: test-aws-Amazon-oracle_java-12
image: ami-035b3c7efe6d061d5
@@ -81,6 +105,8 @@ platforms:
- rhel_family
- s3
- package
- amazon
- pip2

- name: test-aws-Amazon2-oracle_java-12
image: ami-0b898040803850657
@@ -99,6 +125,8 @@ platforms:
- rhel_family
- s3
- tarball
- amazon
- pip2

provisioner:
name: ansible
@@ -108,6 +136,18 @@ provisioner:
callback_whitelist: profile_tasks,timer
inventory:
group_vars:
pip2:
pip_executable: pip
python_executable: python
pip3:
pip_executable: pip3
python_executable: python3
ansible_python_interpreter: /usr/bin/python3
centos:
epel_path: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-\
{{ ansible_distribution_major_version }}.noarch.rpm"
amazon:
epel_path: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
s3:
transport: s3
transport_s3_bucket: java-molecule-s3-test
36 changes: 28 additions & 8 deletions molecule/cloud-aws-direct-12/prepare.yml
Original file line number Diff line number Diff line change
@@ -2,25 +2,45 @@
- name: Include common prepare
import_playbook: ../resources/provisioning/AWS/prepare.yml

- name: Prepare RHEL
hosts: rhel_family
- name: Prepare Debian
hosts: debian_family
tasks:

- name: Enable EPEL repository
yum:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- name: Add universe repository for bionic
apt_repository:
repo: deb http://archive.ubuntu.com/ubuntu bionic universe
state: present
when: ansible_distribution_release == 'bionic'
become: true

- name: Install python packages
apt:
name:
- python-setuptools
state: present
register: status
until: status is succeeded
become: true

- name: Prepare RHEL
hosts: rhel_family
tasks:

- block:
- name: Enable EPEL repository
yum:
name: '{{ epel_path }}'
state: present
register: status
until: status is succeeded
become: true

- name: Prepare host to S3 transport
hosts: s3
gather_facts: true
tasks:
- name: Install pip package
package:
name: python-pip
name: '{{ python_executable }}-pip'
state: present
register: status
until: status is succeeded
@@ -29,11 +49,11 @@
- name: Install boto module
pip:
name:
- pip
- botocore
- boto
- boto3
state: present
executable: '{{ pip_executable }}'
extra_args: --upgrade
register: status
until: status is succeeded
25 changes: 18 additions & 7 deletions molecule/cloud-aws-direct-8/molecule.yml
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ lint:
config-file: .yamllint
platforms:

- name: test-aws-centos7-oracle_java-8-s3-rpm
image: ami-9887c6e7
platform: centos7
- name: test-aws-centos8-oracle_java-8-s3-rpm
image: ami-0ed2ad9dc845b42b6
platform: centos8
instance_type: m5.large
profile_name: epmldi-instance-profile
region: us-east-1
@@ -28,6 +28,7 @@ platforms:
- rhel_family
- s3
- package
- pip3

- name: test-aws-centos7-oracle_java-8-s3
image: ami-9887c6e7
@@ -46,6 +47,7 @@ platforms:
- rhel_family
- s3
- tarball
- pip2

- name: test-aws-ubuntu18-oracle_java-8-s3
image: ami-012fd5eb46f56731f
@@ -64,10 +66,11 @@ platforms:
- debian_family
- s3
- tarball
- pip3

- name: test-aws-ubuntu18-oracle_java-8-local
image: ami-012fd5eb46f56731f
platform: ubuntu18
- name: test-aws-debian9-oracle_java-8-local
image: ami-003f19e0e687de1cd
platform: debian9
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
@@ -76,11 +79,12 @@ platforms:
security_group_name:
- default
wait_timeout: 1800
ssh_user: ubuntu
ssh_user: admin
groups:
- debian_family
- local
- tarball
- pip2

provisioner:
name: ansible
@@ -90,6 +94,13 @@ provisioner:
callback_whitelist: profile_tasks,timer
inventory:
group_vars:
pip2:
pip_executable: pip
python_executable: python
pip3:
pip_executable: pip3
python_executable: python3
ansible_python_interpreter: /usr/bin/python3
local:
transport: local
transport_local: /tmp/jdk-8u202-linux-x64.tar.gz
53 changes: 26 additions & 27 deletions molecule/cloud-aws-direct-8/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
---
- name: Prepare Ubuntu / Debian
- name: Include common prepare
import_playbook: ../resources/provisioning/AWS/prepare.yml

- name: Prepare Debian
hosts: debian_family
gather_facts: false
tasks:

- name: Install python for Ansible
raw: test -e /usr/bin/python || (apt install -y python-minimal)
- name: Add universe repository for bionic
apt_repository:
repo: deb http://archive.ubuntu.com/ubuntu bionic universe
state: present
when: ansible_distribution_release == 'bionic'
become: true

- name: Install python packages
apt:
name:
- python-setuptools
state: present
register: status
until: status is succeeded
become: true
changed_when: false
register: update_result
retries: 10
delay: 5
until: update_result.rc == 0

- name: Prepare RHEL
hosts: rhel_family
gather_facts: false
tasks:
- name: Install python for Ansible
raw: test -e /usr/bin/python || (yum install -y python2 python-simplejson)
become: true
changed_when: false

- name: gather facts
setup:

- name: 'Enable EPEL repository'
- name: Enable EPEL repository
yum:
name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-\
{{ ansible_distribution_major_version }}.noarch.rpm"
@@ -36,32 +37,30 @@

- name: Prepare host to S3 transport
hosts: s3
gather_facts: true
tasks:
- name: 'Install pip package'
- name: Install pip package
package:
name: python-pip
name: '{{ python_executable }}-pip'
state: present
register: status
until: status is succeeded
become: true

- name: 'Install boto module'
- name: Install boto module
pip:
name:
- 'pip'
- 'botocore'
- 'boto'
- 'boto3'
- botocore
- boto
- boto3
state: present
executable: '{{ pip_executable }}'
extra_args: --upgrade
register: status
until: status is succeeded
become: true

- name: Prepare host to S3 transport
hosts: localhost
gather_facts: true
vars:
transport_s3_bucket: java-molecule-s3-test
transport_s3_path: /java/jdk-8u202-linux-x64.tar.gz
16 changes: 16 additions & 0 deletions molecule/cloud-aws-openjdk-8/molecule.yml
Original file line number Diff line number Diff line change
@@ -10,6 +10,22 @@ lint:
options:
config-file: .yamllint
platforms:
- name: test-aws-centos8-openjdk-8-repo
image: ami-0ed2ad9dc845b42b6
platform: centos8
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: centos
groups:
- rhel_family
- repositories

- name: test-aws-centos7-openjdk-8-repo
image: ami-9887c6e7
platform: centos7
15 changes: 15 additions & 0 deletions molecule/cloud-aws-openjdk-ga/molecule.yml
Original file line number Diff line number Diff line change
@@ -10,6 +10,21 @@ lint:
options:
config-file: .yamllint
platforms:
- name: test-aws-centos8-openjdk-ga
image: ami-0ed2ad9dc845b42b6
platform: centos8
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: centos
groups:
- rhel_family

- name: test-aws-centos7-openjdk-ga
image: ami-9887c6e7
platform: centos7
16 changes: 16 additions & 0 deletions molecule/cloud-aws-sapjvm-8/molecule.yml
Original file line number Diff line number Diff line change
@@ -10,6 +10,22 @@ lint:
options:
config-file: .yamllint
platforms:
- name: test-aws-centos8-sapjvm-8
image: ami-0ed2ad9dc845b42b6
platform: centos8
instance_type: m5.large
region: us-east-1
vpc_subnet_id: subnet-0f2b9cd66faea38af
assign_public_ip: false
spot_price: 0.04
security_group_name:
- default
wait_timeout: 1800
ssh_user: centos
groups:
- rhel_family
- sapjvm

- name: test-aws-centos7-sapjvm-8
image: ami-9887c6e7
platform: centos7
1 change: 0 additions & 1 deletion molecule/cloud-aws-windows-11/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
- name: Prepare host to S3 transport
hosts: localhost
gather_facts: true
vars:
transport_s3_bucket: java-molecule-s3-test
java_download_path: /tmp
3 changes: 0 additions & 3 deletions molecule/resources/tests/verify.yml
Original file line number Diff line number Diff line change
@@ -3,9 +3,6 @@
hosts: all
tasks:

- name: Populate service facts
service_facts:

- name: Check java
command: java -version
register: java_ver_cmd
1 change: 0 additions & 1 deletion molecule/resources/tests/verify_win.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# This is an example playbook to execute Ansible tests.
- name: Verify
hosts: windows
tasks:
44 changes: 44 additions & 0 deletions tasks/Linux/finalize_paths.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- name: Find java_folder
find:
paths: '{{ java_path }}'
recurse: false
file_type: directory
patterns: '{{ java_folder }}'
use_regex: true
register: java_dir

- name: Set actual java directory
set_fact:
java_folder: "{{ java_dir.files | map(attribute='path') | list | last | basename }}"

- name: Put java profile
template:
src: java.sh.j2
dest: /etc/profile.d/java.sh
owner: root
group: root
mode: 0555

- name: Check for java binaries existence
stat:
path: '{{ java_path }}/{{ java_folder }}/bin/{{ binary }}'
register: java_binary_collection
loop:
- java
- javac
- jar
- keytool
loop_control:
loop_var: binary

- name: Update alternatives
alternatives:
name: '{{ java_item.binary }}'
path: '{{ java_path }}/{{ java_folder }}/bin/{{ java_item.binary }}'
link: '/usr/bin/{{ java_item.binary }}'
priority: 100
when: java_item.stat.exists | bool
loop: '{{ java_binary_collection.results }}'
loop_control:
loop_var: java_item
19 changes: 0 additions & 19 deletions tasks/Linux/install/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
---
- name: Add apt-key and repository for AdoptOpenJDK
block:
- name: Add apt-key for AdoptOpenJDK
apt_key:
url: https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
state: present
register: package_install
until: package_install is succeeded

- name: Add repository for AdoptOpenJDK
apt_repository:
repo: 'deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ bionic main'
filename: adoptopenjdk
state: present
codename: trusty
update_cache: true
when:
- java_distribution == "adoptopenjdk"

- name: Install java packages
apt:
deb: '{{ java_artifact | default(omit) }}'
25 changes: 25 additions & 0 deletions tasks/Linux/install/Debian_adoptopenjdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Add apt-key for AdoptOpenJDK
apt_key:
url: https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
state: present
register: package_install
until: package_install is succeeded

- name: Add repository for AdoptOpenJDK
apt_repository:
repo: 'deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ bionic main'
filename: adoptopenjdk
state: present
codename: trusty
update_cache: true

- name: Install java packages
apt:
deb: '{{ java_artifact | default(omit) }}'
name: '{{ (jdk_package if transport == "repositories") | default(omit) }}'
state: present
update_cache: true
cache_valid_time: 3600
register: package_install
until: package_install is succeeded
11 changes: 0 additions & 11 deletions tasks/Linux/install/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
---
- name: Add repository for AdoptOpenJDK
yum_repository:
name: AdoptOpenJDK
description: AdoptOpenJDK
baseurl: http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/7/x86_64
enabled: true
gpgcheck: true
gpgkey: https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
when:
- java_distribution == "adoptopenjdk"

- name: Install java packages
yum:
name: '{{ (transport == "repositories") | ternary(jdk_package, java_artifact) }}'
16 changes: 16 additions & 0 deletions tasks/Linux/install/RedHat_adoptopenjdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Add repository for AdoptOpenJDK
yum_repository:
name: AdoptOpenJDK
description: AdoptOpenJDK
baseurl: http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/7/x86_64
enabled: true
gpgcheck: true
gpgkey: https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public

- name: Install java packages
yum:
name: '{{ (transport == "repositories") | ternary(jdk_package, java_artifact) }}'
state: present
register: package_install
until: package_install is succeeded
48 changes: 5 additions & 43 deletions tasks/Linux/system.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
- name: Set parse variables based on java distribution
include_vars: java_parts.yml

- name: Perform install from artifacts
block:
- name: Install requirements
@@ -18,47 +21,6 @@
loop_control:
loop_var: install_task

- name: Find java_folder
find:
paths: '{{ java_path }}'
recurse: false
file_type: directory
patterns: '{{ java_folder }}'
use_regex: true
register: java_dir

- name: Set actual java directory
set_fact:
java_folder: "{{ java_dir.files | map(attribute='path') | list | last | basename }}"

- name: Put java profile
template:
src: java.sh.j2
dest: /etc/profile.d/java.sh
owner: root
group: root
mode: 0555

- name: Check for java binaries existence
stat:
path: '{{ java_path }}/{{ java_folder }}/bin/{{ binary }}'
register: java_binary_collection
loop:
- java
- javac
- jar
- keytool
loop_control:
loop_var: binary

- name: Update alternatives
alternatives:
name: '{{ java_item.binary }}'
path: '{{ java_path }}/{{ java_folder }}/bin/{{ java_item.binary }}'
link: '/usr/bin/{{ java_item.binary }}'
priority: 100
when: java_item.stat.exists | bool
loop: '{{ java_binary_collection.results }}'
loop_control:
loop_var: java_item
- name: Finalize binary paths
include_tasks: finalize_paths.yml
become: true
14 changes: 14 additions & 0 deletions tasks/Linux/system_repositories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Perform install from repositories
block:
- name: 'Perform repo install'
include_tasks: '{{ install_task }}'
with_first_found:
- 'install/{{ ansible_os_family }}_{{ java_distribution }}.yml'
- 'install/{{ ansible_os_family }}.yml'
loop_control:
loop_var: install_task

- name: Finalize binary paths
include_tasks: finalize_paths.yml
become: true
26 changes: 26 additions & 0 deletions tasks/Win32NT/finalize_paths.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Find java_folder
win_find:
paths: '{{ java_path }}'
recurse: false
file_type: directory
patterns: '{{ java_folder }}'
use_regex: true
register: java_dir

- name: Set actual java directory
set_fact:
java_act_path: "{{ java_dir.files | map(attribute='path') | list | last }}"

- name: Set java environment variable
win_environment:
name: JAVA_HOME
state: present
value: '{{ java_act_path }}'
level: machine

- name: Ensure that 'JAVA_HOME\bin' present in 'Path' variable
win_path:
elements: '{{ java_act_path }}\bin'
state: present
scope: machine
30 changes: 5 additions & 25 deletions tasks/Win32NT/system.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
- name: Set parse variables based on java distribution
include_vars: java_parts.yml

- name: 'Perform {{ java_binary_type }} install'
include_tasks: '{{ install_task }}'
with_first_found:
@@ -7,28 +10,5 @@
loop_control:
loop_var: install_task

- name: Find java_folder
win_find:
paths: '{{ java_path }}'
recurse: false
file_type: directory
patterns: '{{ java_folder }}'
use_regex: true
register: java_dir

- name: Set actual java directory
set_fact:
java_act_path: "{{ java_dir.files | map(attribute='path') | list | last }}"

- name: Set java environment variable
win_environment:
name: JAVA_HOME
state: present
value: '{{ java_act_path }}'
level: machine

- name: Ensure that 'JAVA_HOME\bin' present in 'Path' variable
win_path:
elements: '{{ java_act_path }}\bin'
state: present
scope: machine
- name: Finalize binary paths
include_tasks: finalize_paths.yml
11 changes: 11 additions & 0 deletions tasks/Win32NT/system_chocolatey.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: 'Perform {{ java_binary_type }} install'
include_tasks: '{{ install_task }}'
with_first_found:
- 'install/{{ java_distribution }}_{{ java_binary_type }}.yml'
- 'install/{{ java_binary_type }}.yml'
loop_control:
loop_var: install_task

- name: Finalize binary paths
include_tasks: finalize_paths.yml
8 changes: 2 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -18,15 +18,11 @@
loop_control:
loop_var: transport_driver

- name: Set parse variables based on java distribution
include_vars: java_parts.yml
when:
- transport != 'repositories'
- java_binary_type != 'chocolatey'

- name: Choose platform based task
include_tasks: '{{ platform }}'
with_first_found:
- '{{ ansible_system }}/system_{{ transport }}.yml'
- '{{ ansible_system }}/system_{{ java_binary_type }}.yml'
- '{{ ansible_system }}/system.yml'
- not-supported.yml
loop_control:
1 change: 1 addition & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
java_package_requirements:
- unzip
- tar
- rsync

# Variables for RHEL specific (example java-11-openjdk-devel.x86_64)

0 comments on commit 38ebbb5

Please sign in to comment.