From 38ebbb5ac16fbbe568a4730812221dd5338c0621 Mon Sep 17 00:00:00 2001 From: Timur Gadiev Date: Thu, 17 Oct 2019 11:26:24 +0300 Subject: [PATCH] refactoring: EPMLDI-1748 (#94) * Test refactored code Signed-off-by: Timur Gadiev * Add centos8 tests Signed-off-by: Timur Gadiev * Fix packages Signed-off-by: Timur Gadiev * Fix ubuntu Signed-off-by: Timur Gadiev * Fix trailing space Signed-off-by: Timur Gadiev * Test fixed ubuntu Signed-off-by: Timur Gadiev * Test python-pip Ubuntu Signed-off-by: Timur Gadiev * Fix adoptopenjdk Signed-off-by: Timur Gadiev * Test requirements Signed-off-by: Timur Gadiev * Fix epel Signed-off-by: Timur Gadiev * Fix requirements Signed-off-by: Timur Gadiev * Test debug Signed-off-by: Timur Gadiev * Fix epel Signed-off-by: Timur Gadiev * Fix pip Ubuntu Signed-off-by: Timur Gadiev * Test ubuntu Signed-off-by: Timur Gadiev * Test ubuntu 18 Signed-off-by: Timur Gadiev * Test alternate prepare Signed-off-by: Timur Gadiev * Fix trailing spaces Signed-off-by: Timur Gadiev * Remove raw python install Signed-off-by: Timur Gadiev * Remove upgrade pip Signed-off-by: Timur Gadiev * Add executable Signed-off-by: Timur Gadiev * Test full java 12 and openjdk-ga Signed-off-by: Timur Gadiev * Test inventory vars Signed-off-by: Timur Gadiev * Fix group vars Signed-off-by: Timur Gadiev * Add ansible_python_interpreter: /usr/bin/python3 Signed-off-by: Timur Gadiev * Add extra_args Signed-off-by: Timur Gadiev * Add aws profile Signed-off-by: Timur Gadiev * Add ansible_python_interpreter Signed-off-by: Timur Gadiev * Enable all tests Signed-off-by: Timur Gadiev * Update scenarios Signed-off-by: Timur Gadiev * Fix debian test Signed-off-by: Timur Gadiev * Make separate tasks for paths settings Signed-off-by: Timur Gadiev --- .gitlab-ci.yml | 6 +- README.md | 4 ++ meta/main.yml | 4 ++ .../cloud-aws-adoptopenjdk-11/molecule.yml | 6 +- .../cloud-aws-adoptopenjdk-11/prepare.yml | 38 +++++++------ .../cloud-aws-adoptopenjdk-12/molecule.yml | 32 +++++++++++ .../cloud-aws-adoptopenjdk-12/prepare.yml | 55 ++++++++++--------- molecule/cloud-aws-direct-12/molecule.yml | 40 ++++++++++++++ molecule/cloud-aws-direct-12/prepare.yml | 36 +++++++++--- molecule/cloud-aws-direct-8/molecule.yml | 25 ++++++--- molecule/cloud-aws-direct-8/prepare.yml | 53 +++++++++--------- molecule/cloud-aws-openjdk-8/molecule.yml | 16 ++++++ molecule/cloud-aws-openjdk-ga/molecule.yml | 15 +++++ molecule/cloud-aws-sapjvm-8/molecule.yml | 16 ++++++ molecule/cloud-aws-windows-11/prepare.yml | 1 - molecule/resources/tests/verify.yml | 3 - molecule/resources/tests/verify_win.yml | 1 - tasks/Linux/finalize_paths.yml | 44 +++++++++++++++ tasks/Linux/install/Debian.yml | 19 ------- tasks/Linux/install/Debian_adoptopenjdk.yml | 25 +++++++++ tasks/Linux/install/RedHat.yml | 11 ---- tasks/Linux/install/RedHat_adoptopenjdk.yml | 16 ++++++ tasks/Linux/system.yml | 48 ++-------------- tasks/Linux/system_repositories.yml | 14 +++++ tasks/Win32NT/finalize_paths.yml | 26 +++++++++ tasks/Win32NT/system.yml | 30 ++-------- tasks/Win32NT/system_chocolatey.yml | 11 ++++ tasks/main.yml | 8 +-- vars/RedHat.yml | 1 + 29 files changed, 402 insertions(+), 202 deletions(-) create mode 100644 tasks/Linux/finalize_paths.yml create mode 100644 tasks/Linux/install/Debian_adoptopenjdk.yml create mode 100644 tasks/Linux/install/RedHat_adoptopenjdk.yml create mode 100644 tasks/Linux/system_repositories.yml create mode 100644 tasks/Win32NT/finalize_paths.yml create mode 100644 tasks/Win32NT/system_chocolatey.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b0534025..4773c74a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/README.md b/README.md index aa284fbe..ea5f9927 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/meta/main.yml b/meta/main.yml index 5e84fc63..55697b98 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -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" diff --git a/molecule/cloud-aws-adoptopenjdk-11/molecule.yml b/molecule/cloud-aws-adoptopenjdk-11/molecule.yml index e39b6810..2a26f9f7 100644 --- a/molecule/cloud-aws-adoptopenjdk-11/molecule.yml +++ b/molecule/cloud-aws-adoptopenjdk-11/molecule.yml @@ -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 diff --git a/molecule/cloud-aws-adoptopenjdk-11/prepare.yml b/molecule/cloud-aws-adoptopenjdk-11/prepare.yml index 2ffd1360..7d9c35c3 100644 --- a/molecule/cloud-aws-adoptopenjdk-11/prepare.yml +++ b/molecule/cloud-aws-adoptopenjdk-11/prepare.yml @@ -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" diff --git a/molecule/cloud-aws-adoptopenjdk-12/molecule.yml b/molecule/cloud-aws-adoptopenjdk-12/molecule.yml index e8146bb3..0edfa52c 100644 --- a/molecule/cloud-aws-adoptopenjdk-12/molecule.yml +++ b/molecule/cloud-aws-adoptopenjdk-12/molecule.yml @@ -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 diff --git a/molecule/cloud-aws-adoptopenjdk-12/prepare.yml b/molecule/cloud-aws-adoptopenjdk-12/prepare.yml index 45552714..240ef69e 100644 --- a/molecule/cloud-aws-adoptopenjdk-12/prepare.yml +++ b/molecule/cloud-aws-adoptopenjdk-12/prepare.yml @@ -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,24 +37,24 @@ - 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 @@ -60,7 +62,6 @@ - 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 diff --git a/molecule/cloud-aws-direct-12/molecule.yml b/molecule/cloud-aws-direct-12/molecule.yml index b25fe6dd..cb641143 100644 --- a/molecule/cloud-aws-direct-12/molecule.yml +++ b/molecule/cloud-aws-direct-12/molecule.yml @@ -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 diff --git a/molecule/cloud-aws-direct-12/prepare.yml b/molecule/cloud-aws-direct-12/prepare.yml index bdca8644..403e160a 100644 --- a/molecule/cloud-aws-direct-12/prepare.yml +++ b/molecule/cloud-aws-direct-12/prepare.yml @@ -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 diff --git a/molecule/cloud-aws-direct-8/molecule.yml b/molecule/cloud-aws-direct-8/molecule.yml index 9cef5308..e2e6c493 100644 --- a/molecule/cloud-aws-direct-8/molecule.yml +++ b/molecule/cloud-aws-direct-8/molecule.yml @@ -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 diff --git a/molecule/cloud-aws-direct-8/prepare.yml b/molecule/cloud-aws-direct-8/prepare.yml index 2c4a9063..2ba62464 100644 --- a/molecule/cloud-aws-direct-8/prepare.yml +++ b/molecule/cloud-aws-direct-8/prepare.yml @@ -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,24 +37,23 @@ - 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 @@ -61,7 +61,6 @@ - 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 diff --git a/molecule/cloud-aws-openjdk-8/molecule.yml b/molecule/cloud-aws-openjdk-8/molecule.yml index df1d1a26..c57c8804 100644 --- a/molecule/cloud-aws-openjdk-8/molecule.yml +++ b/molecule/cloud-aws-openjdk-8/molecule.yml @@ -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 diff --git a/molecule/cloud-aws-openjdk-ga/molecule.yml b/molecule/cloud-aws-openjdk-ga/molecule.yml index acd4a12e..e0c3c31b 100644 --- a/molecule/cloud-aws-openjdk-ga/molecule.yml +++ b/molecule/cloud-aws-openjdk-ga/molecule.yml @@ -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 diff --git a/molecule/cloud-aws-sapjvm-8/molecule.yml b/molecule/cloud-aws-sapjvm-8/molecule.yml index 5a1dc140..970d657d 100644 --- a/molecule/cloud-aws-sapjvm-8/molecule.yml +++ b/molecule/cloud-aws-sapjvm-8/molecule.yml @@ -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 diff --git a/molecule/cloud-aws-windows-11/prepare.yml b/molecule/cloud-aws-windows-11/prepare.yml index 4f386cb9..f17975d7 100644 --- a/molecule/cloud-aws-windows-11/prepare.yml +++ b/molecule/cloud-aws-windows-11/prepare.yml @@ -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 diff --git a/molecule/resources/tests/verify.yml b/molecule/resources/tests/verify.yml index e97b1cab..b546bd06 100644 --- a/molecule/resources/tests/verify.yml +++ b/molecule/resources/tests/verify.yml @@ -3,9 +3,6 @@ hosts: all tasks: - - name: Populate service facts - service_facts: - - name: Check java command: java -version register: java_ver_cmd diff --git a/molecule/resources/tests/verify_win.yml b/molecule/resources/tests/verify_win.yml index e1177d33..79cd2426 100644 --- a/molecule/resources/tests/verify_win.yml +++ b/molecule/resources/tests/verify_win.yml @@ -1,5 +1,4 @@ --- -# This is an example playbook to execute Ansible tests. - name: Verify hosts: windows tasks: diff --git a/tasks/Linux/finalize_paths.yml b/tasks/Linux/finalize_paths.yml new file mode 100644 index 00000000..ff6220a8 --- /dev/null +++ b/tasks/Linux/finalize_paths.yml @@ -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 diff --git a/tasks/Linux/install/Debian.yml b/tasks/Linux/install/Debian.yml index 5a439c1c..59e5957c 100644 --- a/tasks/Linux/install/Debian.yml +++ b/tasks/Linux/install/Debian.yml @@ -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) }}' diff --git a/tasks/Linux/install/Debian_adoptopenjdk.yml b/tasks/Linux/install/Debian_adoptopenjdk.yml new file mode 100644 index 00000000..5472ec21 --- /dev/null +++ b/tasks/Linux/install/Debian_adoptopenjdk.yml @@ -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 diff --git a/tasks/Linux/install/RedHat.yml b/tasks/Linux/install/RedHat.yml index b39df6f3..7d673dfe 100644 --- a/tasks/Linux/install/RedHat.yml +++ b/tasks/Linux/install/RedHat.yml @@ -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) }}' diff --git a/tasks/Linux/install/RedHat_adoptopenjdk.yml b/tasks/Linux/install/RedHat_adoptopenjdk.yml new file mode 100644 index 00000000..c907de07 --- /dev/null +++ b/tasks/Linux/install/RedHat_adoptopenjdk.yml @@ -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 diff --git a/tasks/Linux/system.yml b/tasks/Linux/system.yml index 1c899585..942b93e3 100644 --- a/tasks/Linux/system.yml +++ b/tasks/Linux/system.yml @@ -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 diff --git a/tasks/Linux/system_repositories.yml b/tasks/Linux/system_repositories.yml new file mode 100644 index 00000000..2412c938 --- /dev/null +++ b/tasks/Linux/system_repositories.yml @@ -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 diff --git a/tasks/Win32NT/finalize_paths.yml b/tasks/Win32NT/finalize_paths.yml new file mode 100644 index 00000000..1fd66adb --- /dev/null +++ b/tasks/Win32NT/finalize_paths.yml @@ -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 diff --git a/tasks/Win32NT/system.yml b/tasks/Win32NT/system.yml index 3898ce02..460c2014 100644 --- a/tasks/Win32NT/system.yml +++ b/tasks/Win32NT/system.yml @@ -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 diff --git a/tasks/Win32NT/system_chocolatey.yml b/tasks/Win32NT/system_chocolatey.yml new file mode 100644 index 00000000..0c64ea40 --- /dev/null +++ b/tasks/Win32NT/system_chocolatey.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index e145b9c5..cdfd8add 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 2bb1dddb..98a8e6bc 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -1,6 +1,7 @@ --- java_package_requirements: - unzip + - tar - rsync # Variables for RHEL specific (example java-11-openjdk-devel.x86_64)