Skip to content

Commit

Permalink
#820 Dry-run for CP4D cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
fketelaars committed Nov 1, 2024
1 parent 6c37d89 commit 83ea718
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
src: db2u-product-cm.j2
dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2u-product-cm.yml"

- include_role:
name: log-deployer-activity
vars:
_p_activity_description: "Create configmap db2u-product-cm in project {{ current_cp4d_cluster.project }}"
_p_activity_yaml: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2u-product-cm.yml"

- name: Create configmap db2u-product-cm in project {{ current_cp4d_cluster.project }}
shell: |
oc apply -f {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2u-product-cm.yml
oc apply -f {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2u-product-cm.yml
when: not cpd_dry_run
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,30 @@
vars:
_p_preview_script: False

- name: Run apply-cr command to install Cloud Pak for Data platform, logs are in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-cr-cpd-platform.log
shell: |
{{ _apply_cr_command }} > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-cr-cpd-platform.log 2>&1
# Wait for ZenService to be created (can take 10-15 minutes)
- name: Wait for ZenService to be completed
shell: |
oc get ZenService -n {{ current_cp4d_cluster.project }} lite-cr --output json | \
jq -r '.status.zenStatus' | grep -i 'completed' | \
wc -l
register: deployed_zenservice
retries: 90
delay: 60
until: deployed_zenservice.stdout == "1"
- include_role:
name: log-deployer-activity
vars:
ansible_callback_diy_runner_retry_msg: >-
{%- set result = ansible_callback_diy.result.output -%}
{%- set retries_left = result.retries - result.attempts -%}
Retrying: {{ ansible_callback_diy.task.name }} ({{ retries_left }} Retries left) ...
_p_activity_description: "Run apply-cr to install Cloud Pak for Data platform"
_p_activity_command: "{{ _apply_cr_command }}"

- block:
- name: Run apply-cr command to install Cloud Pak for Data platform, logs are in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-cr-cpd-platform.log
shell: |
{{ _apply_cr_command }} > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-cr-cpd-platform.log 2>&1
# Wait for ZenService to be created (can take 10-15 minutes)
- name: Wait for ZenService to be completed
shell: |
oc get ZenService -n {{ current_cp4d_cluster.project }} lite-cr --output json | \
jq -r '.status.zenStatus' | grep -i 'completed' | \
wc -l
register: deployed_zenservice
retries: 90
delay: 60
until: deployed_zenservice.stdout == "1"
vars:
ansible_callback_diy_runner_retry_msg: >-
{%- set result = ansible_callback_diy.result.output -%}
{%- set retries_left = result.retries - result.attempts -%}
Retrying: {{ ansible_callback_diy.task.name }} ({{ retries_left }} Retries left) ...
when: not cpd_dry_run
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@
path: "{{status_dir}}/log"
state: directory

- name: Logging state of cartridges in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-cartridge-state.log
shell: |
{{ role_path }}/files/cp4d-log-services-installed.sh \
{{ status_dir }} \
{{ current_cp4d_cluster.project }}
async: 86400
poll: 0
register: _log_services
- block:
- name: Logging state of cartridges in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-cartridge-state.log
shell: |
{{ role_path }}/files/cp4d-log-services-installed.sh \
{{ status_dir }} \
{{ 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: Show details of background task to log cartridge state
debug:
var: _log_services
when: not cpd_dry_run

- name: Prepare OpenShift cluster for Cloud Pak for Data
include_role:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,20 @@

- name: Configure CP4D admin password and store in vault
include_tasks: configure-cpd-admin-password.yml
when: not cpd_dry_run

- name: Output Cloud pak for Data URL and admin password
include_role:
name: cp4d-cluster-show
when: not cpd_dry_run

- name: Login to Cloud Pak for Data as the admin user
include_role:
name: cp4d-login
vars:
_p_cp4d_project: "{{ current_cp4d_cluster.project }}"
_p_cp4d_password: "{{ _cp4d_admin_password }}"
when: not cpd_dry_run

# Configure SSL certificate from the OpenShift Cluster to Cloud Pak for Data
- name: Configure Cloud Pak for Data SSL certificate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

# Prepare CP4D for versions >= 4.8.0
- block:

Expand Down Expand Up @@ -27,17 +26,24 @@
--patch='{"metadata": {"namespace": "ibm-knative-events"}}' \
--dry-run=client | oc apply -n ibm-knative-events -f -
when: cpd_airgap | bool
when:
- cpd_airgap | bool
- not cpd_dry_run

- name: Generate deploy KNative eventing command
set_fact:
_deploy_knative_eventing_command: "{{ lookup('template','deploy-knative-eventing.j2') }}"

- name: Generate deploy KNative eventing script {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.sh
template:
src: deploy-knative-eventing.j2
dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.sh"
mode: u+rwx
- include_role:
name: log-deployer-activity
vars:
_p_activity_description: "Deploy KNative eventing"
_p_activity_command: "{{ _deploy_knative_eventing_command }}"

- name: Run script to deploy KNative eventing, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log
shell: |
{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.sh
{{ _deploy_knative_eventing_command }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log
when: not cpd_dry_run

when:
- current_cp4d_cluster.cp4d_version >= '4.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,35 @@
when:
- _db2u_dependency | default(False)

- name: Generate authorize instance script {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-authorize-instance.sh
template:
src: authorize-instance.j2
dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-authorize-instance.sh"
mode: u+rwx
- name: Generate authorize instance command for project {{ current_cp4d_cluster.project }}
set_fact:
_authorize_instance_command: "{{ lookup('template','authorize-instance.j2') }}"

- name: Run script to authorize instance, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-authorize-instance.log
- include_role:
name: log-deployer-activity
vars:
_p_activity_description: "Authorize instance {{ current_cp4d_cluster.project }}"
_p_activity_command: "{{ _authorize_instance_command }}"

- name: Authorize instance, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-authorize-instance.log
shell: |
{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-authorize-instance.sh
set -o pipefail
{{ _authorize_instance_command }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-authorize-instance.log
- name: Generate setop instance topology command for project {{ current_cp4d_cluster.project }}
set_fact:
_setup_instance_topology: "{{ lookup('template','setup-instance_topology.j2') }}"

- name: Generate setup instance topology script {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-setup-instance-topology.sh
template:
src: setup-instance-topology.j2
dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-setup-instance-topology.sh"
mode: u+rwx
- include_role:
name: log-deployer-activity
vars:
_p_activity_description: "Authorize instance {{ current_cp4d_cluster.project }}"
_p_activity_command: "{{ _setup_instance_topology }}"

- name: Run script to setup instance topology, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-setup-instance-topology.log
- name: Setup instance topology, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-setup-instance-topology.log
shell: |
{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-setup-instance-topology.sh
set -o pipefail
{{ _setup_instance_topology }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-setup-instance-topology.log
when:
- current_cp4d_cluster.cp4d_version >= '4.7.0'
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
set -o pipefail
authorize-instance-topology \
--cpd_operator_ns={{ current_cp4d_cluster.operators_project }} \
--cpd_instance_ns={{ current_cp4d_cluster.project }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-authorize-instance.log
--cpd_instance_ns={{ current_cp4d_cluster.project }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
set -o pipefail
deploy-knative-eventing \
--release={{ current_cp4d_cluster.cp4d_version }} \
--block_storage_class={{ ocp_storage_class_block }} \
2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log
--block_storage_class={{ ocp_storage_class_block }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
set -o pipefail
setup-instance-topology \
--cpd_operator_ns={{ current_cp4d_cluster.operators_project }} \
--cpd_instance_ns={{ current_cp4d_cluster.project }} \
Expand Down

0 comments on commit 83ea718

Please sign in to comment.