From f3781369926adcae7160566105d291749006a37b Mon Sep 17 00:00:00 2001 From: Aliaksandr Padrabinkin <46869350+y6vmeq@users.noreply.github.com> Date: Mon, 21 Oct 2019 20:59:11 +0300 Subject: [PATCH] Add SapMachine: EPMLDI-1738 (#97) (#98) * Add SapMachine (Linux): EPMLDI-1738 (#97) * fix tests: EPMLDI-1738 (#97) * fix s3: EPMLDI-1738 (#97) * add win: EPMLDI-1738 (#97) * fix verison: EPMLDI-1738 (#97) * fix tag for gitlab-ci: EPMLDI-1738 (#97) --- .gitlab-ci.yml | 45 +++++ README.md | 27 ++- defaults/main.yml | 5 +- .../cloud-aws-adoptopenjdk-12/prepare.yml | 17 -- molecule/cloud-aws-sapmachine-10/molecule.yml | 138 ++++++++++++++++ molecule/cloud-aws-sapmachine-10/playbook.yml | 5 + molecule/cloud-aws-sapmachine-10/prepare.yml | 61 +++++++ molecule/cloud-aws-sapmachine-11/molecule.yml | 135 +++++++++++++++ molecule/cloud-aws-sapmachine-11/playbook.yml | 5 + molecule/cloud-aws-sapmachine-12/molecule.yml | 134 +++++++++++++++ molecule/cloud-aws-sapmachine-12/playbook.yml | 5 + molecule/cloud-aws-sapmachine-12/prepare.yml | 54 ++++++ molecule/cloud-aws-sapmachine-13/molecule.yml | 138 ++++++++++++++++ molecule/cloud-aws-sapmachine-13/playbook.yml | 5 + molecule/cloud-aws-sapmachine-13/prepare.yml | 61 +++++++ .../cloud-aws-sapmachine-windows/molecule.yml | 155 ++++++++++++++++++ .../cloud-aws-sapmachine-windows/playbook.yml | 5 + tasks/Linux/fetch/sapmachine-fallback.yml | 38 +++++ tasks/Win32NT/fetch/sapmachine-fallback.yml | 40 +++++ tasks/Win32NT/install/sapmachine_tarball.yml | 36 ++++ vars/java_distro_configs/sapmachine_vars.yml | 20 +++ vars/main.yml | 1 + 22 files changed, 1111 insertions(+), 19 deletions(-) create mode 100644 molecule/cloud-aws-sapmachine-10/molecule.yml create mode 100644 molecule/cloud-aws-sapmachine-10/playbook.yml create mode 100644 molecule/cloud-aws-sapmachine-10/prepare.yml create mode 100644 molecule/cloud-aws-sapmachine-11/molecule.yml create mode 100644 molecule/cloud-aws-sapmachine-11/playbook.yml create mode 100644 molecule/cloud-aws-sapmachine-12/molecule.yml create mode 100644 molecule/cloud-aws-sapmachine-12/playbook.yml create mode 100644 molecule/cloud-aws-sapmachine-12/prepare.yml create mode 100644 molecule/cloud-aws-sapmachine-13/molecule.yml create mode 100644 molecule/cloud-aws-sapmachine-13/playbook.yml create mode 100644 molecule/cloud-aws-sapmachine-13/prepare.yml create mode 100644 molecule/cloud-aws-sapmachine-windows/molecule.yml create mode 100644 molecule/cloud-aws-sapmachine-windows/playbook.yml create mode 100644 tasks/Linux/fetch/sapmachine-fallback.yml create mode 100644 tasks/Win32NT/fetch/sapmachine-fallback.yml create mode 100644 tasks/Win32NT/install/sapmachine_tarball.yml create mode 100644 vars/java_distro_configs/sapmachine_vars.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4773c74a..b32944bd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -249,3 +249,48 @@ AWS adoptopenjdk Windows: - molecule test -s cloud-aws-adoptopenjdk-windows tags: - aws + +AWS sapmachine-10: + variables: + AWS_REGION: us-east-1 + stage: deployment test + script: + - molecule test -s cloud-aws-sapmachine-10 + tags: + - aws + +AWS sapmachine-11: + variables: + AWS_REGION: us-east-1 + stage: deployment test + script: + - molecule test -s cloud-aws-sapmachine-11 + tags: + - aws + +AWS sapmachine-12: + variables: + AWS_REGION: us-east-1 + stage: deployment test + script: + - molecule test -s cloud-aws-sapmachine-12 + tags: + - aws + +AWS sapmachine-13: + variables: + AWS_REGION: us-east-1 + stage: deployment test + script: + - molecule test -s cloud-aws-sapmachine-13 + tags: + - aws + +AWS sapmachine-windows: + variables: + AWS_REGION: us-east-1 + stage: deployment test + script: + - molecule test -s cloud-aws-sapmachine-windows + tags: + - aws diff --git a/README.md b/README.md index ea5f9927..7c1d3f30 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,12 @@ This Ansible role has the following features for: - Install JDK, JRE - Additional opportunity to install from adoptopenjdk-fallback, repositories, web, local source, s3, chocolatey. + +**SapMachine** + +- Install JDK, JRE +- Additional opportunity to install from sapmachine-fallback, web, local source, s3. + DISCLAIMER: usage of any version of this role implies you have accepted the [Oracle Binary Code License Agreement for Java SE](http://www.oracle.com/technetwork/java/javase/terms/license/index.html). @@ -89,6 +95,11 @@ Requirements - 11 - 12 - 13 + - **Supported SapMachine version**: + - 10 + - 11 + - 12 + - 13 - **Supported OS**: - Ubuntu - bionic @@ -112,6 +123,7 @@ Requirements - `sapjvm` - `zulu` - `adoptopenjdk` + - `sapmachine` **Notice**: this variable is mandatory in case of installing other distribution than 'openjdk'. @@ -121,7 +133,7 @@ Requirements - `jdk` (default) - `jre` - - `transport` Artifact source transport. Use `openjdk-fallback`(OpenJDK only), `repositories`(OpenJDK only), `sapjvm-fallback`(SAPJVM only), `adoptopenjdk-fallback`(AdoptOpenJDK only), `zulu-fallback`(ZULU only), `local`, `web` or `s3` for more predictable result. + - `transport` Artifact source transport. Use `openjdk-fallback`(OpenJDK only), `repositories`(OpenJDK only), `sapjvm-fallback`(SAPJVM only), `adoptopenjdk-fallback`(AdoptOpenJDK only),`sapmachine-fallback`(SapMachine only), `zulu-fallback`(ZULU only), `local`, `web` or `s3` for more predictable result. Available: - `repositories` Installing OpenJDK java from system repositories (yum or apt, Linux only) @@ -132,6 +144,7 @@ Requirements - `sapjvm-fallback` fetching artifact from SAP site. - `zulu-fallback` fetching artifact from AZUL site. - `adoptopenjdk-fallback` fetching artifact from adoptopenjdk site. + - `sapmachine-fallback` fetching artifact from SapMachine site. - `openjdk-fallback` fetching artifact from jdk.java.net. This is default value for `transport` variable @@ -318,6 +331,18 @@ https://docs.ansible.com/ansible/latest/modules/aws_s3_module.html#requirements adoptopenjdk_impl: openj9 java_major_version: 8 ``` +### Installing SapMachine sapmachine-jre-10 from sapmachine-fallback: +```yaml +- name: Install SapMachine + hosts: all + + roles: + - role: lean_delivery.java + java_distribution: sapmachine + transport: sapmachine-fallback + java_package: jre + java_major_version: 10 +``` License ------- diff --git a/defaults/main.yml b/defaults/main.yml index 8eb9ebc5..a7121775 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,17 +5,19 @@ # - sapjvm # - zulu # - adoptopenjdk (not supported 9/10) +# - sapmachine (suported only 10/11/12/13) java_distribution: openjdk # OpenJDK tarball supported only jdk # Oracle java supported jre/server-jre/jdk # AdoptOpenJDK supported jdk/jre +# SapMachine supported jdk/jre java_package: jdk # AdoptOpenJDK Implementation (hotspot/openj9) adoptopenjdk_impl: hotspot -# OpenJDK Redhat: 8 (packages) / 11 (package for centos7, tarball for all other) / 12 (tarball) +# OpenJDK Redhat: 8 (packages) / 11 (package for centos7, tarball for all other) / 12 (tarball) # OpenJDK Debian: 8 (packages) / 11 (package for ubuntu18, tarball for all other) / 12 (tarball) # Oracle java: 8 (jre/server-jre/jdk) / 11 (jdk) java_major_version: 12 @@ -46,6 +48,7 @@ transport: openjdk-fallback # - "adoptopenjdk-fallback" Install from artifact downloaded from adoptopenjdk site # - "sapjvm-fallback" Install from artifact downloaded from SAP site # - "zulu-fallback" Install from artifact downloaded from AZUL site +# - "sapmachine-fallback" Install from artifact downloaded from SapMachine site transport_web: '{{ transport_web_default }}' transport_local: "/tmp/openjdk-11.0.2_linux-x64_bin.tar.gz" diff --git a/molecule/cloud-aws-adoptopenjdk-12/prepare.yml b/molecule/cloud-aws-adoptopenjdk-12/prepare.yml index 240ef69e..b678b91c 100644 --- a/molecule/cloud-aws-adoptopenjdk-12/prepare.yml +++ b/molecule/cloud-aws-adoptopenjdk-12/prepare.yml @@ -59,20 +59,3 @@ register: status until: status is succeeded become: true - -- name: Prepare host to S3 transport - hosts: localhost - vars: - transport_s3_bucket: java-molecule-s3-test - transport_s3_path: /java/adoptopenjdk/OpenJDK12U-jdk_x64_linux_hotspot_12.0.1_12.tar.gz - java_download_path: /tmp - tasks: - - name: Download artifact from s3 - aws_s3: - bucket: '{{ transport_s3_bucket }}' - object: '{{ transport_s3_path }}' - dest: '{{ java_download_path }}/{{ transport_s3_path | basename }}' - mode: get - overwrite: different - retries: 5 - delay: 2 diff --git a/molecule/cloud-aws-sapmachine-10/molecule.yml b/molecule/cloud-aws-sapmachine-10/molecule.yml new file mode 100644 index 00000000..66d9ad23 --- /dev/null +++ b/molecule/cloud-aws-sapmachine-10/molecule.yml @@ -0,0 +1,138 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml +driver: + name: ec2 +lint: + name: yamllint + options: + config-file: .yamllint +platforms: + - name: test-aws-centos7-sapmachine-jdk-tarball-10 + image: ami-9887c6e7 + platform: centos7 + 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 + - sapmachine + - jdk + - sapmachine_fallback + + - name: test-aws-centos8-sapmachine-jre-tarball-10 + 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 + - sapmachine + - jre + - sapmachine_fallback + + - name: test-aws-Debian9-sapmachine-jre-tarball-10 + image: ami-003f19e0e687de1cd + platform: debian9 + 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: admin + groups: + - debian_family + - sapmachine + - jre + - sapmachine_fallback + + - name: test-aws-ubuntu18-sapmachine-jdk-tarball-10 + image: ami-012fd5eb46f56731f + platform: ubuntu18 + 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: ubuntu + groups: + - debian_family + - sapmachine + - jdk + - sapmachine_fallback + + - name: test-aws-ubuntu18-sapmachine-s3-10 + image: ami-012fd5eb46f56731f + profile_name: epmldi-instance-profile + platform: ubuntu18 + 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: ubuntu + groups: + - debian_family + - sapmachine + - s3 + +provisioner: + name: ansible + log: false + config_options: + defaults: + callback_whitelist: profile_tasks,timer + inventory: + group_vars: + sapmachine: + java_distribution: sapmachine + java_major_version: 10 + jdk: + java_package: jdk + jre: + java_package: jre + sapmachine_fallback: + transport: sapmachine-fallback + s3: + transport: s3 + transport_s3_bucket: java-molecule-s3-test + transport_s3_path: /java/sapmachine/sapmachine-jdk-10.0.2.13_linux-x64_bin.tar.gz + transport_s3_aws_access_key: "{{ lookup('env','AWS_ACCESS_KEY_ID') }}" + transport_s3_aws_secret_key: "{{ lookup('env','AWS_SECRET_ACCESS_KEY') }}" + playbooks: + create: ../resources/provisioning/AWS/create.yml + prepare: ../cloud-aws-sapmachine-10/prepare.yml + destroy: ../resources/provisioning/AWS/destroy.yml + verify: ../resources/tests/verify.yml + lint: + name: ansible-lint +scenario: + name: cloud-aws-sapmachine-10 +verifier: + name: ansible + lint: + name: ansible-lint diff --git a/molecule/cloud-aws-sapmachine-10/playbook.yml b/molecule/cloud-aws-sapmachine-10/playbook.yml new file mode 100644 index 00000000..2bd7212e --- /dev/null +++ b/molecule/cloud-aws-sapmachine-10/playbook.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: ansible-role-java diff --git a/molecule/cloud-aws-sapmachine-10/prepare.yml b/molecule/cloud-aws-sapmachine-10/prepare.yml new file mode 100644 index 00000000..42665300 --- /dev/null +++ b/molecule/cloud-aws-sapmachine-10/prepare.yml @@ -0,0 +1,61 @@ +--- +- name: Include common prepare + import_playbook: ../resources/provisioning/AWS/prepare.yml + +- name: Prepare Debian + hosts: debian_family + tasks: + + - 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: + + - name: Enable EPEL repository + yum: + name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-\ + {{ ansible_distribution_major_version }}.noarch.rpm" + state: 'present' + register: status + until: status is succeeded + become: true + +- name: Prepare host to S3 transport + hosts: s3 + tasks: + + - name: Install pip package + package: + name: 'python-pip' + state: present + register: status + until: status is succeeded + become: true + + - name: Install boto module + pip: + name: + - botocore + - boto + - boto3 + state: present + executable: 'pip' + extra_args: --upgrade + register: status + until: status is succeeded + become: true diff --git a/molecule/cloud-aws-sapmachine-11/molecule.yml b/molecule/cloud-aws-sapmachine-11/molecule.yml new file mode 100644 index 00000000..964d7619 --- /dev/null +++ b/molecule/cloud-aws-sapmachine-11/molecule.yml @@ -0,0 +1,135 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml +driver: + name: ec2 +lint: + name: yamllint + options: + config-file: .yamllint +platforms: + - name: test-aws-centos7-sapmachine-jdk-tarball-11 + image: ami-9887c6e7 + platform: centos7 + 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 + - sapmachine + - jdk + - sapmachine_fallback + + - name: test-aws-centos8-sapmachine-jre-tarball-11 + 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 + - sapmachine + - jre + - sapmachine_fallback + + - name: test-aws-Debian9-sapmachine-jre-tarball-11 + image: ami-003f19e0e687de1cd + platform: debian9 + 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: admin + groups: + - debian_family + - sapmachine + - jre + - sapmachine_fallback + + - name: test-aws-ubuntu18-sapmachine-jdk-tarball-11 + image: ami-012fd5eb46f56731f + platform: ubuntu18 + 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: ubuntu + groups: + - debian_family + - sapmachine + - jdk + - sapmachine_fallback + + - name: test-aws-centos7-sapmachine-web-11 + image: ami-9887c6e7 + platform: centos7 + 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 + - sapmachine + - web + +provisioner: + name: ansible + log: false + config_options: + defaults: + callback_whitelist: profile_tasks,timer + inventory: + group_vars: + sapmachine: + java_distribution: sapmachine + java_major_version: 11 + jdk: + java_package: jdk + jre: + java_package: jre + sapmachine_fallback: + transport: sapmachine-fallback + web: + transport: web + transport_web: >- + https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.5/sapmachine-jdk-11.0.5_linux-x64_bin.tar.gz + playbooks: + create: ../resources/provisioning/AWS/create.yml + prepare: ../resources/provisioning/AWS/prepare.yml + destroy: ../resources/provisioning/AWS/destroy.yml + verify: ../resources/tests/verify.yml + lint: + name: ansible-lint +scenario: + name: cloud-aws-sapmachine-11 +verifier: + name: ansible + lint: + name: ansible-lint diff --git a/molecule/cloud-aws-sapmachine-11/playbook.yml b/molecule/cloud-aws-sapmachine-11/playbook.yml new file mode 100644 index 00000000..2bd7212e --- /dev/null +++ b/molecule/cloud-aws-sapmachine-11/playbook.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: ansible-role-java diff --git a/molecule/cloud-aws-sapmachine-12/molecule.yml b/molecule/cloud-aws-sapmachine-12/molecule.yml new file mode 100644 index 00000000..f6ab7ede --- /dev/null +++ b/molecule/cloud-aws-sapmachine-12/molecule.yml @@ -0,0 +1,134 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml +driver: + name: ec2 +lint: + name: yamllint + options: + config-file: .yamllint +platforms: + - name: test-aws-centos7-sapmachine-jdk-tarball-12 + image: ami-9887c6e7 + platform: centos7 + 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 + - sapmachine + - jdk + - sapmachine_fallback + + - name: test-aws-centos8-sapmachine-jre-tarball-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 + - sapmachine + - jre + - sapmachine_fallback + + - name: test-aws-Debian9-sapmachine-jre-tarball-12 + image: ami-003f19e0e687de1cd + platform: debian9 + 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: admin + groups: + - debian_family + - sapmachine + - jre + - sapmachine_fallback + + - name: test-aws-ubuntu18-sapmachine-jdk-tarball-12 + image: ami-012fd5eb46f56731f + platform: ubuntu18 + 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: ubuntu + groups: + - debian_family + - sapmachine + - jdk + - sapmachine_fallback + + - name: test-aws-centos8-sapmachine-local-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 + - sapmachine + - local + +provisioner: + name: ansible + log: false + config_options: + defaults: + callback_whitelist: profile_tasks,timer + inventory: + group_vars: + sapmachine: + java_distribution: sapmachine + java_major_version: 12 + jdk: + java_package: jdk + jre: + java_package: jre + sapmachine_fallback: + transport: sapmachine-fallback + local: + transport: local + transport_local: /tmp/sapmachine-jdk-12.0.2_linux-x64_bin.tar.gz + playbooks: + create: ../resources/provisioning/AWS/create.yml + prepare: ../cloud-aws-sapmachine-12/prepare.yml + destroy: ../resources/provisioning/AWS/destroy.yml + verify: ../resources/tests/verify.yml + lint: + name: ansible-lint +scenario: + name: cloud-aws-sapmachine-12 +verifier: + name: ansible + lint: + name: ansible-lint diff --git a/molecule/cloud-aws-sapmachine-12/playbook.yml b/molecule/cloud-aws-sapmachine-12/playbook.yml new file mode 100644 index 00000000..2bd7212e --- /dev/null +++ b/molecule/cloud-aws-sapmachine-12/playbook.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: ansible-role-java diff --git a/molecule/cloud-aws-sapmachine-12/prepare.yml b/molecule/cloud-aws-sapmachine-12/prepare.yml new file mode 100644 index 00000000..6149938f --- /dev/null +++ b/molecule/cloud-aws-sapmachine-12/prepare.yml @@ -0,0 +1,54 @@ +--- +- name: Include common prepare + import_playbook: ../resources/provisioning/AWS/prepare.yml + +- name: Prepare Debian + hosts: debian_family + tasks: + + - 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: + + - name: Enable EPEL repository + yum: + name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-\ + {{ ansible_distribution_major_version }}.noarch.rpm" + state: 'present' + 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/sapmachine/sapmachine-jdk-12.0.2_linux-x64_bin.tar.gz + java_download_path: /tmp + tasks: + - name: Download artifact from s3 + aws_s3: + bucket: '{{ transport_s3_bucket }}' + object: '{{ transport_s3_path }}' + dest: '{{ java_download_path }}/{{ transport_s3_path | basename }}' + mode: get + overwrite: different + retries: 5 + delay: 2 diff --git a/molecule/cloud-aws-sapmachine-13/molecule.yml b/molecule/cloud-aws-sapmachine-13/molecule.yml new file mode 100644 index 00000000..bf0336b7 --- /dev/null +++ b/molecule/cloud-aws-sapmachine-13/molecule.yml @@ -0,0 +1,138 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml +driver: + name: ec2 +lint: + name: yamllint + options: + config-file: .yamllint +platforms: + - name: test-aws-centos7-sapmachine-jdk-tarball-13 + image: ami-9887c6e7 + platform: centos7 + 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 + - sapmachine + - jdk + - sapmachine_fallback + + - name: test-aws-centos8-sapmachine-jre-tarball-13 + 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 + - sapmachine + - jre + - sapmachine_fallback + + - name: test-aws-Debian9-sapmachine-jre-tarball-13 + image: ami-003f19e0e687de1cd + platform: debian9 + 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: admin + groups: + - debian_family + - sapmachine + - jre + - sapmachine_fallback + + - name: test-aws-ubuntu18-sapmachine-jdk-tarball-13 + image: ami-012fd5eb46f56731f + platform: ubuntu18 + 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: ubuntu + groups: + - debian_family + - sapmachine + - jdk + - sapmachine_fallback + + - name: test-aws-Debian9-sapmachine-s3-13 + image: ami-003f19e0e687de1cd + profile_name: epmldi-instance-profile + platform: debian9 + 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: admin + groups: + - debian_family + - sapmachine + - s3 + +provisioner: + name: ansible + log: false + config_options: + defaults: + callback_whitelist: profile_tasks,timer + inventory: + group_vars: + sapmachine: + java_distribution: sapmachine + java_major_version: 13 + jdk: + java_package: jdk + jre: + java_package: jre + sapmachine_fallback: + transport: sapmachine-fallback + s3: + transport: s3 + transport_s3_bucket: java-molecule-s3-test + transport_s3_path: /java/sapmachine/sapmachine-jdk-13.0.1_linux-x64_bin.tar.gz + transport_s3_aws_access_key: "{{ lookup('env','AWS_ACCESS_KEY_ID') }}" + transport_s3_aws_secret_key: "{{ lookup('env','AWS_SECRET_ACCESS_KEY') }}" + playbooks: + create: ../resources/provisioning/AWS/create.yml + prepare: ../cloud-aws-sapmachine-13/prepare.yml + destroy: ../resources/provisioning/AWS/destroy.yml + verify: ../resources/tests/verify.yml + lint: + name: ansible-lint +scenario: + name: cloud-aws-sapmachine-13 +verifier: + name: ansible + lint: + name: ansible-lint diff --git a/molecule/cloud-aws-sapmachine-13/playbook.yml b/molecule/cloud-aws-sapmachine-13/playbook.yml new file mode 100644 index 00000000..2bd7212e --- /dev/null +++ b/molecule/cloud-aws-sapmachine-13/playbook.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: ansible-role-java diff --git a/molecule/cloud-aws-sapmachine-13/prepare.yml b/molecule/cloud-aws-sapmachine-13/prepare.yml new file mode 100644 index 00000000..42665300 --- /dev/null +++ b/molecule/cloud-aws-sapmachine-13/prepare.yml @@ -0,0 +1,61 @@ +--- +- name: Include common prepare + import_playbook: ../resources/provisioning/AWS/prepare.yml + +- name: Prepare Debian + hosts: debian_family + tasks: + + - 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: + + - name: Enable EPEL repository + yum: + name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-\ + {{ ansible_distribution_major_version }}.noarch.rpm" + state: 'present' + register: status + until: status is succeeded + become: true + +- name: Prepare host to S3 transport + hosts: s3 + tasks: + + - name: Install pip package + package: + name: 'python-pip' + state: present + register: status + until: status is succeeded + become: true + + - name: Install boto module + pip: + name: + - botocore + - boto + - boto3 + state: present + executable: 'pip' + extra_args: --upgrade + register: status + until: status is succeeded + become: true diff --git a/molecule/cloud-aws-sapmachine-windows/molecule.yml b/molecule/cloud-aws-sapmachine-windows/molecule.yml new file mode 100644 index 00000000..a3d2f505 --- /dev/null +++ b/molecule/cloud-aws-sapmachine-windows/molecule.yml @@ -0,0 +1,155 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml +driver: + name: ec2 +lint: + name: yamllint + options: + config-file: .yamllint +platforms: + - name: test-aws-windows2016-sapmachine-tarball-11 + aws_image_id: ami-00a20f508263efd30 + platform: windows2016core + aws_region: us-east-1 + instance_type: m5.large + assign_public_ip: false + spot_price: 0.14 + aws_sec_group: + - default + vpc_subnet_id: subnet-0f2b9cd66faea38af + groups: + - windows + - sapmachine + - jdk + - sapmachine_fallback + - ver11 + + - name: test-aws-windows2019-sapmachine-tarball-11 + aws_image_id: ami-0477b9335a5a75438 + platform: windows2019core + aws_region: us-east-1 + instance_type: m5.large + assign_public_ip: false + spot_price: 0.14 + aws_sec_group: + - default + vpc_subnet_id: subnet-0f2b9cd66faea38af + groups: + - windows + - sapmachine + - jre + - sapmachine_fallback + - ver11 + + - name: test-aws-windows2016-sapmachine-tarball-12 + aws_image_id: ami-00a20f508263efd30 + platform: windows2016core + aws_region: us-east-1 + instance_type: m5.large + assign_public_ip: false + spot_price: 0.14 + aws_sec_group: + - default + vpc_subnet_id: subnet-0f2b9cd66faea38af + groups: + - windows + - sapmachine + - jdk + - sapmachine_fallback + - ver12 + + - name: test-aws-windows2019-sapmachine-tarball-12 + aws_image_id: ami-0477b9335a5a75438 + platform: windows2019core + aws_region: us-east-1 + instance_type: m5.large + assign_public_ip: false + spot_price: 0.14 + aws_sec_group: + - default + vpc_subnet_id: subnet-0f2b9cd66faea38af + groups: + - windows + - sapmachine + - jre + - sapmachine_fallback + - ver12 + + - name: test-aws-windows2016-sapmachine-tarball-13 + aws_image_id: ami-00a20f508263efd30 + platform: windows2016core + aws_region: us-east-1 + instance_type: m5.large + assign_public_ip: false + spot_price: 0.14 + aws_sec_group: + - default + vpc_subnet_id: subnet-0f2b9cd66faea38af + groups: + - windows + - sapmachine + - jdk + - sapmachine_fallback + - ver11 + + - name: test-aws-windows2019-sapmachine-tarball-13 + aws_image_id: ami-0477b9335a5a75438 + platform: windows2019core + aws_region: us-east-1 + instance_type: m5.large + assign_public_ip: false + spot_price: 0.14 + aws_sec_group: + - default + vpc_subnet_id: subnet-0f2b9cd66faea38af + groups: + - windows + - sapmachine + - jre + - sapmachine_fallback + - ver13 + +provisioner: + name: ansible + log: false + inventory: + group_vars: + sapmachine: + java_distribution: sapmachine + ver11: + java_major_version: 11 + ver12: + java_major_version: 12 + ver13: + java_major_version: 13 + jdk: + java_package: jdk + jre: + java_package: jre + sapmachine_fallback: + transport: sapmachine-fallback + chocolatey: + transport: chocolatey + windows: + ansible_password: "{{ lookup('env', 'WINRM_ADMIN_PWD') | default('M0leCule123!', true) }}" + ansible_winrm_transport: credssp + ansible_winrm_server_cert_validation: ignore + ansible_connection: winrm + playbooks: + create: ../resources/provisioning/AWS/create.yml + destroy: ../resources/provisioning/AWS/destroy.yml + verify: ../resources/tests/verify_win.yml + config_options: + defaults: + callback_whitelist: profile_tasks,timer + lint: + name: ansible-lint +scenario: + name: cloud-aws-sapmachine-windows +verifier: + name: ansible + lint: + name: ansible-lint diff --git a/molecule/cloud-aws-sapmachine-windows/playbook.yml b/molecule/cloud-aws-sapmachine-windows/playbook.yml new file mode 100644 index 00000000..2bd7212e --- /dev/null +++ b/molecule/cloud-aws-sapmachine-windows/playbook.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: ansible-role-java diff --git a/tasks/Linux/fetch/sapmachine-fallback.yml b/tasks/Linux/fetch/sapmachine-fallback.yml new file mode 100644 index 00000000..11162ae2 --- /dev/null +++ b/tasks/Linux/fetch/sapmachine-fallback.yml @@ -0,0 +1,38 @@ +--- +- name: 'Fetch version page' + uri: + url: 'https://sap.github.io/SapMachine/latest/{{ java_major_version }}' + return_content: true + follow_redirects: all + register: version_page + +- name: Find release version + set_fact: + full_version: >- + {{ version_page.content | regex_findall('(1.*[.|-]\d)') + + version_page.content | regex_findall('(1.*[.|\d]\d)') }} + +- name: 'Fetch artifact checksum file' + uri: + url: "{{ sapmachine_root_page }}{{ java_distribution }}-{{ full_version[0] }}/\ + {{ java_distribution }}-{{ java_package }}-{{ full_version[-1] | replace('%2B','.') }}\ + _linux-x64_bin.sha256.txt" + return_content: true + register: artifact_checksum_file + +- name: Find artifact checksum + set_fact: + artifact_checksum: >- + {{ artifact_checksum_file.content | regex_search('(^\w*)') }} + +- name: 'Download artifact' + get_url: + url: "{{ sapmachine_root_page }}{{ java_distribution }}-{{ full_version[0] }}/\ + {{ java_distribution }}-{{ java_package }}-{{ full_version[-1] | replace('%2B','.') }}\ + _linux-x64_bin.tar.gz" + dest: '{{ java_download_path }}' + checksum: 'sha256:{{ artifact_checksum }}' + register: file_downloaded + retries: 20 + delay: 5 + until: file_downloaded is succeeded diff --git a/tasks/Win32NT/fetch/sapmachine-fallback.yml b/tasks/Win32NT/fetch/sapmachine-fallback.yml new file mode 100644 index 00000000..0c54778d --- /dev/null +++ b/tasks/Win32NT/fetch/sapmachine-fallback.yml @@ -0,0 +1,40 @@ +--- +- name: 'Fetch version page' + win_uri: + url: 'https://sap.github.io/SapMachine/latest/{{ java_major_version }}' + return_content: true + follow_redirects: all + register: version_page + +- name: Find release version + set_fact: + full_version: >- + {{ version_page.content | regex_findall('(1.*[.|-]\d)') + + version_page.content | regex_findall('(1.*[.|\d]\d)') }} + +- name: 'Fetch artifact checksum file' + win_uri: + url: "{{ sapmachine_root_page }}{{ java_distribution }}-{{ full_version[0] }}/\ + {{ java_distribution }}-{{ java_package }}-{{ full_version[-1] | replace('%2B','.') }}\ + _windows-x64_bin.sha256.txt" + return_content: true + register: artifact_checksum_file + +- name: Find artifact checksum + set_fact: + artifact_checksum: >- + {{ artifact_checksum_file.content | regex_search('(^\w*)') }} + +- name: 'Download artifact' + win_get_url: + url: "{{ sapmachine_root_page }}{{ java_distribution }}-{{ full_version[0] }}/\ + {{ java_distribution }}-{{ java_package }}-{{ full_version[-1] | replace('%2B','.') }}\ + _windows-x64_bin.zip" + dest: '{{ java_download_path }}' + force: true + checksum: '{{ artifact_checksum }}' + checksum_algorithm: sha256 + register: file_downloaded + retries: 20 + delay: 5 + until: file_downloaded is succeeded diff --git a/tasks/Win32NT/install/sapmachine_tarball.yml b/tasks/Win32NT/install/sapmachine_tarball.yml new file mode 100644 index 00000000..548a4ad8 --- /dev/null +++ b/tasks/Win32NT/install/sapmachine_tarball.yml @@ -0,0 +1,36 @@ +--- +- name: Check that the java_folder exists + win_stat: + path: '{{ java_path }}\{{ java_folder }}/bin' + register: java_folder_bin + +- name: Install java from tarball + block: + - name: Mkdir for java installation + win_file: + path: '{{ java_path }}\{{ java_folder }}' + state: directory + + - name: Create temporary directory + win_tempfile: + state: directory + register: temp_dir_path + + - name: Unarchive to temporary directory + win_unzip: + src: '{{ java_artifact }}' + dest: '{{ temp_dir_path }}' + + - name: Find java_folder in temp + win_find: + paths: '{{ temp_dir_path }}' + recurse: false + file_type: directory + register: java_temp_folder + + - name: Copy from temporary directory + win_copy: + src: '{{ java_temp_folder.files | map(attribute="path") | list | last }}\' + dest: '{{ java_path }}\{{ java_folder }}' + remote_src: true + when: not java_folder_bin.stat.exists diff --git a/vars/java_distro_configs/sapmachine_vars.yml b/vars/java_distro_configs/sapmachine_vars.yml new file mode 100644 index 00000000..5ba95d2b --- /dev/null +++ b/vars/java_distro_configs/sapmachine_vars.yml @@ -0,0 +1,20 @@ +--- +parts: >- + {{ java_artifact_basename + | regex_findall('^.*(j[dkre]{2})-([0-9]+)\.?([0-9.]+)?[-_]([a-z]+)-(x64|i586).*') + | first | list }} + +java_package_suffix: >- + {{ (java_major_version == 11) | ternary(java_major_version, '') }} + +choco_java_package: 'openjdk{{ java_package_suffix }}' + +choco_path: 'C:\Program Files\OpenJDK' + +java_folder_ext_transport: >- + {{ ((java_minor_version | default('') | string).find('*') != -1) + | ternary(java_package + '-' + java_major_version|string, + java_def_folder_ext_transport) }} + +java_folder: >- + {{ (not java_tarball_install | bool and (ansible_system == 'Linux')) | ternary(java_folder_repo_transport, java_folder_ext_transport) }} diff --git a/vars/main.yml b/vars/main.yml index 5998a1a7..5f462033 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -3,6 +3,7 @@ openjdk_root_page: https://jdk.java.net sapjvm_root_page: https://tools.hana.ondemand.com adoptopenjdk_api_page: https://api.adoptopenjdk.net/v2/ zulu_api_page: https://zulu.api.azul.com/api/v1/ +sapmachine_root_page: https://github.com/SAP/SapMachine/releases/download/ # vars file for java transport_web_default: https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz