Skip to content

Commit

Permalink
Merge branch 'cpd485' into wxo
Browse files Browse the repository at this point in the history
  • Loading branch information
fketelaars committed Apr 14, 2024
2 parents 5cc53d4 + 0897b0b commit c14f30b
Show file tree
Hide file tree
Showing 59 changed files with 1,251 additions and 324 deletions.
6 changes: 3 additions & 3 deletions automation-generators/generic/cp4i/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ def preprocessor(attributes=None, fullConfig=None, moduleVariables=None):

g('project').isRequired()
g('openshift_cluster_name').expandWith('openshift[*]',remoteIdentifier='name')
openshift_cluster_name=g('openshift_cluster_name').getExpandedAttributes()['openshift_cluster_name']
g('cp4i_version').isRequired()
g('openshift_storage_name').expandWithSub('openshift', remoteIdentifier='name', remoteValue=openshift_cluster_name, listName='openshift_storage',listIdentifier='storage_name')
g('instances').isRequired()
g('use_case_files').isOptional().mustBeOneOf([True, False])
g('olm_utils').isOptional().mustBeOneOf([True, False])
Expand All @@ -74,7 +72,9 @@ def preprocessor(attributes=None, fullConfig=None, moduleVariables=None):
fc = g.getFullConfig()
ge=g.getExpandedAttributes()

# Check for cp4i:
# Check for cp4i:
openshift_cluster_name=g('openshift_cluster_name').getExpandedAttributes()['openshift_cluster_name']
g('openshift_storage_name').expandWithSub('openshift', remoteIdentifier='name', remoteValue=openshift_cluster_name, listName='openshift_storage',listIdentifier='storage_name')

# Check that version matches x.y.z pattern
if not re.match(r"[0-9]+\.[0-9]\.[0-9]+",str(ge['cp4i_version'])):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,6 @@ pm_project_name: "{{ main_project_name }}"
pm_postgresql_project: "{{ postgresql_project_name }}"
pm_postgresql_hostname: "{{ postgresql_hostname }}"
pm_postgresql_password: "{{ postgresql_universal_password }}"
pm_mongodb_project: "{{ mongodb_project_name }}"
pm_mongodb_hostname: "{{ mongodb_hostname }}"
pm_mongodb_admin_user: "{{ mongodb_admin_user }}"
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
# name: rpa
# when: _current_cp4ba_cluster.rpa.enabled

# - name: Install PM
# ansible.builtin.include_role:
# name: pm
# when: _current_cp4ba_cluster.pm.enabled
- name: Install PM
ansible.builtin.include_role:
name: pm
when: _current_cp4ba_cluster.pm.enabled
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cp4ba_operator_channel: v23.2
## Should not be changed in particular guide version.
## Version of Cloud Pak CASE archive as found on
## https://github.com/IBM/cloud-pak/tree/master/repo/case/ibm-cp-automation e.g. 3.0.1
cp4ba_case_version: 5.1.2
cp4ba_case_version: 5.1.3
## Should not be changed in particular guide version.
## Version of cert-kubernetes folder from Cloud Pak CASE archive e.g. 21.0.1
cp4ba_case_cert_k8s_version: 23.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
###############################################################################
# CP4BA 23.0.2-IF002 catalog
# CP4BA 23.0.2-IF003 catalog
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
Expand All @@ -26,7 +26,7 @@ spec:
displayName: ibm-cp4a-operator
publisher: IBM
sourceType: grpc
image: icr.io/cpopen/ibm-cp-automation-catalog@sha256:beed894a47ae8e3414e50638221e6cf03ae3ac121fe2e78ec0e0705cda77a82c
image: icr.io/cpopen/ibm-cp-automation-catalog@sha256:916ca9cc9f2a08071274480ee76a5a0886b136aeaf22bf5ba77ccabaaf03f39a
updateStrategy:
registryPoll:
interval: 45m
Expand Down Expand Up @@ -61,7 +61,7 @@ spec:
updateStrategy:
registryPoll:
interval: 45m
priority: 100
priority: 100
---
# IBM Cloud Foundational Services 4.4.0
apiVersion: operators.coreos.com/v1alpha1
Expand All @@ -79,7 +79,7 @@ spec:
updateStrategy:
registryPoll:
interval: 45m
priority: 100
priority: 100
---
# IBM Business Teams Service version 3.32.0
apiVersion: operators.coreos.com/v1alpha1
Expand Down Expand Up @@ -126,7 +126,7 @@ spec:
displayName: ibm-fncm-operator
publisher: IBM
sourceType: grpc
image: icr.io/cpopen/ibm-fncm-catalog@sha256:0ecc62f5e9eec5d1e0e58fd510fbb7110a1a175aa834ade2059c170792393863
image: icr.io/cpopen/ibm-fncm-catalog@sha256:c8ca90434c2d9b7846097daab2eeb99168e16fcd9382873af31399119b1ced9f
updateStrategy:
registryPoll:
interval: 45m
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ pm_base_dir: "{{ generic_directory }}"
pm_dir_name: pm
pm_project_name: ""
pm_operator_channel: v3.0
pm_version: 1.14.3
pm_version: 1.14.4
pm_storage_class_name: ""
pm_universal_password: ""
pm_postgresql_project: ""
pm_postgresql_hostname: ""
pm_postgresql_password: ""
pm_mongodb_project: ""
pm_mongodb_hostname: ""
pm_mongodb_admin_user: ""
pm_output_namespace: "cloud-pak-deployer"
13 changes: 7 additions & 6 deletions automation-roles/50-install-cloud-pak/cp4ba/pm/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,22 @@
kubernetes.core.k8s_info:
api_version: v1
kind: Pod
namespace: mongodb
namespace: "{{ pm_mongodb_project }}"
label_selectors:
- app.kubernetes.io/component=mongodb
- app=mongodb
register: mongodb_pod

- name: Create PM Mongo DB
kubernetes.core.k8s_exec:
namespace: mongodb
namespace: "{{ pm_mongodb_project }}"
pod: "{{ mongodb_pod.resources[0].metadata.name }}"
command: |
mongo --username root --password {{ pm_universal_password }} --authenticationDatabase admin
--eval 'db.createUser({user: "root", pwd: "{{ pm_universal_password }}", roles: [ { role: "readWrite", db: "processmining" } ]})'
mongo --username {{ pm_mongodb_admin_user }} --password {{ pm_universal_password }} --authenticationDatabase admin
--eval 'db.createUser({user: "{{ pm_mongodb_admin_user }}", pwd: "{{ pm_universal_password }}", roles: [ { role: "readWrite", db: "processmining" } ]})'
mongodb://localhost:27017/processmining
register: command_status
failed_when: command_status.rc != 0 and command_status.stdout is not search('.*User \"root@processmining\" already exists.*')
failed_when: command_status.rc != 0 and
command_status.stdout is not search('.*User \"' + pm_mongodb_admin_user + '@processmining\" already exists.*')

- name: Prepare yaml file for CatalogSource
ansible.builtin.template:
Expand Down
10 changes: 5 additions & 5 deletions automation-roles/50-install-cloud-pak/cp4ba/pm/tasks/remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@
kubernetes.core.k8s_info:
api_version: v1
kind: Pod
namespace: mongodb
namespace: "{{ pm_mongodb_project }}"
label_selectors:
- app.kubernetes.io/component=mongodb
- app=mongodb
register: mongodb_pod

- name: Delete PM Mongo DB
kubernetes.core.k8s_exec:
namespace: mongodb
namespace: "{{ pm_mongodb_project }}"
pod: "{{ mongodb_pod.resources[0].metadata.name }}"
command: >
mongo --username root --password {{ pm_universal_password }} --authenticationDatabase admin
mongo --username {{ pm_mongodb_admin_user }} --password {{ pm_universal_password }} --authenticationDatabase admin
--eval '{{ item }}' mongodb://localhost:27017/processmining
register: command_status
with_items:
- db.dropUser("root")
- db.dropUser("{{ pm_mongodb_admin_user }}")
- db.dropDatabase()
when: mongodb_pod.resources | length != 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
displayName: IBM ProcessMining Operators
publisher: IBM
sourceType: grpc
image: icr.io/cpopen/processmining-operator-catalog@sha256:99edbaa0c1d468f07d662c78453c95ecf00acd5ac04c621aa29f687769b05ffe
image: icr.io/cpopen/processmining-operator-catalog@sha256:f5cfcb8c13cade29deb5235c3e8bfdceb03255a5c78621b4a3cd76ebc7f146d3
updateStrategy:
registryPoll:
interval: 45m
Expand Down Expand Up @@ -36,7 +36,7 @@ metadata:
namespace: "{{ pm_project_name }}"
spec:
displayName: IBM Db2U Catalog
image: icr.io/cpopen/ibm-db2uoperator-catalog@sha256:986c54823f2d536e2dd35fa60d8e875786ef7bc0d9e8f87b39e90a7730fc6d70
image: icr.io/cpopen/ibm-db2uoperator-catalog@sha256:278fa6bbaa834faa4a0ec522cd85a301a088e610d8f5a74d7981f172d30cd5d4
imagePullPolicy: Always
publisher: IBM
sourceType: grpc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ spec:
database:
external:
connectionstring: ""
host: "{{ pm_mongodb_hostname }}"
host: "{{ pm_mongodb_hostname }}"
port: 27017
database: processmining
user: root
user: "{{ pm_mongodb_admin_user }}"
credential:
secretname: pm-dbs
passwordkey: mongodbPassword
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ setup-instance-topology \
--cpd_operator_ns={{ current_cp4d_cluster.operators_project | default('cpd-operators') }} \
--cpd_instance_ns={{ current_cp4d_cluster.project }} \
--release={{ current_cp4d_cluster.cp4d_version }} \
--block_storage_class={{ ocp_storage_class_block }} \
--license_acceptance=true 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-setup-instance-topology.log
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ while true;do
current_ts=$(date +%s)

log "Collecting OLM information"
oc get sub -n ${fs_project} \
oc get subscriptions.operators.coreos.com -n ${fs_project} \
--sort-by=.metadata.creationTimestamp \
--no-headers \
-o jsonpath='{range .items[*]}{.metadata.name}{","}{.metadata.creationTimestamp}{","}{.status.installedCSV}{","}{.status.state}{"\n"}{end}' > ${sub_file}
Expand Down Expand Up @@ -86,7 +86,7 @@ while true;do
while IFS=, read -r sub sub_ts csv sub_state;do
if [[ "${csv}" == "" ]];then
log "DIAG: Exporting subscription ${sub} to ${diag_dir}/sub-${sub}.yaml and deleting"
oc get sub -n ${fs_project} ${sub} -o yaml > ${diag_dir}/sub-${sub}.yaml
oc get subscriptions.operators.coreos.com -n ${fs_project} ${sub} -o yaml > ${diag_dir}/sub-${sub}.yaml
oc delete sub -n ${fs_project} ${sub}
fi
done < ${diag_dir}/sub-diag.csv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
block:
- name: Retrieving state of all operators in project {{ foundational_services_project }}
shell: |
oc get sub -n {{ foundational_services_project }} \
oc get subscriptions.operators.coreos.com -n {{ foundational_services_project }} \
--no-headers \
--sort-by=.metadata.creationTimestamp \
-o jsonpath='{range .items[*]}{.metadata.name}{","}{.metadata.creationTimestamp}{","}{.status.installedCSV}{","}{.status.state}{"\n"}{end}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ cp4d_login_username: admin
cp4d_repo_url: cp.icr.io/cp/cpd
cp4d_repo_username: cp

_v_template_dest_directory: "{{ status_dir }}/cp4d"

license_service_project: ibm-licensing
scheduling_service_project: cpd-scheduler
cert_manager_project: ibm-cert-manager
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# Paramteres:
# - _p_template
# - _p_dest_name
#
# The other parameters, as they are defined in the template,
# must be provided when invoking this task

- name: "Prepare yaml file"
template:
src: "{{ _p_template }}"
dest: "{{ status_dir }}/cp4i/{{ _p_dest_name }}"

- name: "Apply {{ status_dir }}/cp4i/{{ _p_dest_name }}"
shell: |
oc apply -f {{ status_dir }}/cp4i/{{ _p_dest_name }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: Verify if the entitlement key secret already exists
shell: |
oc get secret ibm-entitlement-key -n {{ current_cp4i_cluster.project }} | grep -i '^ibm-entitlement-key' | wc -l
Expand All @@ -8,4 +7,4 @@
- name: Create secret ibm-entitlement-key
shell: |
oc create secret docker-registry ibm-entitlement-key --docker-username=cp --docker-password={{ibm_cp_entitlement_key}} --docker-server=cp.icr.io --namespace={{ current_cp4i_cluster.project }}
when: entitlement_key_secret_exists.stdout == "0"
when: "entitlement_key_secret_exists.stdout | trim == '0'"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# Global variables:
# - _use_entitled_registry

# Paramaters:
# - _p_case_file_name
# - _p_catalog_source_yaml
# - _p_case_version

- name: "Create Foundational Services catalog source when entitled registry is used"
shell: |
oc apply -f ~/.ibm-pak/data/mirror/{{ _p_case_file_name }}/{{ _p_case_version }}/{{ _p_catalog_source_yaml }}
when: _use_entitled_registry

- name: "Create Foundational Services catalog source when private registry is used"
shell: |
oc apply -f {{ status_dir }}/ibm-pak/data/mirror/{{ {{ _p_case_file_name }} }}/{{ _p_case_version }}/{{ _p_catalog_source_yaml }}
when: not _use_entitled_registry
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
---

- name: Create instance
- name: "Create instance"
block:

- debug:
msg: "### Creating instance of {{ current_cp4i_instance.type }} "

# ---------- FIND INSTANCE TYPE DEFINITION --------------

- name: Get instance type details
- name: "Get instance type details"
set_fact:
_inst_type_def: "{{ instance_types | json_query(query) | first | default({}) }}"
vars:
query: >-
[?type=='{{ current_cp4i_instance.type }}']
- name: Fail if the instance type cannot be found
- name: "Fail if the instance type cannot be found"
fail:
msg: "Case instance type for instance {{ current_cp4i_instance.name }} not found."
when: _inst_type_def=={}

# ---------- FIND VERSION PROPERTIES -----------------------

- name: Find version specific instance type properties
- name: "Find version specific instance type properties"
include_tasks: get-instance-properties.yml
# returns: instance_properties

# ---------- CREATE INSTANCE ----------------------------

Expand All @@ -32,19 +32,20 @@
oc get {{_inst_type_def.kind}} {{instance_properties.name}} -n {{current_cp4i_cluster.project}} | grep -i '^{{instance_properties.name}}' | wc -l
register: instance_exists

- name: Create instance if it does not already exist
- name: "Create instance if it does not already exist"
block:

- name: If instance type is enterprise-gateway create admin password secret
- name: "If instance type is enterprise-gateway create admin password secret"
include_tasks: create-dp-admin-password-secret.yml
when: instance_properties.type == 'enterprise-gateway'

- set_fact:

- name: "Get template from instance properties or use a default one defined for the instance type"
set_fact:
instance_template: "{{ instance_properties.template | default(default_template_name) }}"
vars:
default_template_name: "{{ _inst_type_def.default_template }}"

- name: Prepare yaml file for creating instance
- name: "Prepare yaml file for creating instance"
template:
src: "{{instance_template}}.j2"
dest: "{{ status_dir }}/cp4i/{{instance_properties.type}}-{{instance_properties.name}}.yml"
Expand All @@ -53,12 +54,11 @@
shell: |
oc apply -f {{ status_dir }}/cp4i/{{instance_properties.type}}-{{instance_properties.name}}.yml
when: instance_exists.stdout == "0"

when: "instance_exists.stdout | trim == '0'"

# ---------- WAITING FOR PLATFORM NAVIGATOR TO BECOME READY -------

- name: "Wait for the {{_inst_type_def.kind}} to become ready"
- name: "Waiting for the {{_inst_type_def.kind}} to become ready"
shell: |
oc get {{_inst_type_def.kind}} -n {{current_cp4i_cluster.project}} {{instance_properties.name}} -o json | jq -r '.status.conditions[] | select(.type=="Ready").status'
register: instance_status
Expand All @@ -67,7 +67,4 @@
until: instance_status.stdout == "True"
when: instance_properties.type == 'platform-navigator'


when: (current_cp4i_instance.state | default('installed')) == 'installed'


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# Parameters:
# - _p_project_name

- name: "Validate if OpenShift project {{ _p_project_name }} exists"
shell: "oc get projects | grep -i '^{{ _p_project_name }}' | wc -l"
register: _project_exists

- name: "Create OpenShift Project {{ _p_project_name }} if it does not exist"
command: "oc new-project {{ _p_project_name }}"
when: "_project_exists.stdout | trim == '0'"
Loading

0 comments on commit c14f30b

Please sign in to comment.