diff --git a/.github/scripts/validate-deploy.sh b/.github/scripts/validate-deploy.sh index 39e8d20..48d1998 100755 --- a/.github/scripts/validate-deploy.sh +++ b/.github/scripts/validate-deploy.sh @@ -1,9 +1,13 @@ #!/usr/bin/env bash +SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P) + +source "${SCRIPT_DIR}/validation-functions.sh" + GIT_REPO=$(cat git_repo) GIT_TOKEN=$(cat git_token) -#BIN_DIR=$(cat .bin_dir) +BIN_DIR=$(cat .bin_dir) export PATH="${BIN_DIR}:${PATH}" @@ -38,32 +42,11 @@ cd .testrepo || exit 1 find . -name "*" -if [[ ! -f "argocd/${LAYER}/cluster/${SERVER_NAME}/${TYPE}/${NAMESPACE}-${COMPONENT_NAME}.yaml" ]]; then - echo "ArgoCD config missing - argocd/${LAYER}/cluster/${SERVER_NAME}/${TYPE}/${NAMESPACE}-${COMPONENT_NAME}.yaml" - exit 1 -fi - -echo "Printing argocd/${LAYER}/cluster/${SERVER_NAME}/${TYPE}/${NAMESPACE}-${COMPONENT_NAME}.yaml" -cat "argocd/${LAYER}/cluster/${SERVER_NAME}/${TYPE}/${NAMESPACE}-${COMPONENT_NAME}.yaml" -echo "Printing payload/${LAYER}/namespace/${NAMESPACE}/${COMPONENT_NAME}/values.yaml" -cat "payload/${LAYER}/namespace/${NAMESPACE}/${COMPONENT_NAME}/values.yaml" - -count=0 -until kubectl get namespace "${NAMESPACE}" 1> /dev/null 2> /dev/null || [[ $count -eq 20 ]]; do - echo "Waiting for namespace: ${NAMESPACE}" - count=$((count + 1)) - sleep 15 -done - -if [[ $count -eq 20 ]]; then - echo "Timed out waiting for namespace: ${NAMESPACE}" - exit 1 -else - echo "Found namespace: ${NAMESPACE}. Sleeping for 30 seconds to wait for everything to settle down" - sleep 30 -fi +validate_gitops_content "${NAMESPACE}" "${LAYER}" "${SERVER_NAME}" "${TYPE}" "${COMPONENT_NAME}" "values.yaml" +check_k8s_namespace "${NAMESPACE}" +## testing for operator separtely here because it only needs 30min timer, the other deployments need much longer count=0 until kubectl get deployment ibm-mas-manage-operator -n ${NAMESPACE} || [[ $count -eq 30 ]]; do echo "Waiting for deployment/ibm-mas-manage-operator in ${NAMESPACE}" @@ -78,57 +61,16 @@ if [[ $count -eq 30 ]]; then fi ## workspace rollout -count=0 -until kubectl get deployment ${INSTNAME}-entitymgr-ws -n ${NAMESPACE} || [[ $count -eq 50 ]]; do - echo "Waiting for deployment/${INSTNAME}-entitymgr-ws in ${NAMESPACE}" - count=$((count + 1)) - sleep 60 -done - -if [[ $count -eq 50 ]]; then - echo "Timed out waiting for deployment/${APPNAME}-entitymgr-ws in ${NAMESPACE}" - kubectl get all -n "${NAMESPACE}" - exit 1 -fi - -kubectl get deployments -n ${NAMESPACE} +check_k8s_resource "${NAMESPACE}" deployment "${INSTNAME}-entitymgr-ws" ## maxinst deployment must succeed or nothing will work - this can take up to 4.5hrs if demo data is deployed too -count=0 -until kubectl get deployment ${WSNAME}-manage-maxinst -n ${NAMESPACE} || [[ $count -eq 200 ]]; do - echo "Waiting for deployment/${WSNAME}-manage-maxinst in ${NAMESPACE}" - count=$((count + 1)) - sleep 1m -done - -if [[ $count -eq 200 ]]; then - echo "Timed out waiting for deployment/${WSNAME}-manage-maxinst in ${NAMESPACE}" - kubectl get all -n "${NAMESPACE}" - exit 1 -fi - - -kubectl get deployments -n ${NAMESPACE} +check_k8s_resource "${NAMESPACE}" deployment "${WSNAME}-manage-maxinst" ## last test for all deploy -count=0 -until kubectl get deployment ${WSNAME}-all -n ${NAMESPACE} || [[ $count -eq 200 ]]; do - echo "Waiting for deployment/${WSNAME}-all in ${NAMESPACE}" - count=$((count + 1)) - sleep 1m -done - -if [[ $count -eq 200 ]]; then - echo "Timed out waiting for deployment/${WSNAME}-all in ${NAMESPACE}" - kubectl get all -n "${NAMESPACE}" - exit 1 -fi +check_k8s_resource "${NAMESPACE}" deployment "${WSNAME}-all" kubectl get deployments -n ${NAMESPACE} - - - cd .. rm -rf .testrepo diff --git a/.github/scripts/validation-functions.sh b/.github/scripts/validation-functions.sh new file mode 100755 index 0000000..51c639f --- /dev/null +++ b/.github/scripts/validation-functions.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +validate_gitops_content () { + local NS="$1" + local GITOPS_LAYER="$2" + local GITOPS_SERVER_NAME="$3" + local GITOPS_TYPE="$4" + local GITOPS_COMPONENT_NAME="$5" + local PAYLOAD_FILE="${6:-values.yaml}" + + echo "Validating: namespace=${NS}, layer=${GITOPS_LAYER}, server=${GITOPS_SERVER_NAME}, type=${GITOPS_TYPE}, component=${GITOPS_COMPONENT_NAME}" + + if [[ ! -f "argocd/${GITOPS_LAYER}/cluster/${GITOPS_SERVER_NAME}/${GITOPS_TYPE}/${NS}-${GITOPS_COMPONENT_NAME}.yaml" ]]; then + echo "ArgoCD config missing - argocd/${GITOPS_LAYER}/cluster/${GITOPS_SERVER_NAME}/${GITOPS_TYPE}/${NS}-${GITOPS_COMPONENT_NAME}.yaml" >&2 + exit 1 + fi + + echo "Printing argocd/${GITOPS_LAYER}/cluster/${GITOPS_SERVER_NAME}/${GITOPS_TYPE}/${NS}-${GITOPS_COMPONENT_NAME}.yaml" + cat "argocd/${GITOPS_LAYER}/cluster/${GITOPS_SERVER_NAME}/${GITOPS_TYPE}/${NS}-${GITOPS_COMPONENT_NAME}.yaml" + + if [[ ! -f "payload/${GITOPS_LAYER}/namespace/${NS}/${GITOPS_COMPONENT_NAME}/${PAYLOAD_FILE}" ]]; then + echo "Application values not found - payload/${GITOPS_LAYER}/namespace/${NS}/${GITOPS_COMPONENT_NAME}/${PAYLOAD_FILE}" >&2 + exit 1 + fi + + echo "Printing payload/${GITOPS_LAYER}/namespace/${NS}/${GITOPS_COMPONENT_NAME}/${PAYLOAD_FILE}" + cat "payload/${GITOPS_LAYER}/namespace/${NS}/${GITOPS_COMPONENT_NAME}/${PAYLOAD_FILE}" +} + +check_k8s_namespace () { + local NS="$1" + + count=0 + until kubectl get namespace "${NS}" 1> /dev/null 2> /dev/null || [[ $count -eq 20 ]]; do + echo "Waiting for namespace: ${NS}" + count=$((count + 1)) + sleep 15 + done + + if [[ $count -eq 20 ]]; then + echo "Timed out waiting for namespace: ${NS}" >&2 + exit 1 + else + echo "Found namespace: ${NS}. Sleeping for 30 seconds to wait for everything to settle down" + sleep 30 + fi +} + +check_k8s_resource () { + local NS="$1" + local GITOPS_TYPE="$2" + local NAME="$3" + + echo "Checking for resource: ${NS}/${GITOPS_TYPE}/${NAME}" + + count=0 + until kubectl get "${GITOPS_TYPE}" "${NAME}" -n "${NS}" 1> /dev/null 2> /dev/null || [[ $count -gt 200 ]]; do + echo "Waiting for ${GITOPS_TYPE}/${NAME} in ${NS}" + count=$((count + 1)) + sleep 60 + done + + if [[ $count -gt 200 ]]; then + echo "Timed out waiting for ${GITOPS_TYPE}/${NAME}" >&2 + kubectl get "${GITOPS_TYPE}" -n "${NS}" + exit 1 + fi + + kubectl get "${GITOPS_TYPE}" "${NAME}" -n "${NS}" -o yaml + + if [[ "${GITOPS_TYPE}" =~ deployment|statefulset|daemonset ]]; then + kubectl rollout status "${GITOPS_TYPE}" "${NAME}" -n "${NS}" || exit 1 + elif [[ "${GITOPS_TYPE}" == "job" ]]; then + kubectl wait --for=condition=complete "job/${NAME}" -n "${NS}" || exit 1 + fi + + echo "Done checking for resource: ${NS}/${GITOPS_TYPE}/${NAME}" +} \ No newline at end of file diff --git a/.github/workflows/verify-pr.yaml b/.github/workflows/verify-pr.yaml index ffba38b..9b018c1 100644 --- a/.github/workflows/verify-pr.yaml +++ b/.github/workflows/verify-pr.yaml @@ -13,7 +13,7 @@ jobs: #uses: cloud-native-toolkit/action-workflows/.github/workflows/verify-gitops-module.yaml@v1 uses: ./.github/workflows/verify-workflow.yaml with: - testcase: ocp4_latest_gitops_maximo + testcase: ocp4_latest_gitops_maximo_manage secrets: GIT_ORG: ${{ secrets.GIT_ORG }} AWS_CLUSTER_USERNAME: ${{ secrets.AWS_CLUSTER_USERNAME }} diff --git a/.github/workflows/verify-workflow.yaml b/.github/workflows/verify-workflow.yaml index f578e84..be13fab 100644 --- a/.github/workflows/verify-workflow.yaml +++ b/.github/workflows/verify-workflow.yaml @@ -8,7 +8,7 @@ on: testcase: required: true type: string - default: ocp4_latest_gitops_maximo + default: ocp4_latest_gitops_maximo_manage skipDestroy: required: false type: string diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index ec7ac32..b42e061 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -13,7 +13,7 @@ jobs: #uses: cloud-native-toolkit/action-workflows/.github/workflows/verify-gitops-module.yaml@v1 uses: ./.github/workflows/verify-workflow.yaml with: - testcase: ocp4_latest_gitops_maximo + testcase: ocp4_latest_gitops_maximo_manage secrets: GIT_ORG: ${{ secrets.GIT_ORG }} AWS_CLUSTER_USERNAME: ${{ secrets.AWS_CLUSTER_USERNAME }} diff --git a/README.md b/README.md index 9a23d1e..645a23c 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,46 @@ -# Maximo Application Suite - MAS Application Gitops terraform module -![Verify and release module](https://github.com/cloud-native-toolkit/terraform-gitops-mas-manage/workflows/Verify%20and%20release%20module/badge.svg) +# Maximo Application Suite - MAS Manage Application Gitops terraform module -Deploys the MAS applications as part of Maximo Application Suite via gitops. To run, download the BOM (Bill of Materials) from the module catalog and build the terraform from there. Specify the MAS-Core instance id - in the `instanceid` variable. This will create a namespace of the name "mas-(instanceid)-(appid)". + +Deploys MAS Manage applications as part of Maximo Application Suite via gitops. To run, download the BOM (Bill of Materials) from the module catalog and build the terraform from there. Specify the MAS-Core instance id - in the `instanceid` variable. This will create a namespace of the name `mas-(instanceid)-manage`. Note if your cluster is not setup for gitops, download the gitops bootstrap BOM from the module catalog first to setup the gitops tooling. +## Supported Manage Industry Add-on solutions +This module currently supports installing the following add-ons with MAS Manage: +- Health +- Civil Infrastructure + +Override the `addons` variable such that it looks like the following to deploy health with Manage: + +`addons = ["health"]` + +To deploy Civil Infrastructure use: + +`addons = ["civil"]` + +The other industry solutions follow the same format and are comma separated if more than one is needed. Note be sure to check MAS requirements as not all industry solutions can be deployed together. + +## Database re-use +(skip if this is a new install and not re-using a database) + +You can reuse an existing Manage database by setting: `reuse_db = true` when calling the module. If you are re-using the database then you must supply the `crypto` and `cryptox` keys from the previous install of Manage that encrypted the database or this new Manage install will fail when trying to access the database. NOTE: The cypto keys are base64 encoded. If you are copying the two crypto keys from a previous install directly from the cluster and for example download the `demo-manage-encryptionsecret.yaml` within the `manage` namespace, these will already have been base64 encoded and require you to decode them before setting them in the below two variables. If not done, they will end up base6 encoded twice and the installation will not succeed. + +You can decode a key by running the following from a terminal prompt: + +`echo -n (your base64 key) | base64 --decode` + +``` + crypto_key = var.database_crypto_key + cryptox_key = var.database_cryptox_key +``` + +## DB2Warehouse Setup +If you are using DB2 Warehouse as your supported database, before you can install MAS Manage, DB2 Warehouse needs to be setup and requires DB2 administration tasks to be run. It is recommended a DB2 specialist run the script: `db2_manage_upd.sh` found in the `scripts` directory of this repository. + + ## Supported platforms -- OCP 4.6+ +- OCP 4.8+ ## Suggested companion modules @@ -37,6 +70,9 @@ module "mas_manage" { entitlement_key = module.catalog.entitlement_key instanceid = "mas8" appid = "manage" + workspace_id = "demo" + demodata = true + addons = ["health"] } ``` diff --git a/chart/ibm-masapp-manage-operator/.helmignore b/chart/ibm-masapp-manage-operator/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/chart/ibm-masapp-manage-operator/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/chart/ibm-masapp-manage-operator/Chart.yaml b/chart/ibm-masapp-manage-operator/Chart.yaml new file mode 100644 index 0000000..bba2bc9 --- /dev/null +++ b/chart/ibm-masapp-manage-operator/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: ibm-masapp-manage-operator +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 1.0.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.0.0" diff --git a/chart/ibm-masapp-manage-operator/templates/_helpers.tpl b/chart/ibm-masapp-manage-operator/templates/_helpers.tpl new file mode 100644 index 0000000..8c81b23 --- /dev/null +++ b/chart/ibm-masapp-manage-operator/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "ibm-masapp-manage-operator.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "ibm-masapp-manage-operator.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "ibm-masapp-manage-operator.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ibm-masapp-manage-operator.labels" -}} +helm.sh/chart: {{ include "ibm-masapp-manage-operator.chart" . }} +{{ include "ibm-masapp-manage-operator.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ibm-masapp-manage-operator.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ibm-masapp-manage-operator.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "ibm-masapp-manage-operator.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "ibm-masapp-manage-operator.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/chart/ibm-masapp-manage/templates/subscription.yaml b/chart/ibm-masapp-manage-operator/templates/subscription.yaml similarity index 86% rename from chart/ibm-masapp-manage/templates/subscription.yaml rename to chart/ibm-masapp-manage-operator/templates/subscription.yaml index e73fddf..2a09636 100644 --- a/chart/ibm-masapp-manage/templates/subscription.yaml +++ b/chart/ibm-masapp-manage-operator/templates/subscription.yaml @@ -3,7 +3,7 @@ kind: Subscription metadata: name: {{ .Values.masapp.name }} labels: - {{- include "ibm-masapp-manage.labels" . | nindent 4 }} + {{- include "ibm-masapp-manage-operator.labels" . | nindent 4 }} annotations: argocd.argoproj.io/sync-wave: "-1" spec: diff --git a/chart/ibm-masapp-manage-operator/values.yaml b/chart/ibm-masapp-manage-operator/values.yaml new file mode 100644 index 0000000..2d37e9f --- /dev/null +++ b/chart/ibm-masapp-manage-operator/values.yaml @@ -0,0 +1,4 @@ +# Default values for ibm-masapp-manage-operator. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + diff --git a/chart/ibm-masapp-manage/templates/workspace.yaml b/chart/ibm-masapp-manage/templates/workspace.yaml index a01a87e..ba30057 100644 --- a/chart/ibm-masapp-manage/templates/workspace.yaml +++ b/chart/ibm-masapp-manage/templates/workspace.yaml @@ -15,9 +15,13 @@ spec: components: base: version: latest +{{- range .Values.addons }} +{{ . | nindent 4 }}: + version: latest +{{ end }} settings: aio: - install: true + install: false db: dbSchema: "{{ .Values.workspace.dbschema }}" {{- if .Values.masapp.reuse_db }} diff --git a/main.tf b/main.tf index 7aaf0f6..33514d7 100644 --- a/main.tf +++ b/main.tf @@ -1,14 +1,17 @@ locals { name = "ibm-masapp-manage" + operator_name = "ibm-masapp-manage-operator" bin_dir = module.setup_clis.bin_dir tmp_dir = "${path.cwd}/.tmp/${local.name}" yaml_dir = "${local.tmp_dir}/chart/${local.name}" - secret_dir = "${path.cwd}/.tmp/${local.namespace}/${local.name}/secrets" - workspace_name = "${var.instanceid}-${var.workspace_id}" - cr_secret_name = "${var.workspace_id}-${var.appid}-encryptionsecret" + operator_yaml_dir = "${local.tmp_dir}/chart/${local.operator_name}" + secret_dir = "${path.cwd}/.tmp/${local.namespace}/${local.name}/secrets" + workspace_name = "${var.instanceid}-${var.workspace_id}" + cr_secret_name = "${var.workspace_id}-${var.appid}-encryptionsecret" layer = "services" - type = "base" + type = "instances" + operator_type = "operators" application_branch = "main" appname = "ibm-mas-${var.appid}" namespace = "mas-${var.instanceid}-${var.appid}" @@ -29,17 +32,23 @@ locals { reuse_db = var.reuse_db cr_secret_name = local.cr_secret_name } + workspace = { + name = local.workspace_name + dbschema = var.db_schema + } + } + values_content_operator = { + masapp = { + name = local.appname + } subscription = { channel = var.channel installPlanApproval = local.installPlan source = var.catalog sourceNamespace = var.catalog_namespace } - workspace = { - name = local.workspace_name - dbschema = var.db_schema - } } + } module setup_clis { @@ -92,9 +101,9 @@ module seal_secrets { source = "github.com/cloud-native-toolkit/terraform-util-seal-secrets.git" source_dir = local.secret_dir - dest_dir = "${local.yaml_dir}/templates" + dest_dir = "${local.operator_yaml_dir}/templates" kubeseal_cert = var.kubeseal_cert - label = local.name + label = local.operator_name } @@ -127,10 +136,29 @@ module "jdbc_config"{ db_url = var.db_url } -# Add values for charts + +# Add values for operator chart +resource "null_resource" "deployAppValsOperator" { + + provisioner "local-exec" { + command = "${path.module}/scripts/create-operator-yaml.sh '${local.operator_name}' '${local.operator_yaml_dir}'" + + environment = { + VALUES_CONTENT = yamlencode(local.values_content_operator) + } + } +} + + +# Add values for instance charts resource "null_resource" "deployAppVals" { + + triggers = { + addons = join(",", var.addons) + } + provisioner "local-exec" { - command = "${path.module}/scripts/create-yaml.sh '${local.name}' '${local.yaml_dir}'" + command = "${path.module}/scripts/create-yaml.sh '${local.name}' '${local.yaml_dir}' '${self.triggers.addons}'" environment = { VALUES_CONTENT = yamlencode(local.values_content) @@ -138,9 +166,24 @@ resource "null_resource" "deployAppVals" { } } -# Deploy +# Deploy Operator +resource gitops_module masapp_operator { + depends_on = [null_resource.deployAppValsOperator, module.sbo, module.jdbc_config, module.pullsecret] + + name = local.operator_name + namespace = local.namespace + content_dir = local.operator_yaml_dir + server_name = var.server_name + layer = local.layer + type = local.operator_type + branch = local.application_branch + config = yamlencode(var.gitops_config) + credentials = yamlencode(var.git_credentials) +} + +# Deploy Instance resource gitops_module masapp { - depends_on = [null_resource.deployAppVals, module.sbo, module.jdbc_config, module.pullsecret] + depends_on = [gitops_module.masapp_operator] name = local.name namespace = local.namespace diff --git a/scripts/create-operator-yaml.sh b/scripts/create-operator-yaml.sh new file mode 100755 index 0000000..223201b --- /dev/null +++ b/scripts/create-operator-yaml.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +CHARTNAME="$1" +DEST_DIR="$2" + +SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P) +MODULE_DIR=$(cd "${SCRIPT_DIR}/.."; pwd -P) +CHART_DIR=$(cd "${MODULE_DIR}/chart/${CHARTNAME}"; pwd -P) + +mkdir -p "${DEST_DIR}" + +## put the yaml resource content in DEST_DIR +cp -R "${CHART_DIR}"/* "${DEST_DIR}" + +if [[ -n "${VALUES_CONTENT}" ]]; then + echo "${VALUES_CONTENT}" > "${DEST_DIR}/values.yaml" +fi diff --git a/scripts/create-yaml.sh b/scripts/create-yaml.sh index dd7fe35..9864ff1 100755 --- a/scripts/create-yaml.sh +++ b/scripts/create-yaml.sh @@ -2,6 +2,7 @@ CHARTNAME="$1" DEST_DIR="$2" +ADDONS="$3" SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P) MODULE_DIR=$(cd "${SCRIPT_DIR}/.."; pwd -P) @@ -16,4 +17,21 @@ if [[ -n "${VALUES_CONTENT}" ]]; then echo "${VALUES_CONTENT}" > "${DEST_DIR}/values.yaml" fi +## addons as needed to deploy with manage +cat >> ${DEST_DIR}/values.yaml << EOL +addons: +EOL + if [[ "${ADDONS}" =~ health ]]; then + echo "adding health ..." + cat >> ${DEST_DIR}/values.yaml << EOL + - health +EOL + fi + + if [[ "${ADDONS}" =~ civil ]]; then + echo "adding civil infrastructure ..." + cat >> ${DEST_DIR}/values.yaml << EOL + - civil +EOL + fi diff --git a/scripts/db2_manage_upd.sh b/scripts/db2_manage_upd.sh new file mode 100755 index 0000000..0d67b2b --- /dev/null +++ b/scripts/db2_manage_upd.sh @@ -0,0 +1,67 @@ +#!/usr/bin/bash +db2 connect to BLUDB +db2 update db cfg for BLUDB using dft_table_org row +db2 update db cfg for BLUDB using LOGARCHMETH1 off +db2 update db cfg for BLUDB using SELF_TUNING_MEM ON +db2 update db cfg for BLUDB using APPGROUP_MEM_SZ 16384 DEFERRED +db2 update db cfg for BLUDB using APPLHEAPSZ 2048 AUTOMATIC DEFERRED +db2 update db cfg for BLUDB using AUTO_MAINT ON DEFERRED +db2 update db cfg for BLUDB using AUTO_TBL_MAINT ON DEFERRED +db2 update db cfg for BLUDB using AUTO_RUNSTATS ON DEFERRED +db2 update db cfg for BLUDB using AUTO_REORG ON DEFERRED +db2 update db cfg for BLUDB using AUTO_DB_BACKUP ON DEFERRED +db2 update db cfg for BLUDB using CATALOGCACHE_SZ 800 DEFERRED +db2 update db cfg for BLUDB using CHNGPGS_THRESH 40 DEFERRED +db2 update db cfg for BLUDB using DBHEAP AUTOMATIC +db2 update db cfg for BLUDB using LOCKLIST AUTOMATIC DEFERRED +db2 update db cfg for BLUDB using LOGBUFSZ 1024 DEFERRED +db2 update db cfg for BLUDB using LOCKTIMEOUT 300 DEFERRED +db2 update db cfg for BLUDB using LOGPRIMARY 20 DEFERRED +db2 update db cfg for BLUDB using LOGSECOND 100 DEFERRED +db2 update db cfg for BLUDB using LOGFILSIZ 8192 DEFERRED +db2 update db cfg for BLUDB using SOFTMAX 1000 DEFERRED +db2 update db cfg for BLUDB using MAXFILOP 61440 DEFERRED +db2 update db cfg for BLUDB using PCKCACHESZ AUTOMATIC DEFERRED +db2 update db cfg for BLUDB using STAT_HEAP_SZ AUTOMATIC DEFERRED +db2 update db cfg for BLUDB using STMTHEAP AUTOMATIC DEFERRED +db2 update db cfg for BLUDB using UTIL_HEAP_SZ 10000 DEFERRED +db2 update db cfg for BLUDB using DATABASE_MEMORY AUTOMATIC DEFERRED +db2 update db cfg for BLUDB using AUTO_STMT_STATS OFF DEFERRED +db2 update db cfg for BLUDB using STMT_CONC LITERALS DEFERRED +db2 update alert cfg for database on BLUDB using db.db_backup_req SET THRESHOLDSCHECKED YES +db2 update alert cfg for database on BLUDB using db.tb_reorg_req SET THRESHOLDSCHECKED YES +db2 update alert cfg for database on BLUDB using db.tb_runstats_req SET THRESHOLDSCHECKED YES +db2 update dbm cfg using PRIV_MEM_THRESH 32767 DEFERRED +db2 update dbm cfg using KEEPFENCED NO DEFERRED +db2 update dbm cfg using NUMDB 2 DEFERRED +db2 update dbm cfg using RQRIOBLK 65535 DEFERRED +db2 update dbm cfg using HEALTH_MON OFF DEFERRED +db2 update dbm cfg using AGENT_STACK_SZ 1000 DEFERRED +db2 update dbm cfg using MON_HEAP_SZ AUTOMATIC DEFERRED +db2 update db cfg using DDL_CONSTRAINT_DEF YES +db2set DB2_SKIPINSERTED=ON +db2set DB2_INLIST_TO_NLJN=YES +db2set DB2_MINIMIZE_LISTPREFETCH=Y +db2set DB2_EVALUNCOMMITTED=YES +db2set DB2_FMP_COMM_HEAPSZ=65536 +db2set DB2_SKIPDELETED=ON +db2set DB2_USE_ALTERNATE_PAGE_CLEANING=ON +db2 CREATE BUFFERPOOL MAXBUFPOOL IMMEDIATE SIZE 4096 AUTOMATIC PAGESIZE 32 K +db2 CREATE REGULAR TABLESPACE MAXDATA PAGESIZE 32 K MANAGED BY AUTOMATIC STORAGE INITIALSIZE 5000 M BUFFERPOOL MAXBUFPOOL +db2 CREATE TEMPORARY TABLESPACE MAXTEMP PAGESIZE 32 K MANAGED BY AUTOMATIC STORAGE BUFFERPOOL MAXBUFPOOL +db2 CREATE REGULAR TABLESPACE MAXINDEX PAGESIZE 32 K MANAGED BY AUTOMATIC STORAGE INITIALSIZE 5000 M BUFFERPOOL MAXBUFPOOL +db2 CREATE SCHEMA MAXIMO AUTHORIZATION MAXIMO +db2 GRANT DBADM,CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,IMPLICIT_SCHEMA,LOAD,CREATE_EXTERNAL_ROUTINE,QUIESCE_CONNECT,SECADM ON DATABASE TO USER MAXIMO +db2 GRANT USE OF TABLESPACE MAXDATA TO USER MAXIMO +db2 GRANT CREATEIN,DROPIN,ALTERIN ON SCHEMA MAXIMO TO USER MAXIMO + +db2 connect reset +db2 terminate +db2 force applications all +db2 deactivate db BLUDB +db2stop +db2start +db2 activate db bludb + +db2 get db cfg for BLUDB | grep -i org +db2 get db cfg for BLUDB | grep LOGARCHMETH \ No newline at end of file diff --git a/test/stages/provider.tf b/test/stages/provider.tf index 5e2e8ce..23c4a99 100644 --- a/test/stages/provider.tf +++ b/test/stages/provider.tf @@ -6,4 +6,10 @@ provider "gitops" { username = var.git_username token = var.git_token bin_dir = module.setup_clis.bin_dir +} + +resource local_file bin_dir { + filename = "${path.cwd}/.bin_dir" + + content = module.setup_clis.bin_dir } \ No newline at end of file diff --git a/test/stages/stage2-mas-app.tf b/test/stages/stage2-mas-app.tf index 88a4272..def2029 100644 --- a/test/stages/stage2-mas-app.tf +++ b/test/stages/stage2-mas-app.tf @@ -18,6 +18,7 @@ module "gitops_module" { crypto_key = var.database_crypto_key cryptox_key = var.database_cryptox_key reuse_db = true + //addons = ["health"] //add to deploy health } diff --git a/variables.tf b/variables.tf index 34160f8..06a1bf3 100644 --- a/variables.tf +++ b/variables.tf @@ -176,3 +176,9 @@ variable "cryptox_key" { default = "" sensitive = true } + +variable "addons" { + description = "comma separated list of quoted Manage app addons to deploy along with Manage. Current valid addons: health, civil" + type = list(string) + default = [] +}