-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #686 from IBM/wxo
Add watsonx Orchestrate to deployer
- Loading branch information
Showing
29 changed files
with
398 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/files/temp-patch-wxo.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/bin/bash | ||
|
||
# Parameters | ||
# $1: Status directory | ||
# $2: OpenShift project for Cloud Pak for Data | ||
|
||
status_dir=$1 | ||
project=$2 | ||
|
||
exit_code=0 | ||
|
||
get_logtime() { | ||
echo $(date "+%Y-%m-%d %H:%M:%S") | ||
} | ||
|
||
log() { | ||
LOG_TIME=$(get_logtime) | ||
printf "[${LOG_TIME}] ${1}\n" | tee -a ${status_dir}/log/$project-wxo-48-patch.log | ||
} | ||
|
||
log "----------" | ||
# Check if the connection to the OpenShift cluster is still valid | ||
log "Info: Checking access to project $project" | ||
oc get project $project | ||
if [ $? -ne 0 ];then | ||
log "Error: Could not access project $project. Has the OpenShift login token expired?" | ||
exit 99 | ||
fi | ||
|
||
ops_manager_patched=0 | ||
rabbit_mq_cluster_patched=0 | ||
|
||
while true;do | ||
log "----------" | ||
log "Checking OpsManager in project ${project}" | ||
log "----------" | ||
|
||
if oc get opsmanagers.mongodb.com -n ${project} mongodb-wo-mongo-ops-manager;then | ||
log "Info: Patching OpsManager mongodb-wo-mongo-ops-manager" | ||
patch_result=$(oc patch opsmanagers.mongodb.com \ | ||
-n ${project} mongodb-wo-mongo-ops-manager \ | ||
--type merge \ | ||
--patch '{ | ||
"spec": { | ||
"applicationDatabase":{ | ||
"podSpec":{ | ||
"podTemplate":{ | ||
"metadata":{ | ||
"labels":{ | ||
"wo.watsonx.ibm.com/external-access":"true" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}' 2>&1 | tee -a ${status_dir}/log/$project-wxo-48-patch.log) | ||
if [[ "$patch_result" != *"(no change)"* ]];then | ||
echo "OpsManager has been patched." | tee -a ${status_dir}/log/$project-wxo-48-patch.log | ||
oc delete sts -n ${project} mongodb-wo-mongo-ops-manager-db --ignore-not-found | ||
fi | ||
ops_manager_patched=1 | ||
fi | ||
|
||
log "----------" | ||
log "Checking RabbitMQCluster in project ${project}" | ||
log "----------" | ||
|
||
if oc get rabbitmqclusters.rabbitmq.opencontent.ibm.com -n ${project} wo-rabbitmq;then | ||
log "Info: Patching RabbitMQCluster wo-rabbitmq" | ||
patch_result=$(oc patch rabbitmqclusters.rabbitmq.opencontent.ibm.com \ | ||
-n ${project} wo-rabbitmq \ | ||
--type merge \ | ||
--patch '{ | ||
"metadata":{ | ||
"annotations":{ | ||
"wo.watsonx.ibm.com/hands-off":"true" | ||
} | ||
}, | ||
"spec":{ | ||
"global":{ | ||
"podLabels":{ | ||
"wo.watsonx.ibm.com/external-access":"true" | ||
} | ||
} | ||
} | ||
}' 2>&1 | tee -a ${status_dir}/log/$project-wxo-48-patch.log) | ||
if [[ "$patch_result" != *"(no change)"* ]];then | ||
echo "RabbitMQCluster has been patched." | tee -a ${status_dir}/log/$project-wxo-48-patch.log | ||
oc delete job -n ${project} wo-rabbitmq-orchestrate-backup-label --ignore-not-found | ||
fi | ||
rabbit_mq_cluster_patched=1 | ||
fi | ||
|
||
if [[ ${ops_manager_patched} -eq 1 && ${rabbit_mq_cluster_patched} -eq 1 ]];then | ||
log "Both OpsManager and RabbitMQCluster have been patched, exiting" | ||
exit 0 | ||
fi | ||
|
||
log "----------" | ||
log "Finished checks, sleeping for 2 minutes" | ||
sleep 120 | ||
done | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
.../50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
--- | ||
- name: Check if Watson Assistant has been installed {{ _p_current_cp4d_cluster.project }} | ||
shell: | | ||
oc get WatsonAssistant wa -n {{ _p_current_cp4d_cluster.project }} | ||
failed_when: False | ||
register: _wa_installed | ||
|
||
- name: Fail if Watson Assistant has not been installed in project {{ _p_current_cp4d_cluster.project }} | ||
fail: | ||
msg: Watson Assistant has not been installed in project {{ _p_current_cp4d_cluster.project }} | ||
when: _wa_installed.rc != 0 | ||
|
||
- name: Generate OLM utils command to create watsonx Orchestrate subscription | ||
set_fact: | ||
_apply_olm_wxo_command: "{{ lookup('template', 'apply-olm-cartridge-wxo.j2') }}" | ||
|
||
- name: Show apply-olm command to create watsonx Orchestrate subscription | ||
debug: | ||
var: _apply_olm_wxo_command | ||
|
||
- name: Run apply-olm command to install watsonx Orchestrate subscriptions, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-olm-wxo.log | ||
shell: | | ||
{{ _apply_olm_wxo_command }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-olm-wxo.log 2>&1 | ||
retries: 2 | ||
delay: 10 | ||
until: _apply_olm_wxo_result.rc==0 | ||
register: _apply_olm_wxo_result | ||
|
||
- set_fact: | ||
_app_connect: "{{ _current_cp4d_cartridge.app_connect }}" | ||
|
||
- name: Download IBM App Connect case file version {{ _app_connect.app_connect_case_version }} | ||
get_url: | ||
url: "https://github.com/IBM/cloud-pak/raw/master/repo/case/ibm-appconnect/{{ _app_connect.app_connect_case_version }}/ibm-appconnect-{{ _app_connect.app_connect_case_version }}.tgz" | ||
dest: "{{ status_dir }}/cp4d/ibm-app-connect-{{ _app_connect.app_connect_case_version }}.tar.gz" | ||
owner: root | ||
mode: 0644 | ||
register: _case_download_result | ||
until: _case_download_result is succeeded | ||
retries: 5 | ||
delay: 30 | ||
|
||
- name: Unpack IBM App Connect case file {{ status_dir }}/cp4d/ibm-app-connect-{{ _app_connect.app_connect_case_version }}.tar.gz to /tmp | ||
unarchive: | ||
src: "{{ status_dir }}/cp4d/ibm-app-connect-{{ _app_connect.app_connect_case_version }}.tar.gz" | ||
dest: /tmp | ||
remote_src: True | ||
|
||
- name: Create OpenShift Project {{ _app_connect.app_connect_project }} | ||
shell: | ||
oc new-project {{ _app_connect.app_connect_project }} || true | ||
|
||
- name: Create IBM App Connect catalog source | ||
shell: | | ||
oc patch --filename=/tmp/ibm-appconnect/inventory/ibmAppconnect/files/op-olm/catalog_source.yaml \ | ||
--type=merge \ | ||
-o yaml \ | ||
--patch='{"metadata": {"namespace": "{{ _app_connect.app_connect_project }}"}}' \ | ||
--dry-run=client | oc apply -n {{ _app_connect.app_connect_project }} -f - | ||
- name: Generate yaml for IBM App Connect operator | ||
template: | ||
src: ibm-app-connect.j2 | ||
dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-ibm-app-connect.yaml" | ||
|
||
- name: Create IBM App Connect operator | ||
shell: | | ||
oc apply -f {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-ibm-app-connect.yaml | ||
- name: Wait for IBM App Connect operator to be installed | ||
shell: | | ||
oc wait csv --namespace={{ _app_connect.app_connect_project }} \ | ||
-l=operators.coreos.com/ibm-appconnect.{{ _app_connect.app_connect_project }}='' \ | ||
--for='jsonpath={.status.phase}'=Succeeded --timeout=30s | ||
register: _ibm_app_connect_csv | ||
retries: 20 | ||
delay: 10 | ||
until: _ibm_app_connect_csv.rc == 0 | ||
|
||
- name: Create IBM App Connect instance for watsonx watsonx.orchestrate | ||
shell: | | ||
setup-appconnect \ | ||
--appconnect_ns={{ _app_connect.app_connect_project }} \ | ||
--cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \ | ||
--release={{ _p_current_cp4d_cluster.cp4d_version }} \ | ||
--components=watsonx_orchestrate \ | ||
--file_storage_class={{ ocp_storage_class_file }} | ||
- set_fact: | ||
_cp4d_admin_password_vault_key_name: "cp4d_admin_{{ _p_current_cp4d_cluster.project| replace('-','_') }}_{{ _p_current_cp4d_cluster.openshift_cluster_name| replace('-','_') }}" | ||
|
||
- name: Retrieve CP4D admin password from vault secret {{ _cp4d_admin_password_vault_key_name }} | ||
include_role: | ||
name: vault-get-secret | ||
vars: | ||
secret_name: "{{ _cp4d_admin_password_vault_key_name }}" | ||
secret_group: "{{ environment_name }}" | ||
_p_secret_variable: _cp4d_admin_password_vault | ||
|
||
- name: Setup watsonx Assistant instances for watsonx watsonx.orchestrate | ||
shell: | | ||
setup-wxo-assistant \ | ||
--cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \ | ||
--create_assistants=true \ | ||
--user={{ _cp4d_user }} \ | ||
--password={{ _cp4d_admin_password_vault }} \ | ||
--auth_type=password | ||
register: _setup_wxo_assistant | ||
retries: 5 | ||
delay: 10 | ||
until: _setup_wxo_assistant.rc == 0 | ||
|
||
- block: | ||
- name: Starting background task to patch OpsManager and RabbitMQCluster. Logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-wxo-48-patch.log | ||
shell: | | ||
{{ role_path }}/files/temp-patch-wxo.sh \ | ||
{{ status_dir }} \ | ||
{{ _p_current_cp4d_cluster.project }} | ||
async: 86400 | ||
poll: 0 | ||
register: _patch_wxo_48 | ||
|
||
- name: Show details of background task to patch watsonx Orchestrate | ||
debug: | ||
var: _patch_wxo_48 | ||
when: _p_current_cp4d_cluster.cp4d_version == "4.8.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...les/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-olm-cartridge-wxo.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/opt/ansible/bin/apply-olm \ | ||
--release={{ _p_current_cp4d_cluster.cp4d_version }} \ | ||
--case_download=false \ | ||
--catsrc=false --sub=true \ | ||
--cpd_operator_ns={{ _p_current_cp4d_cluster.operators_project | default('cpd-operators') }} \ | ||
--upgrade={%- if _upgrade_cp4d -%}true{%- else -%}false{%- endif %} \ | ||
--components=watsonx_orchestrate |
Oops, something went wrong.