Skip to content

Commit

Permalink
Merge pull request #243 from IBM/cpd-460
Browse files Browse the repository at this point in the history
OLM patching and Cloud Pak for Data 4.6 support
  • Loading branch information
arthurlaimbock authored Dec 6, 2022
2 parents 5944a99 + 55c34d5 commit 519220b
Show file tree
Hide file tree
Showing 27 changed files with 463 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,6 @@
remote_src: True
mode: u+rwx

- set_fact:
_cp4d_cartridges_installed_successfully: True

- name: Write cartridge information to file {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-cartridges.json
copy:
content: "{{ _cartridges_to_install | default([]) | to_json }}"
dest: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-cartridges.json"

- name: Logging state of cartridges in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-cartridge-state.log
shell: |
{{ role_path }}/files/log-services-installed.sh \
{{ status_dir }} \
{{ _p_current_cp4d_cluster.project }}
async: 86400
poll: 0
register: _log_services

- name: Show details of background task to log cartridge state
debug:
var: _log_services

- name: Run apply-cr command to install cartridges
block:
- name: Generate apply-cr command to install cartridges
Expand All @@ -67,7 +46,7 @@
fail:
msg: "{{ _install_cartridges_result }}"
when:
- not _cp4d_cartridges_installed_successfully
- _install_cartridges_result.rc!=0
- not (cpd_test_cartridges | default(False) | bool)
- set_fact:
_cp4d_cartridges_installed_successfully: False
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
- name: "Install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}"
debug:
msg: ""

- name: Ensure that OLM utils work directory exists
file:
path: /tmp/work
state: directory

# Always generate the preview script to log what will be done
- name: "Generate command preview script to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}"
set_fact:
_apply_cr_command_script: "{{ lookup('template', 'apply-cr-dp.j2') }}"
vars:
_p_preview_script: True

- name: Show apply-cr command to install cartridges
debug:
var: _apply_cr_command_script

- name: Generate preview script to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log
shell: |
{{ _apply_cr_command_script }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log 2>&1
- name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-dp.sh
copy:
src: "/tmp/work/preview.sh"
dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-dp.sh"
remote_src: True
mode: u+rwx

- name: Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}
block:
- name: Generate apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}
set_fact:
_apply_cr_command: "{{ lookup('template', 'apply-cr-dp.j2') }}"
vars:
_p_preview_script: False
- name: Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log
shell: |
{{ _apply_cr_command }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log 2>&1
register: _install_cartridges_result
failed_when: False
- name: Fail if there was an error installing the cartridge {{ _current_cp4d_cartridge.olm_utils_name }} using apply-cr
fail:
msg: "{{ _install_cartridges_result }}"
when:
- _install_cartridges_result.rc!=0
- not (cpd_test_cartridges | default(False) | bool)
- set_fact:
_cp4d_cartridges_installed_successfully: False
when: _install_cartridges_result.rc!=0
when: _sequential_install

- name: Run shell script to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log
shell: |
{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-dp.sh >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log 2>&1
when: not _sequential_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
- name: "Install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}"
debug:
msg: ""

- name: Ensure that OLM utils work directory exists
file:
path: /tmp/work
state: directory

- name: Write license type to /tmp/work/replication-install-options.yml
copy:
content: "license_type: {{ _current_cp4d_cartridge.license }}"
dest: "/tmp/work/replication-install-options.yml"

# Always generate the preview script to log what will be done
- name: "Generate command preview script to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}"
set_fact:
_apply_cr_command_script: "{{ lookup('template', 'apply-cr-replication.j2') }}"
vars:
_p_preview_script: True

- name: Show apply-cr command to install cartridges
debug:
var: _apply_cr_command_script

- name: Generate preview script to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log
shell: |
{{ _apply_cr_command_script }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log 2>&1
- name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-replication.sh
copy:
src: "/tmp/work/preview.sh"
dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-replication.sh"
remote_src: True
mode: u+rwx

- name: Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}
block:
- name: Generate apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}
set_fact:
_apply_cr_command: "{{ lookup('template', 'apply-cr-replication.j2') }}"
vars:
_p_preview_script: False
- name: Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log
shell: |
{{ _apply_cr_command }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log 2>&1
register: _install_cartridges_result
failed_when: False
- name: Fail if there was an error installing the cartridge {{ _current_cp4d_cartridge.olm_utils_name }} using apply-cr
fail:
msg: "{{ _install_cartridges_result }}"
when:
- _install_cartridges_result.rc!=0
- not (cpd_test_cartridges | default(False) | bool)
- set_fact:
_cp4d_cartridges_installed_successfully: False
when: _install_cartridges_result.rc!=0
when: _sequential_install

- name: Run shell script to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log
shell: |
{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-replication.sh >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log 2>&1
when: not _sequential_install
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
- name: Create Watson Knowledge Studio CR
shell: |
oc apply -f {{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml
when: _p_current_cp4d_cluster.cp4d_version >= "4.5.0"
when: _p_current_cp4d_cluster.cp4d_version >= "4.5.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- include_tasks: "{{ role_path }}/tasks/cp4d-install-cr-{{ _current_cp4d_cartridge.olm_utils_name }}.yml"
when:
- (_current_cp4d_cartridge.state | default('installed')) == 'installed'
- (_current_cp4d_cartridge.separate_install | default(False) | bool)
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@
debug:
var: _patch_db2u

- name: Write cartridge information to file {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-cartridges.json
copy:
content: "{{ _cartridges_to_install | default([]) | to_json }}"
dest: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-cartridges.json"

- name: Logging state of cartridges in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-cartridge-state.log
shell: |
{{ role_path }}/files/log-services-installed.sh \
{{ status_dir }} \
{{ _p_current_cp4d_cluster.project }}
async: 86400
poll: 0
register: _log_services

- name: Show details of background task to log cartridge state
debug:
var: _log_services

# Set fact which is handled when testing install of all cartridges
- set_fact:
_cp4d_cartridges_installed_successfully: True

- include_tasks: cp4d-install-cartridges-olm-utils.yml

- name: Run post-processing scripts
Expand All @@ -29,6 +51,12 @@
loop_control:
loop_var: _current_cp4d_cartridge

- name: Install separate cartridges
include_tasks: cp4d-install-separate-cr.yml
loop: "{{ _cartridges_to_install | default([]) }}"
loop_control:
loop_var: _current_cp4d_cartridge

- name: Wait for cartridges to finish installation
include_tasks: cp4d-wait-cartridges-ready.yml
loop: "{{ _cartridges_to_install | default([]) }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-v \
--cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \
--components={% for c in _cartridges_to_install -%}
{%- if (c.state | default('installed')) == 'installed' and c.name != 'watson-ks' -%}
{%- if (c.state | default('installed')) == 'installed' and not (c.separate_install | default(False | bool)) -%}
{%- if not loop.first -%},{% endif -%}
{{ c.olm_utils_name }}
{%- endif -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/opt/ansible/bin/apply-cr \
--release={{ _p_current_cp4d_cluster.cp4d_version }} \
--license_acceptance={{ _cpd_accept_licenses | default(False) | string | lower }} \
--preview={%- if _p_preview_script -%}true{%- else -%}false{%- endif %} \
--upgrade={%- if _upgrade_cp4d -%}true{%- else -%}false{%- endif %} \
-v \
--cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \
--components={{ _current_cp4d_cartridge.olm_utils_name }} \
{% if _storage_type == "ocs" -%}
--storage_vendor=ocs --file_storage_class={{ ocp_storage_class_file }} --block_storage_class={{ ocp_storage_class_block }} --storage_class={{ ocp_storage_class_file }}
{%- elif _storage_type == "pwx" -%}
--storage_vendor=portworx
{%- else -%}
--file_storage_class={{ ocp_storage_class_file }} --block_storage_class={{ ocp_storage_class_block }} --storage_class={{ ocp_storage_class_file }}
{%- endif -%}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/opt/ansible/bin/apply-cr \
--release={{ _p_current_cp4d_cluster.cp4d_version }} \
--license_acceptance={{ _cpd_accept_licenses | default(False) | string | lower }} \
--preview={%- if _p_preview_script -%}true{%- else -%}false{%- endif %} \
--upgrade={%- if _upgrade_cp4d -%}true{%- else -%}false{%- endif %} \
-v \
--cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \
--components={{ _current_cp4d_cartridge.olm_utils_name }} \
--param-file=/tmp/work/replication-install-options.yml \
{% if _storage_type == "ocs" -%}
--storage_vendor=ocs --file_storage_class={{ ocp_storage_class_file }} --block_storage_class={{ ocp_storage_class_block }} --storage_class={{ ocp_storage_class_file }}
{%- elif _storage_type == "pwx" -%}
--storage_vendor=portworx
{%- else -%}
--file_storage_class={{ ocp_storage_class_file }} --block_storage_class={{ ocp_storage_class_block }} --storage_class={{ ocp_storage_class_file }}
{%- endif -%}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@
regexp: '^ image: icr.io/cpopen/ibm-cpd-platform-operator-catalog@sha256:953403f1d7193fedb81186ec454fae3ea0852ef4c1929c3c56f12352189b1766'
replace: ' image: icr.io/cpopen/ibm-cpd-platform-operator-catalog@sha256:54d3d7aff34444eb1991335831c18272ad217a6445f898e22f0b30f539b8c7cf'

# TODO: Remove step once problem in olm-utils is fixed
- name: Update script to fix invalid ws-pipelines create catalog source command
replace:
path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc.sh"
regexp: 'ibm-ws-pipelines-6.0.0.tgz'
replace: 'ibm-ws-pipelines-6.0.0*.tgz'

# TODO: Remove step once problem in olm-utils is fixed
- name: Update script to fix invalid replication create catalog source command
replace:
path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc.sh"
regexp: 'ibm-replication-4.6.0.tgz'
replace: 'ibm-replication-4.6.0*.tgz'

- name: Run apply-olm command to create catalog sources
block:
- name: Generate OLM command to create catalog sources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
include_role:
name: cp4d-cluster-show

# Configure SSL certificate from the OpenShift Cluster to Cloud Pak for Data
- name: Configure Cloud Pak for Data SSL certificate
include_role:
name: cp4d-configure-ssl-certificate

- name: Retrieve Cloud Pak Foundational Services
set_fact:
_cp_fs: "{{ current_cp4d_cluster.cartridges | json_query(query) | first | default({}) }}"
Expand Down
Loading

0 comments on commit 519220b

Please sign in to comment.