From 40738dfba6b77d3a2ddc026a1570a2f74c45942f Mon Sep 17 00:00:00 2001 From: sian Date: Mon, 11 Oct 2021 12:26:36 +0100 Subject: [PATCH] Download alternative option to copy (#15) * add compose to our molecule test image * first try - optio to download * update readme * remove db2 downloads from script * refactor db2 11.1 * remove blank line from Travis * add line to readme * add new vars to readme --- .travis.yml | 4 ++-- Dockerfile | 3 ++- molecule/db2-111-centos-7/converge.yml | 12 ------------ molecule/db2-115-centos-8/converge.yml | 12 ------------ molecule/db2111/converge.yml | 14 ++++++++++++++ .../{db2-111-centos-7 => db2111}/molecule.yml | 0 .../{db2-111-centos-7 => db2111}/verify.yml | 0 molecule/db2115/converge.yml | 14 ++++++++++++++ .../{db2-115-centos-8 => db2115}/molecule.yml | 0 .../{db2-115-centos-8 => db2115}/verify.yml | 0 roles/db2/README.md | 14 ++++++++++---- roles/db2/defaults/main.yml | 11 ++++++----- roles/db2/tasks/activate.yml | 10 ++++++++++ roles/db2/tasks/install.yml | 9 +++++++++ roles/db2/vars/v11.1.4.6.yml | 5 +++-- roles/db2/vars/v11.5.5.0.yml | 5 +++-- scripts/downloadInstaller.sh | 18 ------------------ 17 files changed, 73 insertions(+), 58 deletions(-) delete mode 100644 molecule/db2-111-centos-7/converge.yml delete mode 100644 molecule/db2-115-centos-8/converge.yml create mode 100644 molecule/db2111/converge.yml rename molecule/{db2-111-centos-7 => db2111}/molecule.yml (100%) rename molecule/{db2-111-centos-7 => db2111}/verify.yml (100%) create mode 100644 molecule/db2115/converge.yml rename molecule/{db2-115-centos-8 => db2115}/molecule.yml (100%) rename molecule/{db2-115-centos-8 => db2115}/verify.yml (100%) diff --git a/.travis.yml b/.travis.yml index 7166b5c9..903f4653 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,8 @@ env: matrix: - SCENARIO=websphere-v90-centos-8 - SCENARIO=websphere-v85-centos-7 - - SCENARIO=db2-111-centos-7 - - SCENARIO=db2-115-centos-8 + - SCENARIO=db2111 + - SCENARIO=db2115 - SCENARIO=iim-191-centos-8 - SCENARIO=iim-191-centos-8 - SCENARIO=ihs-v90-centos-8 diff --git a/Dockerfile b/Dockerfile index 7200bd34..6236c426 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM docker:dind -RUN apk add --no-cache bash \ +RUN apk update && apk add --no-cache bash \ py3-pip \ gcc \ libvirt \ @@ -36,6 +36,7 @@ RUN apk add --no-cache bash \ py3-urllib3 \ py3-virtualenv \ py3-websocket-client \ + docker-compose \ && rm -rf /var/cache/apk/* \ && pip install --upgrade pip \ && pip install --upgrade setuptools diff --git a/molecule/db2-111-centos-7/converge.yml b/molecule/db2-111-centos-7/converge.yml deleted file mode 100644 index 7ef61736..00000000 --- a/molecule/db2-111-centos-7/converge.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Converge - hosts: all - - collections: - - ibm.spm_middleware - - roles: - - db2 - - vars: - db2_version: "11.1.4.6" diff --git a/molecule/db2-115-centos-8/converge.yml b/molecule/db2-115-centos-8/converge.yml deleted file mode 100644 index 8744e79d..00000000 --- a/molecule/db2-115-centos-8/converge.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Converge - hosts: all - - collections: - - ibm.spm_middleware - - roles: - - db2 - - vars: - db2_version: "11.5.5.0" diff --git a/molecule/db2111/converge.yml b/molecule/db2111/converge.yml new file mode 100644 index 00000000..23521443 --- /dev/null +++ b/molecule/db2111/converge.yml @@ -0,0 +1,14 @@ +--- +- name: Converge + hosts: all + + collections: + - ibm.spm_middleware + + roles: + - db2 + + vars: + db2_version: "11.1.4.6" + download_url: "{{ lookup('env', 'ARTIFACTORY_URL') }}/{{ lookup('env', 'ARTIFACTORY_REPO') }}/SoftwareInstallers" + download_header: { 'X-JFrog-Art-Api': "{{ lookup('env', 'ARTIFACTORY_TOKEN') }}"} diff --git a/molecule/db2-111-centos-7/molecule.yml b/molecule/db2111/molecule.yml similarity index 100% rename from molecule/db2-111-centos-7/molecule.yml rename to molecule/db2111/molecule.yml diff --git a/molecule/db2-111-centos-7/verify.yml b/molecule/db2111/verify.yml similarity index 100% rename from molecule/db2-111-centos-7/verify.yml rename to molecule/db2111/verify.yml diff --git a/molecule/db2115/converge.yml b/molecule/db2115/converge.yml new file mode 100644 index 00000000..f94f43bf --- /dev/null +++ b/molecule/db2115/converge.yml @@ -0,0 +1,14 @@ +--- +- name: Converge + hosts: all + + collections: + - ibm.spm_middleware + + roles: + - db2 + + vars: + db2_version: "11.5.5.0" + download_url: "{{ lookup('env', 'ARTIFACTORY_URL') }}/{{ lookup('env', 'ARTIFACTORY_REPO') }}/SoftwareInstallers" + download_header: { 'X-JFrog-Art-Api': "{{ lookup('env', 'ARTIFACTORY_TOKEN') }}"} diff --git a/molecule/db2-115-centos-8/molecule.yml b/molecule/db2115/molecule.yml similarity index 100% rename from molecule/db2-115-centos-8/molecule.yml rename to molecule/db2115/molecule.yml diff --git a/molecule/db2-115-centos-8/verify.yml b/molecule/db2115/verify.yml similarity index 100% rename from molecule/db2-115-centos-8/verify.yml rename to molecule/db2115/verify.yml diff --git a/roles/db2/README.md b/roles/db2/README.md index 8ef90ddd..a9e44dda 100644 --- a/roles/db2/README.md +++ b/roles/db2/README.md @@ -8,6 +8,8 @@ The `db2` role will install IBM Db2. ## Role Variables +Ensure you update / override password variables prior to using the role. + | Property Name | Default value | | ------------------------- | --------------------------------------------------- | | `db2_install_path` | `/opt/IBM/db2` | @@ -17,15 +19,19 @@ The `db2` role will install IBM Db2. | ------------------------- | --------------------------------------------------- | | `db2_db_create` | `True` | | `db2_db_name` | `DATABASE` | -| `db2_db_username` | Environment variable: `DB2_USER` | -| `db2_db_password` | Environment variable: `DB2_PASSWORD` | -| `db2_db_spm_enc` | Environment variable: `DB2_ENC_PASSWORD` | +| `db2_db_username` | `db2admin` | +| `db2_db_password` | `db2admin` | +| `db2_db_spm_enc` | `dummyPassword` | | `db2_db_drop_required` | `False` | | ------------------------- | --------------------------------------------------- | | `bootstrap_dateformat` | `dd MM yyyy` | | `bootstrap_dateseparator` | `/` | | `bootstrap_dmx_locale` | `en_US` | | ------------------------- | --------------------------------------------------- | +| `download_url` | # set this if license and installer is being downloaded from a http server | +| `download_header` | # Use this in conjunction with `download_url` | +| ------------------------- | --------------------------------------------------- | + ## Dependencies @@ -37,7 +43,7 @@ None - hosts: servers roles: - role: ibm.spm_middleware.db2 - db2_version: 11.1.4.6 + db2_version: 11.5.5.0 ``` ## License diff --git a/roles/db2/defaults/main.yml b/roles/db2/defaults/main.yml index f310540c..24ef9162 100644 --- a/roles/db2/defaults/main.yml +++ b/roles/db2/defaults/main.yml @@ -4,14 +4,12 @@ db2_version: 11.1.4.6 db2_product: DB2_SERVER_EDITION db2_bypass_prereq_check: false db2_activate: True -db2_installer_path: /tmp/db2/db2_installer.tar.gz -db2_license_path: /tmp/db2ese_u.lic db2_db_create: True db2_db_name: DATABASE -db2_db_username: "{{ lookup('env', 'DB2_USER') }}" -db2_db_password: "{{ lookup('env', 'DB2_PASSWORD') }}" -db2_db_spm_enc: "{{ lookup('env', 'DB2_ENC_PASSWORD') }}" +db2_db_username: db2admin +db2_db_password: db2admin +db2_db_spm_enc: dummyPassword db2_db_drop_required: False bootstrap_dateformat: 'dd MM yyyy' @@ -20,3 +18,6 @@ bootstrap_dmx_locale: 'en_US' # Common profiled_path: /opt/profile.d +# Server info for downloading installers / licenses directly, leave blank to copy +download_url: # e.g. https://artifactory/repo +download_header: # e.g. X-JFrog-Art-Api: "{{ lookup('env', 'MYTOKEN') }}" diff --git a/roles/db2/tasks/activate.yml b/roles/db2/tasks/activate.yml index ed331ea5..fad23531 100644 --- a/roles/db2/tasks/activate.yml +++ b/roles/db2/tasks/activate.yml @@ -3,6 +3,16 @@ copy: src: "{{ db2_license_path }}" dest: /tmp/db2/db2server.lic + when: download_url is not defined + register: target_lic_file + +- name: Download license to target + get_url: + url: "{{ download_url }}/{{ db2_license_path }}" + dest: /tmp/db2server.lic + headers: + "{{ download_header }}" + when: download_url is defined register: target_lic_file - name: Apply license diff --git a/roles/db2/tasks/install.yml b/roles/db2/tasks/install.yml index cdf4099b..a8071c44 100644 --- a/roles/db2/tasks/install.yml +++ b/roles/db2/tasks/install.yml @@ -11,6 +11,15 @@ copy: src: "{{ db2_installer_path }}" dest: "{{ tmp_dir.path }}/db2_installer.tar.gz" + when: download_url is not defined + register: db2_installer + +- name: Download installer + get_url: + url: "{{ download_url }}/{{ db2_installer_path }}" + dest: "{{ tmp_dir.path }}/db2_installer.tar.gz" + headers: "{{ download_header }}" + when: download_url is defined register: db2_installer - name: Create tmp directory diff --git a/roles/db2/vars/v11.1.4.6.yml b/roles/db2/vars/v11.1.4.6.yml index 3ed97cd9..b4f41a2c 100644 --- a/roles/db2/vars/v11.1.4.6.yml +++ b/roles/db2/vars/v11.1.4.6.yml @@ -1,3 +1,4 @@ --- -db2_zip_path: DB2/11.1/v11.1.4fp6_linuxx64_universal_fixpack.tar.gz -db2_lic_url: DB2/11.1/db2ese_u.lic +# paths can be relative to download_url or local +db2_installer_path: DB2/11.1/v11.1.4fp6_linuxx64_universal_fixpack.tar.gz +db2_license_path: DB2/11.1/db2ese_u.lic diff --git a/roles/db2/vars/v11.5.5.0.yml b/roles/db2/vars/v11.5.5.0.yml index c5ad88d1..f6e4035f 100644 --- a/roles/db2/vars/v11.5.5.0.yml +++ b/roles/db2/vars/v11.5.5.0.yml @@ -1,3 +1,4 @@ --- -db2_zip_path: DB2/11.5/v11.5.5fp0_linuxx64_universal_fixpack.tar.gz -db2_lic_url: DB2/11.5/db2ese_u.lic +# paths can be relative to download_url or local +db2_installer_path: DB2/11.5/v11.5.5fp0_linuxx64_universal_fixpack.tar.gz +db2_license_path: DB2/11.5/db2ese_u.lic diff --git a/scripts/downloadInstaller.sh b/scripts/downloadInstaller.sh index bb834c9f..49b8c1af 100644 --- a/scripts/downloadInstaller.sh +++ b/scripts/downloadInstaller.sh @@ -1,23 +1,5 @@ #!/bin/bash echo service is $1 -# DB2 -if [ "$1" = "default" ]; then - echo db2111 - mkdir -p /tmp/db2/ - curl -H "X-JFrog-Art-Api: ${ARTIFACTORY_TOKEN}" -k ${ARTIFACTORY_URL}/${ARTIFACTORY_REPO}/SoftwareInstallers/DB2/11.1/v11.1.4fp6_linuxx64_universal_fixpack.tar.gz -o /tmp/db2/db2_installer.tar.gz - curl -H "X-JFrog-Art-Api: ${ARTIFACTORY_TOKEN}" -k ${ARTIFACTORY_URL}/${ARTIFACTORY_REPO}/SoftwareInstallers/DB2/11.1/db2ese_u.lic -o /tmp/db2ese_u.lic -elif [ "$1" = "db2-111-centos-7" ]; then - echo db2111 - mkdir -p /tmp/db2/ - curl -H "X-JFrog-Art-Api: ${ARTIFACTORY_TOKEN}" -k ${ARTIFACTORY_URL}/${ARTIFACTORY_REPO}/SoftwareInstallers/DB2/11.1/v11.1.4fp6_linuxx64_universal_fixpack.tar.gz -o /tmp/db2/db2_installer.tar.gz - curl -H "X-JFrog-Art-Api: ${ARTIFACTORY_TOKEN}" -k ${ARTIFACTORY_URL}/${ARTIFACTORY_REPO}/SoftwareInstallers/DB2/11.1/db2ese_u.lic -o /tmp/db2ese_u.lic -elif [ "$1" = "db2-115-centos-8" ]; then - echo db2115 - mkdir -p /tmp/db2/ - curl -H "X-JFrog-Art-Api: ${ARTIFACTORY_TOKEN}" -k ${ARTIFACTORY_URL}/${ARTIFACTORY_REPO}/SoftwareInstallers/DB2/11.5/v11.5.5fp0_linuxx64_universal_fixpack.tar.gz -o /tmp/db2/db2_installer.tar.gz - curl -H "X-JFrog-Art-Api: ${ARTIFACTORY_TOKEN}" -k ${ARTIFACTORY_URL}/${ARTIFACTORY_REPO}/SoftwareInstallers/DB2/11.5/db2ese_u.lic -o /tmp/db2ese_u.lic -fi - # IIM if [ "$1" = "iim-191-centos-8" ]; then echo "Download IIM installer"