From 80d96a1e96a11dbd81b538e9b2f54aba82a15f33 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 29 Oct 2024 08:14:43 +0000 Subject: [PATCH 01/51] #820 Add --dry-run parameter --- .../validate-variables-destroy/tasks/main.yml | 7 +++++++ .../10-validation/validate-variables/tasks/main.yml | 7 +++++++ cp-deploy.sh | 12 +++++++++++- docker-scripts/run_automation.sh | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/automation-roles/10-validation/validate-variables-destroy/tasks/main.yml b/automation-roles/10-validation/validate-variables-destroy/tasks/main.yml index b4af7dffe..0a87c3626 100644 --- a/automation-roles/10-validation/validate-variables-destroy/tasks/main.yml +++ b/automation-roles/10-validation/validate-variables-destroy/tasks/main.yml @@ -10,6 +10,13 @@ fail: msg="cloud_platform {{ cloud_platform }} only support values {{ supported_cloud_platform_types }} " when: "cloud_platform not in supported_cloud_platform_types" +- name: "Fail if dry-run specified for other cloud platform than existing-ocp" + fail: + msg: "--dry-run can only be specified for existing-ocp" + when: + - cpd_dry_run | bool + - cloud_platform != 'existing-ocp' + - include_tasks: ibmcloud-validate-variables.yml when: - cloud_platform == 'ibm-cloud' diff --git a/automation-roles/10-validation/validate-variables/tasks/main.yml b/automation-roles/10-validation/validate-variables/tasks/main.yml index bc5f1a6f7..9d3c840ae 100644 --- a/automation-roles/10-validation/validate-variables/tasks/main.yml +++ b/automation-roles/10-validation/validate-variables/tasks/main.yml @@ -10,6 +10,13 @@ fail: msg="cloud_platform {{ cloud_platform }} only support values {{ supported_cloud_platform_types }} " when: "cloud_platform not in supported_cloud_platform_types" +- name: "Fail if dry-run specified for other cloud platform than existing-ocp" + fail: + msg: "--dry-run can only be specified for existing-ocp" + when: + - cpd_dry_run | bool + - cloud_platform != 'existing-ocp' + - include_tasks: ibmcloud-validate-variables.yml when: - cloud_platform == 'ibm-cloud' diff --git a/cp-deploy.sh b/cp-deploy.sh index 59dd83735..e24c8c76a 100755 --- a/cp-deploy.sh +++ b/cp-deploy.sh @@ -48,7 +48,8 @@ command_usage() { echo " --skip-infra Skip infrastructure provisioning and configuration (\$CPD_SKIP_INFRA)" echo " --skip-cp-install Skip installation of the Cloud Pak and finish after configuring the OpenShift cluster (\$SKIP_CP_INSTALL)" echo " --cp-config-only Skip all infrastructure provisioning and cloud pak deployment tasks and only run the Cloud Pak configuration tasks" - echo " --check-only Skip all provisioning and deployment tasks. Only run the validation and generation." + echo " --check-only Skip all provisioning and deployment tasks. Only run the validation and generation" + echo " --dry-run Only log the steps that will be performed, do not make any changes to the OpenShift cluster" echo " --air-gapped Only for environment subcommand; if specified the deployer is considered to run in an air-gapped environment (\$CPD_AIRGAP)" echo " --skip-mirror-images Pertains to env apply and env download. When specified, the mirroring of images to the private registry is skipped (\$CPD_SKIP_MIRROR)" echo " --skip-portable-registry Pertains to env download. When specified, no portable registry is used to transport the images (\$CPD_SKIP_PORTABLE_REGISTRY)" @@ -541,6 +542,14 @@ while (( "$#" )); do export CHECK_ONLY=true shift 1 ;; + --dry-run) + if [[ "${ACTION}" != "apply" && "${ACTION}" != "destroy" ]];then + echo "Error: --dry-run is only valid for environment subcommand with apply/destroy." + command_usage 2 + fi + export CPD_DRY_RUN=true + shift 1 + ;; --air-gapped) if ${INSIDE_CONTAINER};then echo "$1 flag not allowed when running inside container" @@ -1031,6 +1040,7 @@ if ! $INSIDE_CONTAINER;then run_cmd+=" -e CPD_SKIP_CP_INSTALL=${CPD_SKIP_CP_INSTALL}" run_cmd+=" -e CP_CONFIG_ONLY=${CP_CONFIG_ONLY}" run_cmd+=" -e CHECK_ONLY=${CHECK_ONLY}" + run_cmd+=" -e CPD_DRY_RUN=${CPD_DRY_RUN}" run_cmd+=" -e CPD_AIRGAP=${CPD_AIRGAP}" run_cmd+=" -e CPD_SKIP_MIRROR=${CPD_SKIP_MIRROR}" run_cmd+=" -e CPD_SKIP_PORTABLE_REGISTRY=${CPD_SKIP_PORTABLE_REGISTRY}" diff --git a/docker-scripts/run_automation.sh b/docker-scripts/run_automation.sh index ef3b0a156..d78b327d0 100755 --- a/docker-scripts/run_automation.sh +++ b/docker-scripts/run_automation.sh @@ -79,6 +79,7 @@ env|environment) run_cmd+=" --extra-vars cpd_skip_infra=${CPD_SKIP_INFRA}" run_cmd+=" --extra-vars cp_config_only=${CP_CONFIG_ONLY}" run_cmd+=" --extra-vars cpd_check_only=${CHECK_ONLY}" + run_cmd+=" --extra-vars cpd_dry_run=${CPD_DRY_RUN}" run_cmd+=" --extra-vars cpd_airgap=${CPD_AIRGAP}" run_cmd+=" --extra-vars cpd_skip_mirror=${CPD_SKIP_MIRROR}" run_cmd+=" --extra-vars cpd_skip_cp_install=${CPD_SKIP_CP_INSTALL}" From 50f7c81d8b758da14b9a0f5bf0208c25ad7b427d Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 29 Oct 2024 22:04:33 +0000 Subject: [PATCH 02/51] #820 Create logging role --- .../tasks/log-deployer-command.yml | 17 +++++++++++++++++ .../log-deployer-activity/tasks/main.yml | 6 ++++++ 2 files changed, 23 insertions(+) create mode 100644 automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-command.yml create mode 100644 automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-command.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-command.yml new file mode 100644 index 000000000..9fc58e3b6 --- /dev/null +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-command.yml @@ -0,0 +1,17 @@ +--- +- name: Write deployer activity to {{ status_dir }}/log/deployer-actitivies.log + blockinfile: + path: "{{ status_dir }}/log/deployer-actitivies.log" + create: True + insertafter: EOF + marker: "" + block: | + + # --- + # + # Activity timestamp: {{ now(utc=true,fmt='%Y-%m-%d %H:%M:%S') }} + # Deployer activity: {{ _deployer_activity_sequence }} + # Description: {{ _p_activity_description | default("") }} + # Command: + {{ _p_activity_command }} + # --- \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml new file mode 100644 index 000000000..68025d0dc --- /dev/null +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- set_fact: + _deployer_activity_sequence: "{{ (_deployer_activity_sequence | default(0)) + 1 }}" + +- include_tasks: log-deployer-command.yml + when: _p_activity_command != '' \ No newline at end of file From fc70d36518b9e5ba61b099e8c30e8db0ff019563 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 29 Oct 2024 22:19:37 +0000 Subject: [PATCH 03/51] #820 dry-run for global pull secret --- .../tasks/cp4ba-prepare-openshift.yml | 3 +- .../tasks/cp4d-prepare-entitled-registry.yml | 7 ++--- .../tasks/cp4i-prepare-openshift.yml | 5 ++-- .../apply-global-pull-secret-entitled.yml | 15 ++++++++++ .../apply-global-pull-secret-private.yml | 19 ++++++++++++ .../cp-ocp-global-pull-secret/tasks/main.yml | 20 ++++--------- .../tasks/non-mco-apply-pull-secret.yml | 30 ++++++++++++++++++- .../add-cred-to-global-pull-secret.j2 | 3 ++ .../add-icr-cred-to-global-pull-secret.j2 | 1 + 9 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml create mode 100644 automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml create mode 100644 automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-cred-to-global-pull-secret.j2 create mode 100644 automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-icr-cred-to-global-pull-secret.j2 diff --git a/automation-roles/50-install-cloud-pak/cp4ba/cp4ba-prepare-openshift/tasks/cp4ba-prepare-openshift.yml b/automation-roles/50-install-cloud-pak/cp4ba/cp4ba-prepare-openshift/tasks/cp4ba-prepare-openshift.yml index 0352c4098..f1e2451ed 100644 --- a/automation-roles/50-install-cloud-pak/cp4ba/cp4ba-prepare-openshift/tasks/cp4ba-prepare-openshift.yml +++ b/automation-roles/50-install-cloud-pak/cp4ba/cp4ba-prepare-openshift/tasks/cp4ba-prepare-openshift.yml @@ -34,8 +34,7 @@ ansible.builtin.include_role: name: cp-ocp-global-pull-secret vars: - _p_registry_url: "{{ entitled_registry }}" - _p_registry_pull_secret: "cp:{{ ibm_cp_entitlement_key }}" + _p_ibm_cp_entitlement_key: "{{ ibm_cp_entitlement_key }}" when: (use_entitled_registry | bool) - name: Resume the Machine Config operator diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-prepare-openshift/tasks/cp4d-prepare-entitled-registry.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-prepare-openshift/tasks/cp4d-prepare-entitled-registry.yml index 9a894fc37..83ca8dddf 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-prepare-openshift/tasks/cp4d-prepare-entitled-registry.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-prepare-openshift/tasks/cp4d-prepare-entitled-registry.yml @@ -1,6 +1,6 @@ --- - name: Get IBM Entitled Registry key - include_role: + ansible.builtin.include_role: name: vault-get-secret vars: secret_name: "ibm_cp_entitlement_key" @@ -15,8 +15,7 @@ when: ibm_cp_entitlement_key == "" - name: Set the global pull secret for the entitled registry - include_role: + ansible.builtin.include_role: name: cp-ocp-global-pull-secret vars: - _p_registry_url: "{{ _v_entitled_registry }}" - _p_registry_pull_secret: "{{ _v_entitled_registry_username }}:{{ ibm_cp_entitlement_key }}" \ No newline at end of file + _p_ibm_cp_entitlement_key: "{{ ibm_cp_entitlement_key }}" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4i/cp4i-prepare-openshift/tasks/cp4i-prepare-openshift.yml b/automation-roles/50-install-cloud-pak/cp4i/cp4i-prepare-openshift/tasks/cp4i-prepare-openshift.yml index 7ff9e8226..902db1be0 100644 --- a/automation-roles/50-install-cloud-pak/cp4i/cp4i-prepare-openshift/tasks/cp4i-prepare-openshift.yml +++ b/automation-roles/50-install-cloud-pak/cp4i/cp4i-prepare-openshift/tasks/cp4i-prepare-openshift.yml @@ -53,11 +53,10 @@ # - name: Set the global pull secret for the entitled registry - include_role: + ansible.builtin.include_role: name: cp-ocp-global-pull-secret vars: - _p_registry_url: "{{ _v_entitled_registry }}" - _p_registry_pull_secret: "{{ _p_entitled_reg_auth }}" + _p_ibm_cp_entitlement_key: "{{ ibm_cp_entitlement_key }}" when: (_p_use_entitled_registry | bool) # diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml new file mode 100644 index 000000000..516495a61 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml @@ -0,0 +1,15 @@ +--- +- name: Generate add-icr-cred-to-global-pull-secret command to set global pull secret for entitled registry + set_fact: + _add_icr_cred_globl_pull_secret_command: "{{ lookup('template','add-icr-cred-to-global-pull-secret.j2') }} " + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Set global pull secret for entitled registry" + _p_activity_command: "{{ _add_icr_cred_globl_pull_secret_command }}" + +- name: Set global pull secret for entitled registry, output is in {{ status_dir }}/log/add-icr-cred-to-global-pull-secret.log + shell: | + {{ _add_icr_cred_globl_pull_secret_command }} | tee -a {{ status_dir }}/log/add-icr-cred-to-global-pull-secret.log + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml new file mode 100644 index 000000000..75fa46ec1 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml @@ -0,0 +1,19 @@ +--- +- set_fact: + _private_registry_user: "{{ _p_registry_pull_secret.split(':')[0] }}" + _private_registry_pass: "{{ _p_registry_pull_secret.split(':')[1] }}" + +- name: Generate add-cred-to-global-pull-secret command to set global pull secret for private registry {{ _p_registry_url }} + set_fact: + _add_cred_globl_pull_secret_command: "{{ lookup('template','add-cred-to-global-pull-secret.j2') }} " + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Set global pull secret for private registry {{ _p_registry_url }}" + _p_activity_command: "{{ _add_cred_globl_pull_secret_command }}" + +- name: Set global pull secret for private registry {{ _p_registry_url }}, output is in {{ status_dir }}/log/add-cred-to-global-pull-secret.log + shell: | + {{ _add_cred_globl_pull_secret_command }} | tee -a {{ status_dir }}/log/add-cred-to-global-pull-secret.log + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/main.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/main.yml index a725b7e02..b6f8b7b0b 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/main.yml @@ -1,17 +1,9 @@ --- -- name: Extract the global pull secret - shell: | - oc extract secret/pull-secret -n openshift-config --confirm --to={{ status_dir }}/openshift -- name: Set the global pull secret - shell: | - cat {{ status_dir }}/openshift/.dockerconfigjson | \ - jq --arg registry "{{ _p_registry_url }}" \ - --arg pull_secret $(echo -n "{{ _p_registry_pull_secret }}" | base64 -w0) \ - '.auths += {($registry): {"auth": $pull_secret, "email": "not-used"}}' \ - > {{ status_dir }}/openshift/newdockerconfigjson - oc set data secret/pull-secret -n openshift-config \ - --from-file=.dockerconfigjson={{ status_dir }}/openshift/newdockerconfigjson +- include_tasks: apply-global-pull-secret-entitled.yml + when: (_p_registry_url | default('')) == '' -- name: Apply pull secret if the Machine Config Operator does not exist - include_tasks: non-mco-apply-pull-secret.yml +- include_tasks: apply-global-pull-secret-private.yml + when: (_p_registry_url | default('')) != '' + +- include_tasks: non-mco-apply-pull-secret.yml when: not _mco_exists \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/non-mco-apply-pull-secret.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/non-mco-apply-pull-secret.yml index 3286d4228..2835edf16 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/non-mco-apply-pull-secret.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/non-mco-apply-pull-secret.yml @@ -1,5 +1,33 @@ --- +- set_fact: + _registry_pull_secret: "cp:{{ _p_ibm_cp_entitlement_key }}" + when: (_p_registry_url | default('')) == '' + +- set_fact: + _registry_pull_secret: "{{ _p_registry_pull_secret }}" + when: (_p_registry_url | default('')) != '' + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Set global pull secret for clusters that do not have the Machine Config Operator" + _p_activity_command: "# Global pull secret is applied from secret cloud-pak-node-fix-secrets in namespace kube-system" + +- name: Extract the global pull secret + shell: | + oc extract secret/pull-secret -n openshift-config --confirm --to={{ status_dir }}/openshift +- name: Set the global pull secret + shell: | + cat {{ status_dir }}/openshift/.dockerconfigjson | \ + jq --arg registry "{{ _p_registry_url }}" \ + --arg pull_secret $(echo -n "{{ _registry_pull_secret }}" | base64 -w0) \ + '.auths += {($registry): {"auth": $pull_secret, "email": "not-used"}}' \ + > {{ status_dir }}/openshift/newdockerconfigjson + oc set data secret/pull-secret -n openshift-config \ + --from-file=.dockerconfigjson={{ status_dir }}/openshift/newdockerconfigjson + - name: Add global pull secret to node fix secret shell: | oc set data -n kube-system secret/cloud-pak-node-fix-secrets \ - --from-file=newdockerconfigjson={{ status_dir }}/openshift/newdockerconfigjson \ No newline at end of file + --from-file=newdockerconfigjson={{ status_dir }}/openshift/newdockerconfigjson + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-cred-to-global-pull-secret.j2 b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-cred-to-global-pull-secret.j2 new file mode 100644 index 000000000..0d9c39de6 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-cred-to-global-pull-secret.j2 @@ -0,0 +1,3 @@ +add-cred-to-global-pull-secret --registry={{ _p_registry_url }} \ + --registry_pull_user={{ _private_registry_user }} \ + --registry_pull_password={{ _private_registry_pass }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-icr-cred-to-global-pull-secret.j2 b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-icr-cred-to-global-pull-secret.j2 new file mode 100644 index 000000000..519052ce3 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/templates/add-icr-cred-to-global-pull-secret.j2 @@ -0,0 +1 @@ +add-icr-cred-to-global-pull-secret --entitled_registry_key="{{ _p_ibm_cp_entitlement_key }}" \ No newline at end of file From 9283f2720900597b98536f8cbf76983d94a16033 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Wed, 30 Oct 2024 06:04:39 +0000 Subject: [PATCH 04/51] #820 Ensure Ansible fails of apply global pull secret fails --- .../tasks/apply-global-pull-secret-entitled.yml | 7 ++++--- .../tasks/apply-global-pull-secret-private.yml | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml index 516495a61..a9f5b2683 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-entitled.yml @@ -1,15 +1,16 @@ --- - name: Generate add-icr-cred-to-global-pull-secret command to set global pull secret for entitled registry set_fact: - _add_icr_cred_globl_pull_secret_command: "{{ lookup('template','add-icr-cred-to-global-pull-secret.j2') }} " + _add_icr_cred_global_pull_secret_command: "{{ lookup('template','add-icr-cred-to-global-pull-secret.j2') }} " - include_role: name: log-deployer-activity vars: _p_activity_description: "Set global pull secret for entitled registry" - _p_activity_command: "{{ _add_icr_cred_globl_pull_secret_command }}" + _p_activity_command: "{{ _add_icr_cred_global_pull_secret_command }}" - name: Set global pull secret for entitled registry, output is in {{ status_dir }}/log/add-icr-cred-to-global-pull-secret.log shell: | - {{ _add_icr_cred_globl_pull_secret_command }} | tee -a {{ status_dir }}/log/add-icr-cred-to-global-pull-secret.log + set -o pipefail + {{ _add_icr_cred_global_pull_secret_command }} | tee -a {{ status_dir }}/log/add-icr-cred-to-global-pull-secret.log when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml index 75fa46ec1..150dd6560 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml @@ -5,15 +5,16 @@ - name: Generate add-cred-to-global-pull-secret command to set global pull secret for private registry {{ _p_registry_url }} set_fact: - _add_cred_globl_pull_secret_command: "{{ lookup('template','add-cred-to-global-pull-secret.j2') }} " + _add_cred_global_pull_secret_command: "{{ lookup('template','add-cred-to-global-pull-secret.j2') }} " - include_role: name: log-deployer-activity vars: _p_activity_description: "Set global pull secret for private registry {{ _p_registry_url }}" - _p_activity_command: "{{ _add_cred_globl_pull_secret_command }}" + _p_activity_command: "{{ _aadd_cred_globl_pull_secret_command }}" - name: Set global pull secret for private registry {{ _p_registry_url }}, output is in {{ status_dir }}/log/add-cred-to-global-pull-secret.log shell: | - {{ _add_cred_globl_pull_secret_command }} | tee -a {{ status_dir }}/log/add-cred-to-global-pull-secret.log + set -o pipefail + {{ _aadd_cred_globl_pull_secret_command }} | tee -a {{ status_dir }}/log/add-cred-to-global-pull-secret.log when: not cpd_dry_run \ No newline at end of file From 74f6d6497a2dfed489d2e08106f744603ba4695a Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Wed, 30 Oct 2024 08:07:54 +0000 Subject: [PATCH 05/51] #820 Apply entitlement --- .../tasks/cp4d-apply-single-entitlement.yml | 27 ++++++++++--------- .../templates/apply-entitlement.j2 | 3 +-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/tasks/cp4d-apply-single-entitlement.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/tasks/cp4d-apply-single-entitlement.yml index ffcf045f3..f9ee67f91 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/tasks/cp4d-apply-single-entitlement.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/tasks/cp4d-apply-single-entitlement.yml @@ -1,19 +1,22 @@ --- -- name: Generate apply-entitlement command for entitlement {{ _p_entitlement }} +- name: Generate apply-entitlement script {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-entitlement-{{ _p_entitlement }}.sh for entitlement {{ _p_entitlement }} template: src: apply-entitlement.j2 dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-entitlement-{{ _p_entitlement }}.sh" mode: u=rwx -- name: Run apply-entitlement command, logs are in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-entitlement.log - shell: | - {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-entitlement-{{ _p_entitlement }}.sh - register: _apply_entitlement_result - retries: 5 - delay: 30 - until: _apply_entitlement_result.rc == 0 +- name: Generate apply-entitlement command for entitlement {{ _p_entitlement }} + set_fact: + _apply_entitlement_command: "{{ lookup('template','apply-entitlement.j2') }}" + +- 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) ... \ No newline at end of file + _p_activity_description: "Apply entitlement {{ _p_entitlement }}" + _p_activity_command: "{{ _apply_entitlement_command }}" + +- name: Apply entitlement {{ _p_entitlement }}, output is in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-entitlement.log + shell: | + set -o pipefail + {{ _apply_entitlement_command }} | tee -a {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-entitlement.log + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/templates/apply-entitlement.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/templates/apply-entitlement.j2 index d5744241b..09b1c1af9 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/templates/apply-entitlement.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/templates/apply-entitlement.j2 @@ -1,6 +1,5 @@ -set -o pipefail apply-entitlement \ --cpd_instance_ns={{ current_cp4d_cluster.project }} \ --entitlement={{ _p_entitlement }} \ --production={{ _p_cp4d_production_license }} \ - --apply_branding=true | tee -a {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-entitlement.log \ No newline at end of file + --apply_branding=true \ No newline at end of file From cd2963bd3e3126f4355111314b86f34c2532eb26 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Thu, 31 Oct 2024 20:25:06 +0000 Subject: [PATCH 06/51] #820 Cartridges dry-run --- .../cp4d-install-cartridges-olm-utils.yml | 47 +++--- .../tasks/cp4d-install-cr-dp.yml | 40 +++-- .../tasks/cp4d-install-cr-watson_ks.yml | 23 +-- .../tasks/cp4d-install-cr-ws_runtime.yml | 41 +++-- .../tasks/cp4d-install-separate-cr-apply.yml | 41 +++-- .../tasks/cp4d-pre-wd.yml | 7 + .../tasks/cp4d-prep-cpd-edb.yml | 9 +- .../tasks/cp4d-prep-watsonx-orchestrate.yml | 142 ++++++++++++------ .../tasks/cp4d-set-cartridge-options.yml | 17 ++- .../tasks/cp4d-set-cartridge-scaling.yml | 17 ++- .../tasks/cp4d-setup-mcg-secrets.yml | 8 + .../cp4d-cartridge-install/tasks/main.yml | 27 ++-- .../templates/apply-cr-cartridges.j2 | 2 +- .../templates/create-app-connect-catsrc.j2 | 5 + .../templates/set-cartridge-options.j2 | 4 + .../templates/set-cartridge-scaling.j2 | 4 + .../templates/setup-app-connect.j2 | 6 + .../setup-watsonx-assistant-instances.j2 | 6 + .../tasks/log-deployer-yaml-file.yml | 17 +++ .../log-deployer-activity/tasks/main.yml | 8 +- 20 files changed, 328 insertions(+), 143 deletions(-) create mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/create-app-connect-catsrc.j2 create mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-options.j2 create mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-scaling.j2 create mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-app-connect.j2 create mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-watsonx-assistant-instances.j2 create mode 100644 automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml index a865fcc63..094580312 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml @@ -44,25 +44,34 @@ debug: var: _apply_cr_command -- name: Run apply-cr command to install cartridges, 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 +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Run apply-cr command to install cartridges" + _p_activity_command: "{{ _apply_cr_command }}" -- name: Fail if there was an error installing the cartridge(s) using apply-cr - fail: - msg: "{{ _install_cartridges_result }}" - when: - - _install_cartridges_result.rc!=0 - - not (cpd_test_cartridges | default(False) | bool) +- block: + - name: Run apply-cr command to install cartridges, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log + shell: | + set -o pipefail + {{ _apply_cr_command }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log 2>&1 + register: _install_cartridges_result + failed_when: False -- set_fact: - _cp4d_cartridges_installed_successfully: False - when: _install_cartridges_result.rc!=0 + - name: Fail if there was an error installing the cartridge(s) using apply-cr + fail: + msg: "{{ _install_cartridges_result }}" + when: + - _install_cartridges_result.rc!=0 + - not (cpd_test_cartridges | default(False) | bool) -- name: Wait for cartridges to finish installation - include_tasks: cp4d-wait-cartridges-ready.yml - loop: "{{ _apply_cr_cartridges | default([]) }}" - loop_control: - loop_var: _current_cp4d_cartridge \ No newline at end of file + - set_fact: + _cp4d_cartridges_installed_successfully: False + when: _install_cartridges_result.rc!=0 + + - name: Wait for cartridges to finish installation + include_tasks: cp4d-wait-cartridges-ready.yml + loop: "{{ _apply_cr_cartridges | default([]) }}" + loop_control: + loop_var: _current_cp4d_cartridge + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml index 2e843c2f4..2526effec 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml @@ -31,19 +31,27 @@ 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log - shell: | - {{ _apply_cr_command }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.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 \ No newline at end of file +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}" + _p_activity_command: "{{ _apply_cr_command }}" + +- block: + - 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log + shell: | + {{ _apply_cr_command }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.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: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-watson_ks.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-watson_ks.yml index e869ee25a..7f9498b09 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-watson_ks.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-watson_ks.yml @@ -2,13 +2,18 @@ - include_tasks: cp4d-setup-mcg-secrets.yml when: _p_current_cp4d_cluster.cp4d_version >= "4.7.0" -- block: - - name: Prepare yaml file for Watson Knowledge Studio CR - template: - src: watson-ks-cr-45.j2 - dest: "{{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml" +- name: Prepare yaml file for Watson Knowledge Studio CR + template: + src: watson-ks-cr-45.j2 + dest: "{{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml" - - 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" \ No newline at end of file +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create Watson Knowledge Studio CR" + _p_activity_yaml: "{{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml" + +- name: Create Watson Knowledge Studio CR + shell: | + oc apply -f {{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml index 944e77ced..fdee54d82 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml @@ -39,21 +39,30 @@ vars: _p_preview_script: False - - name: Run apply-cr command to install runtime {{ _ws_runtime }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log - shell: | - {{ _apply_ws_runtime_command }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log 2>&1 - register: _install_cartridges_result - failed_when: False - - - name: Fail if there was an error installing the runtime {{ _ws_runtime }} 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 + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Install Watson Studio runtime {{ _ws_runtime }}" + _p_activity_command: "{{ _apply_ws_runtime_command }}" + + - block: + - name: Run apply-cr command to install Watson Studio runtime {{ _ws_runtime }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log + shell: | + set -o pipefail + {{ _apply_ws_runtime_command }} | tee -a {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log 2>&1 + register: _install_cartridges_result + failed_when: False + + - name: Fail if there was an error installing the runtime {{ _ws_runtime }} 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: not cpd_dry_run when: (_notebook_runtime_version.rc != 0) or (_notebook_runtime_version.stdout != _current_cp4d_cartridge.CR_Version) \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml index 8bc2c8f61..5a1fc56a5 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml @@ -36,19 +36,28 @@ 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log - shell: | - {{ _apply_cr_command }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.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 \ No newline at end of file +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Innstall cartridge {{ _current_cp4d_cartridge.olm_utils_name }}" + _p_activity_command: "{{ _apply_cr_command }}" + +- block: + - 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log + shell: | + set -o pipefail + {{ _apply_cr_command }} | tee -a {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.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: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml index 0d45c695d..29db5d590 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml @@ -5,6 +5,12 @@ src: cpd-network-policy.j2 dest: "{{ status_dir }}/cp4d/ccpd-network-policy-{{ current_cp4d_cluster.project }}.yml" + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create network policy for Cloud Pak for Data on IBM Cloud" + _p_activity_yaml: "{{ status_dir }}/cp4d/ccpd-network-policy-{{ current_cp4d_cluster.project }}.yml" + - name: Create Network Policy shell: | oc apply -f {{ status_dir }}/cp4d/ccpd-network-policy-{{ current_cp4d_cluster.project }}.yml @@ -17,6 +23,7 @@ {%- 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 when: cloud_platform == "ibm-cloud" and _p_current_cp4d_cluster.cp4d_version >= "4.5.0" - include_tasks: cp4d-setup-mcg-secrets.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-cpd-edb.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-cpd-edb.yml index b703ed1c4..844c2cdc2 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-cpd-edb.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-cpd-edb.yml @@ -18,6 +18,13 @@ src: "cpd-edb-license-secret.j2" dest: "{{ status_dir }}/cp4d/cpd-edb-postgresql-secret.yml" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create EDB PostgreSQL license secret object" + _p_activity_yaml: "{{ status_dir }}/cp4d/cpd-edb-postgresql-secret.yml" + - name: Apply EDB PostgreSQL secret command: | - oc apply -f "{{ status_dir }}/cp4d/cpd-edb-postgresql-secret.yml" \ No newline at end of file + oc apply -f "{{ status_dir }}/cp4d/cpd-edb-postgresql-secret.yml" + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml index 025c7998c..76f2cb763 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml @@ -1,14 +1,16 @@ --- -- 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 +- block: + - 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: 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 + when: not cpd_dry_run - name: Generate OLM utils command to create watsonx Orchestrate subscription set_fact: @@ -18,6 +20,12 @@ debug: var: _apply_olm_wxo_command +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create watsonx Orchestrate subscription" + _p_activity_command: "{{ _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 @@ -25,6 +33,7 @@ delay: 10 until: _apply_olm_wxo_result.rc==0 register: _apply_olm_wxo_result + when: not cpd_dry_run - set_fact: _app_connect: "{{ _current_cp4d_cartridge.app_connect }}" @@ -46,26 +55,50 @@ dest: /tmp remote_src: True +- set_fact: + _create_app_connect_project: "oc new-project {{ _app_connect.app_connect_project }} || true" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create App Connect project" + _p_activity_command: "{{ _create_app_connect_project }}" + - name: Create OpenShift Project {{ _app_connect.app_connect_project }} - shell: - oc new-project {{ _app_connect.app_connect_project }} || true + shell: | + {{ _create_app_connect_project }} + when: not cpd_dry_run + +- name: Generate command to create IBM App Connect catalog source + set_fact: + _create_app_connect_catsrc: "{{ lookup('template', 'create-app-connect-catsrc.j2') }}" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create App Connect catalog source" + _p_activity_command: "{{ _create_app_connect_catsrc }}" - 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 - + {{ _create_app_connect_catsrc }} + when: not cpd_dry_run - 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" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create IBM App Connect operator" + _p_activity_yaml: "{{ 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 + when: not cpd_dry_run - name: Wait for IBM App Connect operator to be installed shell: | @@ -76,39 +109,58 @@ retries: 20 delay: 10 until: _ibm_app_connect_csv.rc == 0 + when: not cpd_dry_run + +- name: Generate command to create IBM App Connect instance for watsonx Ochestrate + set_fact: + _create_app_connect_instance: "{{ lookup('template', 'create-app-connect-instance.j2') }}" -- name: Create IBM App Connect instance for watsonx watsonx.orchestrate +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create App Connect instance for watsonx Orchestrate" + _p_activity_command: "{{ _create_app_connect_instance }}" + +- name: Create IBM App Connect instance for 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 }} + {{ _create_app_connect_instance }} + when: not cpd_dry_run - 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 for releases < 5.0.0 - 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: 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: Generate command to setup watsonx Assistant instances for watsonx Orchestrate releases < 5.0.0 + set_fact: + _setup_watsonx_assistant_instances: "{{ lookup('template', 'setup-watsonx-assistant-instances.j2') }}" + + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Setup watsonx Assistant instances for watsonx Orchestrate releases < 5.0.0" + _p_activity_command: "{{ _setup_watsonx_assistant_instances }}" + + - name: Setup watsonx Assistant instances for watsonx Orchestrate for releases < 5.0.0 + 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 + when: not cpd_dry_run when: _p_current_cp4d_cluster.cp4d_version < "5.0.0" - block: @@ -124,4 +176,6 @@ - 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" \ No newline at end of file + when: + - _p_current_cp4d_cluster.cp4d_version == "4.8.4" + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml index 605614a17..c4552e245 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml @@ -3,10 +3,19 @@ - name: Show cartridge installation options debug: msg: "{{ _current_cp4d_cartridge.installation_options | to_json }}" + + - name: Generate command to set cartridge options for {{ _current_cp4d_cartridge.CR_Kind }} + set_fact: + _set_cartridge_options: "{{ lookup('template', 'set-cartridge-options') }}" + + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Set cartridge options for {{ _current_cp4d_cartridge.CR_Kind }}" + _p_activity_command: "{{ _set_cartridge_options }}" + - name: Set cartridge installation options for cartridge {{ _current_cp4d_cartridge.name }} shell: | - oc patch {{ _current_cp4d_cartridge.CR_Kind }} {{ _current_cp4d_cartridge.CR_Name }} \ - -n {{ _p_current_cp4d_cluster.project }} \ - --type merge \ - -p '{"spec": {{ _current_cp4d_cartridge.installation_options | to_json }} }' + {{ _set_cartridge_options }} + when: not cpd_dry_run when: (_current_cp4d_cartridge.installation_options | default({})) != {} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml index 32bd228cd..cc6cbf30e 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml @@ -1,9 +1,18 @@ --- - block: + - name: Generate command to set cartridge scaling for {{ _current_cp4d_cartridge.CR_Kind }} + set_fact: + _set_cartridge_scaling: "{{ lookup('template', 'set-cartridge-scaling') }}" + + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Set cartridge scaling for {{ _current_cp4d_cartridge.CR_Kind }}" + _p_activity_command: "{{ _set_cartridge_scaling }}" + - name: Scale service shell: | - oc patch {{ _current_cp4d_cartridge.CR_Kind }} {{ _current_cp4d_cartridge.CR_Name }} \ - -n {{ _p_current_cp4d_cluster.project }} \ - --type merge \ - -p '{"spec":{"scaleConfig": "{{ _current_cp4d_cartridge.size }}" } }' + {{ _set_cartridge_scaling }} + when: not cpd_dry_run + when: (_current_cp4d_cartridge.size | default('')) != '' \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml index c0c283bd2..d70ab8756 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml @@ -7,6 +7,14 @@ debug: var: _setup_mcg_command +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Setup Multicloud Object Gateway" + _p_activity_command: "{{ _setup_mcg_command }}" + - name: Set up Multicloud Object Gateway (MCG) secrets for {{ _current_cp4d_cartridge.olm_utils_name }} in CP4D project {{ _p_current_cp4d_cluster.project }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-setup-mcg.log shell: | {{ _setup_mcg_command }} + when: not cpd_dry_run + diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/main.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/main.yml index a907cd4d9..a99d55a88 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/main.yml @@ -10,18 +10,20 @@ state: present create: True -- name: Starting background task to patch Db2U clusters. Logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-db2u-temp-patch.log - shell: | - {{ role_path }}/files/temp-patch-db2u.sh \ - {{ status_dir }} \ - {{ _p_current_cp4d_cluster.project }} - async: 86400 - poll: 0 - register: _patch_db2u +- block: + - name: Starting background task to patch Db2U clusters. Logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-db2u-temp-patch.log + shell: | + {{ role_path }}/files/temp-patch-db2u.sh \ + {{ status_dir }} \ + {{ _p_current_cp4d_cluster.project }} + async: 86400 + poll: 0 + register: _patch_db2u -- name: Show details of background task to patch Db2U - debug: - var: _patch_db2u + - name: Show details of background task to patch Db2U + debug: + var: _patch_db2u + when: not cpd_dry_run # Set fact which is handled when testing install of all cartridges - set_fact: @@ -61,4 +63,5 @@ include_tasks: cp4d-wait-cartridges-ready.yml loop: "{{ _cartridges_to_install | default([]) }}" loop_control: - loop_var: _current_cp4d_cartridge \ No newline at end of file + loop_var: _current_cp4d_cartridge + when: not_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-cartridges.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-cartridges.j2 index c83c6d4d1..58bcf016a 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-cartridges.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-cartridges.j2 @@ -1,4 +1,4 @@ -/opt/ansible/bin/apply-cr \ +apply-cr \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --license_acceptance={{ _cpd_accept_licenses | default(False) | string | lower }} \ --preview={{ _p_preview_script | default(False) | string | lower }} \ diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/create-app-connect-catsrc.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/create-app-connect-catsrc.j2 new file mode 100644 index 000000000..679c1522c --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/create-app-connect-catsrc.j2 @@ -0,0 +1,5 @@ +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 - \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-options.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-options.j2 new file mode 100644 index 000000000..43cd8efbb --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-options.j2 @@ -0,0 +1,4 @@ +oc patch {{ _current_cp4d_cartridge.CR_Kind }} {{ _current_cp4d_cartridge.CR_Name }} \ + -n {{ _p_current_cp4d_cluster.project }} \ + --type merge \ + -p '{"spec": {{ _current_cp4d_cartridge.installation_options | to_json }} }' \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-scaling.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-scaling.j2 new file mode 100644 index 000000000..93f664b05 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-scaling.j2 @@ -0,0 +1,4 @@ + oc patch {{ _current_cp4d_cartridge.CR_Kind }} {{ _current_cp4d_cartridge.CR_Name }} \ + -n {{ _p_current_cp4d_cluster.project }} \ + --type merge \ + -p '{"spec":{"scaleConfig": "{{ _current_cp4d_cartridge.size }}" } }' \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-app-connect.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-app-connect.j2 new file mode 100644 index 000000000..7b2f3aaa7 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-app-connect.j2 @@ -0,0 +1,6 @@ +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 }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-watsonx-assistant-instances.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-watsonx-assistant-instances.j2 new file mode 100644 index 000000000..9d9213e95 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-watsonx-assistant-instances.j2 @@ -0,0 +1,6 @@ +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 \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml new file mode 100644 index 000000000..8134c2978 --- /dev/null +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml @@ -0,0 +1,17 @@ +--- +- name: Write deployer YAML file to {{ status_dir }}/log/deployer-actitivies.log + blockinfile: + path: "{{ status_dir }}/log/deployer-actitivies.log" + create: True + insertafter: EOF + marker: "" + block: | + + # --- + # + # Activity timestamp: {{ now(utc=true,fmt='%Y-%m-%d %H:%M:%S') }} + # Deployer activity: {{ _deployer_activity_sequence }} + # Description: {{ _p_activity_description | default("") }} + # YAML file: + {{ _p_activity_yaml }} + # --- \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml index 68025d0dc..c0115f987 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml @@ -1,6 +1,12 @@ --- +- debug: + var: _deployer_activity_sequence + - set_fact: _deployer_activity_sequence: "{{ (_deployer_activity_sequence | default(0)) + 1 }}" - include_tasks: log-deployer-command.yml - when: _p_activity_command != '' \ No newline at end of file + when: _p_activity_command | default('') != '' + +- include_tasks: log-deployer-yaml-file.yml + when: _p_activity_yaml | default('') != '' \ No newline at end of file From 7e0b62838c0d28a2f60c9ea22bdefd36fe64933e Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 05:48:14 +0000 Subject: [PATCH 07/51] #820 Fix typo --- .../cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml index c4552e245..b6e555fca 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml @@ -6,7 +6,7 @@ - name: Generate command to set cartridge options for {{ _current_cp4d_cartridge.CR_Kind }} set_fact: - _set_cartridge_options: "{{ lookup('template', 'set-cartridge-options') }}" + _set_cartridge_options: "{{ lookup('template', 'set-cartridge-options.j2') }}" - include_role: name: log-deployer-activity From 8ab959acd848fddc3d6f28e8ef2ac4415a57f481 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 05:49:06 +0000 Subject: [PATCH 08/51] #820 CP4D infra dependencies --- .../nfd-operator/tasks/main.yml | 67 ++++++++---- .../nvidia-operator/tasks/main.yml | 102 +++++++++++------- .../odf-operator/tasks/main.yml | 82 ++++++++------ .../openshift-mcg/tasks/main.yml | 42 +++++--- 4 files changed, 185 insertions(+), 108 deletions(-) diff --git a/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml b/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml index d02a3aaa3..532f58127 100644 --- a/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml @@ -1,7 +1,17 @@ --- +- set_fact: + _create_nfd_ns: "oc create ns openshift-nfd || true" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create Node Feature Discovery operator namespace" + _p_activity_commandl: "{{ _create_nfd_ns }}" + - name: Create openshift-nfd OpenShift project shell: | - oc create ns openshift-nfd || true + {{ _create_nfd_ns }} + when: not cpd_dry_run - name: Retrieve default channel for Node Feature Discovery manifest shell: @@ -16,26 +26,34 @@ src: nfd-operator.j2 dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml" -- name: Create NFD operator - shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml - -- name: Wait until NFD Operator CSV has status Succeeded - shell: | - oc get csv -n openshift-nfd \ - -l operators.coreos.com/nfd.openshift-nfd \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _nfd_csv_status - retries: 30 - delay: 30 - until: _nfd_csv_status.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: "Create NFD operator" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml" + +- block: + - name: Create NFD operator + shell: | + oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml + + - name: Wait until NFD Operator CSV has status Succeeded + shell: | + oc get csv -n openshift-nfd \ + -l operators.coreos.com/nfd.openshift-nfd \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _nfd_csv_status + retries: 30 + delay: 30 + until: _nfd_csv_status.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 - name: Get OpenShift version include_role: @@ -46,6 +64,13 @@ src: nfd-cr.j2 dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create NFD CR" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml" + - name: Create NFD CR shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml \ No newline at end of file + oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml b/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml index a87366b9b..a2653692e 100644 --- a/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml @@ -1,7 +1,17 @@ --- +- set_fact: + _create_nvidia_operator_ns: "oc create ns nvidia-gpu-operator || true" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create NVIDIA operator namespace" + _p_activity_commandl: "{{ _create_nvidia_operator_ns }}" + - name: Create nvidia-gpu-operator OpenShift project shell: | - oc create ns nvidia-gpu-operator || true + {{ _create_nvidia_operator_ns }} + when: not cpd_dry_run - name: Retrieve default channel for the NVIDIA GPU manifest shell: @@ -16,48 +26,64 @@ src: nvidia-operator.j2 dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml" -- name: Create NVIDIA operator - shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml - -- name: Wait until NVIDIA Operator CSV has status Succeeded - shell: | - oc get csv -n nvidia-gpu-operator \ - -l operators.coreos.com/gpu-operator-certified.nvidia-gpu-operator \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _nvidia_csv_status - retries: 30 - delay: 30 - until: _nvidia_csv_status.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: "Create NVIDIA operator" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml" + +- block: + - name: Create NVIDIA operator + shell: | + oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml + + - name: Wait until NVIDIA Operator CSV has status Succeeded + shell: | + oc get csv -n nvidia-gpu-operator \ + -l operators.coreos.com/gpu-operator-certified.nvidia-gpu-operator \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _nvidia_csv_status + retries: 30 + delay: 30 + until: _nvidia_csv_status.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 - name: Generate NVIDIA ClusterPolicy CR file {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml template: src: nvidia-cluster-policy-cr.j2 dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml" -- name: Create NVIDIA ClusterPolicy CR - shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml - -- name: Wait until NVIDIA ClusterPolicy has status Ready - shell: | - oc get clusterpolicies.nvidia.com gpu-cluster-policy \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.state' | \ - grep -i ready | wc -l - register: _nvidia_cluster_policy_status - retries: 30 - delay: 30 - until: _nvidia_cluster_policy_status.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) ... \ No newline at end of file + _p_activity_description: "Create NVIDIA ClusterPolicy CR" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml" + +- block: + - name: Create NVIDIA ClusterPolicy CR + shell: | + oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml + + - name: Wait until NVIDIA ClusterPolicy has status Ready + shell: | + oc get clusterpolicies.nvidia.com gpu-cluster-policy \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.state' | \ + grep -i ready | wc -l + register: _nvidia_cluster_policy_status + retries: 30 + delay: 30 + until: _nvidia_cluster_policy_status.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 \ No newline at end of file diff --git a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml index c37e42661..fa2ae86eb 100644 --- a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml @@ -19,9 +19,19 @@ - include_tasks: aws-s3-sts-role.yml when: _aws_sts_mode +- set_fact: + _create_openshift_storage_project: "oc create ns openshift-storage || true" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create openshift-storage project" + _p_activity_command: "{{ _create_openshift_storage_project }}" + - name: Create openshift-storage OpenShift project shell: | - oc create ns openshift-storage || true + {{ _create_openshift_storage_project }} + when: not dry_run - name: Retrieve default channel for ocs-operator manifest shell: @@ -36,37 +46,45 @@ src: odf-operator.j2 dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml" -- name: Create ODF operator - shell: | - oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml - -- name: Wait until ODF Operator CSV has status Succeeded - shell: | - oc get csv -n openshift-storage \ - -l operators.coreos.com/ocs-operator.openshift-storage \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _odf_csv_status - retries: 30 - delay: 30 - until: _odf_csv_status.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: "Create ODF operator" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml" -- name: Ensure that Data Foundation is shown in the console - shell: | - oc patch console.operator cluster \ - -n openshift-storage \ - --type json \ - -p '[{"op": "add", "path": "/spec/plugins", "value": ["odf-console"]}]' +- block: + - name: Create ODF operator + shell: | + oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml -- name: Set operator to Manual approval if the cluster is installed with STS - shell: | - oc patch subscriptions.operators.coreos.com -n openshift-storage odf-operator \ - --type merge \ - --patch '{"spec":{"installPlanApproval":"Manual"}}' - when: _aws_sts_mode \ No newline at end of file + - name: Wait until ODF Operator CSV has status Succeeded + shell: | + oc get csv -n openshift-storage \ + -l operators.coreos.com/ocs-operator.openshift-storage \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _odf_csv_status + retries: 30 + delay: 30 + until: _odf_csv_status.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) ... + + - name: Ensure that Data Foundation is shown in the console + shell: | + oc patch console.operator cluster \ + -n openshift-storage \ + --type json \ + -p '[{"op": "add", "path": "/spec/plugins", "value": ["odf-console"]}]' + + - name: Set operator to Manual approval if the cluster is installed with STS + shell: | + oc patch subscriptions.operators.coreos.com -n openshift-storage odf-operator \ + --type merge \ + --patch '{"spec":{"installPlanApproval":"Manual"}}' + when: _aws_sts_mode + when: not dry_run \ No newline at end of file diff --git a/automation-roles/40-configure-infra/openshift-mcg/tasks/main.yml b/automation-roles/40-configure-infra/openshift-mcg/tasks/main.yml index f87a6a418..175d412ba 100644 --- a/automation-roles/40-configure-infra/openshift-mcg/tasks/main.yml +++ b/automation-roles/40-configure-infra/openshift-mcg/tasks/main.yml @@ -32,24 +32,32 @@ src: openshift-mcg-storagecluster.j2 dest: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml" - - name: Apply yaml for MCG StorageCluster ocs-storagecluster - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml - - - name: Wait until MCG StorageCluster has status Ready - shell: | - oc get StorageCluster ocs-storagecluster -n openshift-storage \ - --no-headers \ - -o custom-columns='phase:status.phase' - register: _storage_cluster_status - retries: 60 - delay: 30 - until: _storage_cluster_status.stdout == "Ready" + - 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: "Create MCG StorageCluster" + _p_activity_yaml: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml" + + - block: + - name: Apply yaml for MCG StorageCluster ocs-storagecluster + shell: | + oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml + + - name: Wait until MCG StorageCluster has status Ready + shell: | + oc get StorageCluster ocs-storagecluster -n openshift-storage \ + --no-headers \ + -o custom-columns='phase:status.phase' + register: _storage_cluster_status + retries: 60 + delay: 30 + until: _storage_cluster_status.stdout == "Ready" + 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 when: - _p_openshift_cluster.mcg.install | default(False) | bool From df2b565778e3d878c056fc0f579faf495051d49f Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 05:49:25 +0000 Subject: [PATCH 09/51] #820 Log yaml file --- .../log-deployer-activity/tasks/log-deployer-yaml-file.yml | 2 +- .../99-generic/deployer/log-deployer-activity/tasks/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml index 8134c2978..0853d39b8 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml @@ -13,5 +13,5 @@ # Deployer activity: {{ _deployer_activity_sequence }} # Description: {{ _p_activity_description | default("") }} # YAML file: - {{ _p_activity_yaml }} + {{ lookup('file',_p_activity_yaml) }} # --- \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml index c0115f987..a1578fee7 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml @@ -3,7 +3,7 @@ var: _deployer_activity_sequence - set_fact: - _deployer_activity_sequence: "{{ (_deployer_activity_sequence | default(0)) + 1 }}" + _deployer_activity_sequence: "{{ (_deployer_activity_sequence | default(0)) | int + 1 }}" - include_tasks: log-deployer-command.yml when: _p_activity_command | default('') != '' From 674f8bb40ad38a20d01c47c6ad3d10ebfba314bd Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 05:49:35 +0000 Subject: [PATCH 10/51] #820 Catalog sources --- .../tasks/create-catalog-source-olm-utils.yml | 30 ++++++++++++------- .../cp4d/cp4d-catalog-source/tasks/main.yml | 3 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml index f45d90166..261d64f3b 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml @@ -78,20 +78,28 @@ regexp: '(ibm-datagate-prod-\d.\d.\d)(.tgz)' replace: '\1*\2' -- name: Run apply-olm command to create catalog sources for Cloud Pak for Data {{ _p_catsrc_scope }} - block: - - name: Generate OLM command to create catalog sources for Cloud Pak for Data {{ _p_catsrc_scope }} - set_fact: - _apply_olm_command: "{{ lookup('template', 'apply-olm-create-catsrc.j2') }}" - vars: - _p_preview_script: False - - name: Run apply-olm command to create catalog sources, logs are in {{ status_dir }}/log/apply-olm-create-catsrc-{{ _p_catsrc_scope }}.log - shell: | - {{ _apply_olm_command }} > {{ status_dir }}/log/apply-olm-create-catsrc{{ _p_catsrc_scope }}.log 2>&1 +- name: Generate OLM command to create catalog sources for Cloud Pak for Data {{ _p_catsrc_scope }} + set_fact: + _apply_olm_command: "{{ lookup('template', 'apply-olm-create-catsrc.j2') }}" + vars: + _p_preview_script: False + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create catalog sources for {{ _p_catsrc_scope }}" + _p_activity_command: "{{ _apply_olm_command }}" + +- name: Run apply-olm command to create catalog sources for {{ _p_catsrc_scope }}, logs are in {{ status_dir }}/log/apply-olm-create-catsrc-{{ _p_catsrc_scope }}.log + shell: | + {{ _apply_olm_command }} > {{ status_dir }}/log/apply-olm-create-catsrc{{ _p_catsrc_scope }}.log 2>&1 + when: not cpd_dry_run - name: If not air-gapped, copy case files from /tmp/work/offline to {{ status_dir }}/cp4d/offline copy: src: /tmp/work/offline dest: "{{ status_dir }}/cp4d/" remote_src: True - when: not (cpd_airgap | default(False) | bool) \ No newline at end of file + when: + - not (cpd_airgap | default(False) | bool) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/main.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/main.yml index 1b375d6ae..99b24c80f 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/main.yml @@ -8,4 +8,5 @@ - include_tasks: create-catalog-source-olm-utils.yml -- include_tasks: wait-catalog-sources-ready.yml \ No newline at end of file +- include_tasks: wait-catalog-sources-ready.yml + when: not cpd_dry_run \ No newline at end of file From b1ae00e18f1a2d7d8a051d8dff9e862012699b30 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 06:19:26 +0000 Subject: [PATCH 11/51] #820 Delete cartridge --- .../tasks/cp4d-remove-cr.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml index 610e710fb..f9f588772 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml @@ -7,6 +7,20 @@ - name: Delete instances of {{ _current_cartridge_cr.name }} include_tasks: cp4d-delete-cr-instances.yml -- name: Removing cartridge {{ _current_cartridge_cr.name }} +- set_fact: + _delete_cartridge_cr_command: "{{ oc delete {{ _current_cartridge_cr.cr_cr }} --namespace {{ _p_current_cp4d_cluster.project }} --all }}" + +- name: Show ommand for delete cartridge CR + debug: + var: _delete_cartridge_cr_command + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Remove cartridge {{ _current_cartridge_cr.name }}" + _p_activity_command: "{{ _delete_cartridge_cr_command }}" + +- name: Remove cartridge {{ _current_cartridge_cr.name }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log shell: | - oc delete {{ _current_cartridge_cr.cr_cr }} --namespace {{ _p_current_cp4d_cluster.project }} --all \ No newline at end of file + {{ _delete_cartridge_cr_command }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log 2>&1 + when: not cpd_dry_run \ No newline at end of file From 4913c8719367721a443df94ac291b4568b2bbd77 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 06:41:54 +0000 Subject: [PATCH 12/51] #820 Fix apply cartridges --- .../templates/set-cartridge-options.j2 | 5 +---- .../templates/set-cartridge-scaling.j2 | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-options.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-options.j2 index 43cd8efbb..b89cd8186 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-options.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-options.j2 @@ -1,4 +1 @@ -oc patch {{ _current_cp4d_cartridge.CR_Kind }} {{ _current_cp4d_cartridge.CR_Name }} \ - -n {{ _p_current_cp4d_cluster.project }} \ - --type merge \ - -p '{"spec": {{ _current_cp4d_cartridge.installation_options | to_json }} }' \ No newline at end of file +oc patch {{ _current_cp4d_cartridge.CR_Kind }} {{ _current_cp4d_cartridge.CR_Name }} -n {{ _p_current_cp4d_cluster.project }} --type merge -p '{"spec": {{ _current_cp4d_cartridge.installation_options | to_json }} }' \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-scaling.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-scaling.j2 index 93f664b05..9894a5562 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-scaling.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/set-cartridge-scaling.j2 @@ -1,4 +1 @@ - oc patch {{ _current_cp4d_cartridge.CR_Kind }} {{ _current_cp4d_cartridge.CR_Name }} \ - -n {{ _p_current_cp4d_cluster.project }} \ - --type merge \ - -p '{"spec":{"scaleConfig": "{{ _current_cp4d_cartridge.size }}" } }' \ No newline at end of file + oc patch {{ _current_cp4d_cartridge.CR_Kind }} {{ _current_cp4d_cartridge.CR_Name }} -n {{ _p_current_cp4d_cluster.project }} --type merge -p '{"spec":{"scaleConfig": "{{ _current_cp4d_cartridge.size }}" } }' \ No newline at end of file From 6c37d89a4a98d7fa8c81c13623602a227b3e4a5d Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 12:13:59 +0000 Subject: [PATCH 13/51] #820 Fix typo --- .../cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml index cc6cbf30e..4b6df87d1 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml @@ -2,7 +2,7 @@ - block: - name: Generate command to set cartridge scaling for {{ _current_cp4d_cartridge.CR_Kind }} set_fact: - _set_cartridge_scaling: "{{ lookup('template', 'set-cartridge-scaling') }}" + _set_cartridge_scaling: "{{ lookup('template', 'set-cartridge-scaling.j2') }}" - include_role: name: log-deployer-activity From 83ea718f39a215b9c31a4a3e70901a96ff6ac51f Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 12:14:13 +0000 Subject: [PATCH 14/51] #820 Dry-run for CP4D cluster --- .../tasks/cp4d-db2u-configmap.yml | 9 +++- .../tasks/install-control-plane-olm-utils.yml | 44 +++++++++++-------- .../tasks/install-cp4d-prepare.yml | 24 +++++----- .../cp4d/cp4d-cluster/tasks/install-cp4d.yml | 3 ++ .../tasks/openshift-install-knative.yml | 22 ++++++---- .../tasks/openshift-prepare-project.yml | 38 ++++++++++------ .../templates/authorize-instance.j2 | 3 +- .../templates/deploy-knative-eventing.j2 | 4 +- .../templates/setup-instance-topology.j2 | 1 - 9 files changed, 90 insertions(+), 58 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/cp4d-db2u-configmap.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/cp4d-db2u-configmap.yml index dd6f8451b..4acc17756 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/cp4d-db2u-configmap.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/cp4d-db2u-configmap.yml @@ -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 \ No newline at end of file + oc apply -f {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2u-product-cm.yml + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml index 668f6e242..61e19f3cc 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml @@ -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) ... \ No newline at end of file + _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 \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-cp4d-prepare.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-cp4d-prepare.yml index e636540e4..0f8c9e8d9 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-cp4d-prepare.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-cp4d-prepare.yml @@ -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: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-cp4d.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-cp4d.yml index 18dc40dae..948a5b1a7 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-cp4d.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-cp4d.yml @@ -78,10 +78,12 @@ - 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: @@ -89,6 +91,7 @@ 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 diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml index 667986042..8a0a4d559 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml @@ -1,5 +1,4 @@ --- - # Prepare CP4D for versions >= 4.8.0 - block: @@ -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' diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml index db73c79e0..6443378b5 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml @@ -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' \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/authorize-instance.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/authorize-instance.j2 index 71926a0e2..f4d031632 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/authorize-instance.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/authorize-instance.j2 @@ -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 \ No newline at end of file + --cpd_instance_ns={{ current_cp4d_cluster.project }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 index 4d41c7c82..d932103b7 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 @@ -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 \ No newline at end of file + --block_storage_class={{ ocp_storage_class_block }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/setup-instance-topology.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/setup-instance-topology.j2 index df0248bd1..06a4ed67b 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/setup-instance-topology.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/setup-instance-topology.j2 @@ -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 }} \ From 61a918f82af44529cba5109276048da22c9d9508 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 12:14:25 +0000 Subject: [PATCH 15/51] #820 Dry-run for scheduler --- .../tasks/install-scheduler-47.yml | 9 --------- .../tasks/install-scheduler-olm-utils.yml | 12 ------------ .../tasks/install-scheduler.yml | 15 +++++++++++++++ .../cp4d/cp4d-scheduling-service/tasks/main.yml | 5 +---- .../tasks/uninstall-scheduler.yml | 12 +++++++++++- .../templates/apply-cr-cpd-scheduler.j2 | 6 ------ .../templates/apply-scheduler.j2 | 2 +- 7 files changed, 28 insertions(+), 33 deletions(-) delete mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler-47.yml delete mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler-olm-utils.yml create mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml delete mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-cr-cpd-scheduler.j2 diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler-47.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler-47.yml deleted file mode 100644 index c44a54805..000000000 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler-47.yml +++ /dev/null @@ -1,9 +0,0 @@ -- name: Generate scheduler installation script {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-scheduler.sh - template: - src: apply-scheduler.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-scheduler.sh" - mode: u+rwx - -- name: Run scheduler installation script, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log - shell: | - {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-scheduler.sh > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler-olm-utils.yml deleted file mode 100644 index 7d6dc2955..000000000 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler-olm-utils.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Generate OLM command to install scheduling service - set_fact: - _apply_cr_command: "{{ lookup('template', 'apply-cr-cpd-scheduler.j2') }}" - -- name: Show apply-cr command to install scheduling service - debug: - var: _apply_cr_command - -- name: Run apply-cr command to install scheduling service, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cpd-schduler.log - shell: | - {{ _apply_cr_command }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cpd-schduler.log \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml new file mode 100644 index 000000000..d4e15aa9a --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml @@ -0,0 +1,15 @@ +--- +- name: Generate scheduler command + set_fact: + _apply_scheduler_command: "{{ lookup('template','apply-scheduler.j2') }}" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Apply scheduler" + _p_activity_command: "{{ _apply_scheduler_command }}" + +- name: Install scheduler, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log + shell: | + {{ _apply_scheduler_command }} > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/main.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/main.yml index 1b9f795c4..4849845b0 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/main.yml @@ -1,7 +1,6 @@ --- - set_fact: _scheduler_project: "{{ scheduling_service_project }}" - when: _p_current_cp4d_cluster.cp4d_version >= "4.7.0" - set_fact: _scheduler: "{{ _p_current_cp4d_cluster.cartridges | json_query(query) | first | default({}) }}" @@ -12,10 +11,8 @@ - debug: var: _scheduler -- name: Install scheduling service for Cloud Pak for Data 4.7.0 and higher - include_tasks: install-scheduler-47.yml +- include_tasks: install-scheduler.yml when: - - _p_current_cp4d_cluster.cp4d_version >= "4.7.0" - _scheduler != {} and (_scheduler.state | default('installed')) == 'installed' - include_tasks: uninstall-scheduler.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml index a68b4c96c..d08696378 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml @@ -1,4 +1,14 @@ --- +- name: Generate delete scheduler command + set_fact: + _delete_scheduler_command: "oc delete Scheduling ibm-cpd-scheduler -n {{ _scheduler_project }} --ignore-not-found --wait=true || true" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Delete scheduler" + _p_activity_command: "{{ _delete_scheduler_command }}" + - name: Uninstall scheduling service from project {{ _scheduler_project }} shell: | - oc delete Scheduling ibm-cpd-scheduler -n {{ _scheduler_project }} --ignore-not-found --wait=true || true \ No newline at end of file + {{ _delete_scheduluer_command }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-cr-cpd-scheduler.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-cr-cpd-scheduler.j2 deleted file mode 100644 index 3396cd323..000000000 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-cr-cpd-scheduler.j2 +++ /dev/null @@ -1,6 +0,0 @@ -/opt/ansible/bin/apply-cr \ - --release={{ _p_current_cp4d_cluster.cp4d_version }} \ - --license_acceptance={{ _cpd_accept_licenses | default(False) | string | lower }} \ - -v \ - --cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \ - --components=scheduler \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 index e945e9b78..7f878022a 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 @@ -1,4 +1,4 @@ -/opt/ansible/bin/apply-scheduler \ +apply-scheduler \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --license_acceptance=true \ --scheduler_ns={{ scheduling_service_project }} From 76da56bab364718430af6f284808b2c6372cf5a3 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 12:27:30 +0000 Subject: [PATCH 16/51] #820 Dry-run mirror images --- .../cp4d/cp4d-mirror-images/tasks/main.yml | 125 ++++++++++-------- .../templates/mirror-images.j2 | 6 +- .../templates/mirror-model-images.j2 | 8 +- 3 files changed, 70 insertions(+), 69 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/tasks/main.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/tasks/main.yml index 93973fb24..6e8f2659d 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/tasks/main.yml @@ -99,19 +99,27 @@ src: "{{ status_dir }}/work/offline" dest: /tmp/work/ remote_src: True - when: _p_source_registry_hostname | default('') == _v_portable_registry + when: + - _p_source_registry_hostname | default('') == _v_portable_registry + - not cpd_dry_run - name: Generate script to copy mirroring log files {{ _p_current_cp4d_cluster.project }}-mirror-images-copy-log-files.sh template: src: mirror-images-copy-log-files.j2 dest: "{{ status_dir}}/cp4d/{{ _p_current_cp4d_cluster.project }}-mirror-images-copy-log-files.sh" - mode: u+rwx + mode: u+rwx + when: + - _p_source_registry_hostname | default('') == _v_portable_registry + - not cpd_dry_run - name: Run script that copies mirror log files in background shell: | {{ status_dir}}/cp4d/{{ _p_current_cp4d_cluster.project }}-mirror-images-copy-log-files.sh async: 86400 poll: 0 + when: + - _p_source_registry_hostname | default('') == _v_portable_registry + - not cpd_dry_run - name: Collect the cartridges to be mirrored set_fact: @@ -125,58 +133,60 @@ jsonquery: "[?olm_utils_name=='watsonx_ai'].models[]" - block: - - name: Filter the list of cartriges to exclude watsonx_ai_ifm from regular mirroring - set_fact: - _cartridges_to_mirror_list: "{{ _cartridges_to_install | map(attribute='olm_utils_name') | reject('equalto', 'watsonx_ai_ifm') | join(',') }}" - - - name: Get the watsonx_ai_ifm case version - shell: yq ".release_components_meta.watsonx_ai_ifm.case_version" /opt/ansible/ansible-play/config-vars/release-{{ _p_current_cp4d_cluster.cp4d_version }}.yml - register: _watsonx_ai_ifm_case_version - - - name: Find watsonx_ai_ifm images csv file - find: - paths: "{{ status_dir }}/work/offline/{{ _p_current_cp4d_cluster.cp4d_version }}/.ibm-pak/data/cases/ibm-watsonx-ai-ifm/{{ _watsonx_ai_ifm_case_version.stdout }}" - patterns: '*-images.csv' - register: _watsonx_ai_ifm_images_files - - - name: Read watsonx_ai_ifm images csv file - read_csv: - path: "{{ (_watsonx_ai_ifm_images_files.files | first).path }}" - skipinitialspace: True - register: _watsonx_ai_ifm_images_json - - - name: Initialize group list - set_fact: - _case_groups: [] - - - name: Collect case groups for models + - block: + - name: Filter the list of cartriges to exclude watsonx_ai_ifm from regular mirroring + set_fact: + _cartridges_to_mirror_list: "{{ _cartridges_to_install | map(attribute='olm_utils_name') | reject('equalto', 'watsonx_ai_ifm') | join(',') }}" + + - name: Get the watsonx_ai_ifm case version + shell: | + yq ".release_components_meta.watsonx_ai_ifm.case_version" /opt/ansible/ansible-play/config-vars/release-{{ _p_current_cp4d_cluster.cp4d_version }}.yml + register: _watsonx_ai_ifm_case_version + + - name: Find watsonx_ai_ifm images csv file + find: + paths: "{{ status_dir }}/work/offline/{{ _p_current_cp4d_cluster.cp4d_version }}/.ibm-pak/data/cases/ibm-watsonx-ai-ifm/{{ _watsonx_ai_ifm_case_version.stdout }}" + patterns: '*-images.csv' + register: _watsonx_ai_ifm_images_files + + - name: Read watsonx_ai_ifm images csv file + read_csv: + path: "{{ (_watsonx_ai_ifm_images_files.files | first).path }}" + skipinitialspace: True + register: _watsonx_ai_ifm_images_json + + - name: Initialize group list + set_fact: + _case_groups: [] + + - name: Collect case groups for models + set_fact: + _case_groups: "{{ _case_groups + _watsonx_ai_ifm_images_json.list | selectattr('image_name','search',item) | map(attribute='groups') | unique }}" + loop: "{{ _models_to_install }}" + + - debug: var=_case_groups + + - name: Create case group list + set_fact: + _case_group_list: "{{ _case_groups | join(',') }}" + when: not cpd_dry_run + + - name: Generate command to mirror foundation model images set_fact: - _case_groups: "{{ _case_groups + _watsonx_ai_ifm_images_json.list | selectattr('image_name','search',item) | map(attribute='groups') | unique }}" - loop: "{{ _models_to_install }}" - - - debug: var=_case_groups + _mirror_model_images: "{{ lookup('template','mirror-model-images.j2') }}" - - name: Create case group list - set_fact: - _case_group_list: "{{ _case_groups | join(',') }}" - - - name: Generate script to mirror foundation model images {{ _p_current_cp4d_cluster.project }}-mirror-model-images.sh - template: - src: mirror-model-images.j2 - dest: "{{ status_dir}}/cp4d/{{ _p_current_cp4d_cluster.project }}-mirror-model-images.sh" - mode: u+rwx + - include_role: + name: log-deployer-activity vars: - _p_preview_script: False - - - name: Show script that will mirror model images {{ status_dir}}/cp4d/{{ _p_current_cp4d_cluster.project }}-mirror-model-images.sh - debug: - msg: "{{ lookup('file', status_dir + '/cp4d/' + _p_current_cp4d_cluster.project + '-mirror-model-images.sh' ) }}" + _p_activity_description: "Mirror foundation model images" + _p_activity_command: "{{ _mirror_model_images }}" - name: Mirror model images, log is in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-mirror-model-images.log; detailed logs can be found in {{ status_dir }}/log/mirror_*.log shell: | - {{ status_dir}}/cp4d/{{ _p_current_cp4d_cluster.project }}-mirror-model-images.sh + {{ _mirror_model_images }} 2>&1 | tee {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-mirror-model-images.log failed_when: False register: _mirror_model_images + when: not cpd_dry_run when: _models_to_install | length > 0 @@ -184,23 +194,22 @@ - _p_current_cp4d_cluster.cp4d_version >= '5.0.1' - '"watsonx_ai" in _cartridges_to_install_list' -- name: Generate script to mirror images {{ _p_current_cp4d_cluster.project }}-mirror-images.sh - template: - src: mirror-images.j2 - dest: "{{ status_dir}}/cp4d/{{ _p_current_cp4d_cluster.project }}-mirror-images.sh" - mode: u+rwx - vars: - _p_preview_script: False +- name: Generate command to mirror images + set_fact: + _mirror_images: "{{ lookup('template','mirror-images.j2') }}" -- name: Show script that will mirror images {{ status_dir}}/cp4d/{{ _p_current_cp4d_cluster.project }}-mirror-images.sh - debug: - msg: "{{ lookup('file', status_dir + '/cp4d/' + _p_current_cp4d_cluster.project + '-mirror-images.sh' ) }}" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Mirror images" + _p_activity_command: "{{ _mirror_images }}" - name: Mirror images, log is in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-mirror-images.log; detailed logs can be found in {{ status_dir }}/log/mirror_*.log shell: | - {{ status_dir}}/cp4d/{{ _p_current_cp4d_cluster.project }}-mirror-images.sh + {{ _mirror_images}} 2>&1 | tee {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-mirror-images.log failed_when: False register: _mirror_images + when: not cpd_dry_run - block: @@ -232,4 +241,4 @@ - fail: msg: Mirroring of images failed, check mirror*.log files in {{ status_dir }}/log for details - when: _mirror_images.rc != 0 or (_mirror_model_images.rc is defined and _mirror_model_images.rc != 0) \ No newline at end of file + when: (_mirror_images.rc | default(0)) != 0 or (_mirror_model_images.rc | default(0)) != 0 \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/templates/mirror-images.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/templates/mirror-images.j2 index 8f8258a76..f7fab535a 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/templates/mirror-images.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/templates/mirror-images.j2 @@ -1,6 +1,3 @@ -#!/bin/bash - -set -o pipefail mirror-images \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --components={%- if _p_current_cp4d_cluster.cp4d_version >= '4.7.0' %}ibm-cert-manager,ibm-licensing,{%- endif %}{{ _cartridges_to_mirror_list }} \ @@ -9,6 +6,5 @@ mirror-images \ {% endif -%} --target_registry={{ _target_registry_url }} \ --arch={{ _openshift_processor_arch }} \ - --preview={%- if _p_preview_script -%}true{%- else -%}false{%- endif %} \ -v \ - --case_download={%- if cpd_airgap | default(False) -%}false{%- else -%}true{%- endif %} 2>&1 | tee {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-mirror-images.log \ No newline at end of file + --case_download={%- if cpd_airgap | default(False) -%}false{%- else -%}true{%- endif %} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/templates/mirror-model-images.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/templates/mirror-model-images.j2 index 49c99a015..5cd199d2e 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/templates/mirror-model-images.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-mirror-images/templates/mirror-model-images.j2 @@ -1,7 +1,4 @@ -#!/bin/bash - -set -o pipefail -mirror-images \ + mirror-images \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --components=watsonx_ai_ifm \ {% if (_p_source_registry_hostname | default('')) == _v_portable_registry -%} @@ -9,7 +6,6 @@ mirror-images \ {% endif -%} --target_registry={{ _target_registry_url }} \ --arch={{ _openshift_processor_arch }} \ - --preview={%- if _p_preview_script -%}true{%- else -%}false{%- endif %} \ -v \ --groups={{ _case_group_list }} \ - --case_download={%- if cpd_airgap | default(False) -%}false{%- else -%}true{%- endif %} 2>&1 | tee {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-mirror-model-images.log \ No newline at end of file + --case_download={%- if cpd_airgap | default(False) -%}false{%- else -%}true{%- endif %} \ No newline at end of file From 4ba36f3a7ad6e9942698852038a85167af7963c4 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 12:35:15 +0000 Subject: [PATCH 17/51] #820 Dry-run for projects --- .../tasks/openshift-prepare-project.yml | 104 +++++++++--------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml index 6443378b5..230000c13 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml @@ -8,65 +8,67 @@ fail: msg="cloud_platform {{ cloud_platform }} is not implemented, current implemented cloud platforms are {{ implemented_cloud_platform_types }} " when: "cloud_platform not in implemented_cloud_platform_types" -# Create project that will run operators of Cloud Pak for Data -- name: Validate if OpenShift project {{ current_cp4d_cluster.operators_project }} exists - shell: oc project {{ current_cp4d_cluster.operators_project }} - failed_when: False - register: _cp4d_operators_project_exists - when: current_cp4d_cluster.cp4d_version >= '4.7.0' +- set_fact: + _create_operators_project: "oc new-project {{ current_cp4d_cluster.operators_project }} | true" -- name: Create OpenShift Project {{ current_cp4d_cluster.operators_project }} if it does not exist - command: oc new-project {{current_cp4d_cluster.operators_project }} - when: - - current_cp4d_cluster.cp4d_version >= '4.7.0' - - _cp4d_operators_project_exists.rc != 0 +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create oeprators project {{ current_cp4d_cluster.operators_project }}" + _p_activity_command: "{{ _create_operators_project }}" + +- name: Create operators project {{ current_cp4d_cluster.operators_project }} + shell: | + {{ _create_operators_project }} + when: not cpd_dry_run -# Create project that will run instance of Cloud Pak for Data -- name: Validate if OpenShift project {{ current_cp4d_cluster.project }} exists - shell: oc project {{ current_cp4d_cluster.project }} - failed_when: False - register: _cp4d_cluster_project_exists +- set_fact: + _create_instance_project: "oc new-project {{ current_cp4d_cluster.project }} | true" -- name: Create OpenShift Project {{ current_cp4d_cluster.project }} if it does not exist - command: oc new-project {{ current_cp4d_cluster.project }} - when: _cp4d_cluster_project_exists.rc != 0 +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create instance project {{ current_cp4d_cluster.project }}" + _p_activity_command: "{{ _create_instance_project }}" -# Prepare CP4D for versions >= 4.7.0 -- block: - # Set configmap to control if Db2U must run with elevated or limited privileges - - include_tasks: cp4d-db2u-configmap.yml - when: - - _db2u_dependency | default(False) +- name: Create instance project {{ current_cp4d_cluster.project }} + shell: | + {{ _create_instance_project }} + when: not cpd_dry_run - - name: Generate authorize instance command for project {{ current_cp4d_cluster.project }} - set_fact: - _authorize_instance_command: "{{ lookup('template','authorize-instance.j2') }}" +# Set configmap to control if Db2U must run with elevated or limited privileges +- include_tasks: cp4d-db2u-configmap.yml + when: + - _db2u_dependency | default(False) - - include_role: - name: log-deployer-activity - vars: - _p_activity_description: "Authorize instance {{ current_cp4d_cluster.project }}" - _p_activity_command: "{{ _authorize_instance_command }}" +- name: Generate authorize instance command for project {{ current_cp4d_cluster.project }} + set_fact: + _authorize_instance_command: "{{ lookup('template','authorize-instance.j2') }}" - - name: Authorize instance, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-authorize-instance.log - shell: | - set -o pipefail - {{ _authorize_instance_command }} 2>&1 | tee {{ 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: Generate setop instance topology command for project {{ current_cp4d_cluster.project }} - set_fact: - _setup_instance_topology: "{{ lookup('template','setup-instance_topology.j2') }}" +- name: Authorize instance, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-authorize-instance.log + shell: | + set -o pipefail + {{ _authorize_instance_command }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-authorize-instance.log + when: not cpd_dry_run - - include_role: - name: log-deployer-activity - vars: - _p_activity_description: "Authorize instance {{ current_cp4d_cluster.project }}" - _p_activity_command: "{{ _setup_instance_topology }}" +- name: Generate setop instance topology command for project {{ current_cp4d_cluster.project }} + set_fact: + _setup_instance_topology: "{{ lookup('template','setup-instance-topology.j2') }}" - - name: Setup instance topology, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-setup-instance-topology.log - shell: | - set -o pipefail - {{ _setup_instance_topology }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-setup-instance-topology.log +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Authorize instance {{ current_cp4d_cluster.project }}" + _p_activity_command: "{{ _setup_instance_topology }}" - when: - - current_cp4d_cluster.cp4d_version >= '4.7.0' \ No newline at end of file +- name: Setup instance topology, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-setup-instance-topology.log + shell: | + set -o pipefail + {{ _setup_instance_topology }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-setup-instance-topology.log + when: not cpd_dry_run \ No newline at end of file From a51b0a20b70821bff5ed9bdd72da28999c80c085 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 13:39:43 +0000 Subject: [PATCH 18/51] #820 Node settings --- .../tasks/create-crio-config-crc.yml | 10 +++++++++- .../tasks/create-kubelet-config.yml | 18 +++++++++++++++--- .../tasks/non-mco-apply-kubelet-config.yml | 9 ++++++++- .../cp4d/cp4d-ocp-tuned/tasks/main.yml | 9 ++++++++- .../tasks/uninstall-scheduler.yml | 2 +- .../tasks/log-deployer-yaml-script.yml | 17 +++++++++++++++++ .../log-deployer-activity/tasks/main.yml | 5 ++++- 7 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-script.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-crio-config/tasks/create-crio-config-crc.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-crio-config/tasks/create-crio-config-crc.yml index 2c44bcccd..0c13ac091 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-crio-config/tasks/create-crio-config-crc.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-crio-config/tasks/create-crio-config-crc.yml @@ -4,5 +4,13 @@ src: cp4d-container-runtime-config.j2 dest: "{{ status_dir }}/openshift/cp4d-container-runtime-config.yaml" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create Container Runtime Configuration" + _p_activity_yaml: "{{ status_dir }}/openshift/cp4d-container-runtime-config.yaml" + - name: Apply Container Runtime configuration - shell: oc apply -f {{ status_dir }}/openshift/cp4d-container-runtime-config.yaml + shell: | + oc apply -f {{ status_dir }}/openshift/cp4d-container-runtime-config.yaml + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/create-kubelet-config.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/create-kubelet-config.yml index f91a4bce0..a69633e50 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/create-kubelet-config.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/create-kubelet-config.yml @@ -2,15 +2,27 @@ - name: Delete KubeletConfig cpd-crio-kubeletconfig if it exists shell: | oc delete KubeletConfig cpd-crio-kubeletconfig --ignore-not-found + when: not cpd_dry_run - name: Create KubeletConfig yaml template: src: cp4d-kubeletconfig.j2 dest: "{{ status_dir }}/openshift/cp4d-kubeletconfig.yaml" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create KubeletConfig" + _p_activity_yaml: "{{ status_dir }}/openshift/cp4d-kubeletconfig.yaml" + - name: Create KubeletConfig {{ kubelet_config_name }} - shell: oc apply -f {{ status_dir }}/openshift/cp4d-kubeletconfig.yaml + shell: | + oc apply -f {{ status_dir }}/openshift/cp4d-kubeletconfig.yaml + when: not cpd_dry_run - name: Label worker machine config pool to allow KubeletConfig - shell: oc label machineconfigpool worker db2u-kubelet=sysctl --overwrite - when: _existing_ocp_infra_type != 'aws-rosa' + shell: | + oc label machineconfigpool worker db2u-kubelet=sysctl --overwrite + when: + - _existing_ocp_infra_type != 'aws-rosa' + - not cpd_dry_run diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/non-mco-apply-kubelet-config.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/non-mco-apply-kubelet-config.yml index c2fd864c0..4571043ac 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/non-mco-apply-kubelet-config.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/non-mco-apply-kubelet-config.yml @@ -4,7 +4,14 @@ src: cp4d-apply-kubelet-config.j2 dest: "{{ status_dir }}/openshift/cp4d-apply-kubelet-config.sh" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create KubeletConfig for cluster without MCO" + _p_activity_script: "{{ status_dir }}/openshift/cp4d-apply-kubelet-config.sh" + - name: Put cp4d-apply-kubelet-config.sh script into config map shell: oc set data -n kube-system cm/cloud-pak-node-fix-scripts \ - --from-file={{ status_dir }}/openshift/cp4d-apply-kubelet-config.sh \ No newline at end of file + --from-file={{ status_dir }}/openshift/cp4d-apply-kubelet-config.sh + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-tuned/tasks/main.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-tuned/tasks/main.yml index 9dff1822e..b33cdfe3b 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-tuned/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-tuned/tasks/main.yml @@ -32,6 +32,13 @@ --mem-limit {{ _compute_node_memory_gb }} \ -f {{ status_dir }}/openshift/cp4d-tuned.yaml +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create Tuned resource" + _p_activity_yaml: "{{ status_dir }}/openshift/cp4d-tuned.yaml" + - name: Create Tuned cp4d_ipc shell: | - oc apply -f {{ status_dir }}/openshift/cp4d-tuned.yaml \ No newline at end of file + oc apply -f {{ status_dir }}/openshift/cp4d-tuned.yaml + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml index d08696378..573cb68b9 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml @@ -11,4 +11,4 @@ - name: Uninstall scheduling service from project {{ _scheduler_project }} shell: | - {{ _delete_scheduluer_command }} \ No newline at end of file + {{ _delete_scheduler_command }} \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-script.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-script.yml new file mode 100644 index 000000000..808ea726a --- /dev/null +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-script.yml @@ -0,0 +1,17 @@ +--- +- name: Write deployer script file to {{ status_dir }}/log/deployer-actitivies.log + blockinfile: + path: "{{ status_dir }}/log/deployer-actitivies.log" + create: True + insertafter: EOF + marker: "" + block: | + + # --- + # + # Activity timestamp: {{ now(utc=true,fmt='%Y-%m-%d %H:%M:%S') }} + # Deployer activity: {{ _deployer_activity_sequence }} + # Description: {{ _p_activity_description | default("") }} + # Script + {{ lookup('file',_p_activity_script) }} + # --- \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml index a1578fee7..23f32f612 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml @@ -9,4 +9,7 @@ when: _p_activity_command | default('') != '' - include_tasks: log-deployer-yaml-file.yml - when: _p_activity_yaml | default('') != '' \ No newline at end of file + when: _p_activity_yaml | default('') != '' + +- include_tasks: log-deployer-script-file.yml + when: _p_activity_script | default('') != '' \ No newline at end of file From 4ba7e4364a65898873bc78b4c7888d0bea65da95 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 13:39:56 +0000 Subject: [PATCH 19/51] #820 Subscriptinos --- .../cp4d-create-subscriptions-olm-utils.yml | 46 +++++++++++-------- .../templates/apply-olm-cartridge-sub.j2 | 2 +- .../templates/operator-group.j2 | 8 ---- 3 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/templates/operator-group.j2 diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/tasks/cp4d-create-subscriptions-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/tasks/cp4d-create-subscriptions-olm-utils.yml index caa47c0d3..51e6954ea 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/tasks/cp4d-create-subscriptions-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/tasks/cp4d-create-subscriptions-olm-utils.yml @@ -46,24 +46,32 @@ debug: var: _apply_olm_command -- name: Run apply-olm command to install {{ _p_subscription_scope }} subscriptions, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.log - shell: | - {{ _apply_olm_command }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.log 2>&1 - failed_when: False - retries: 2 - delay: 10 - until: _apply_olm_result.rc==0 - register: _apply_olm_result +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create {{ _p_subscription_scope }} subscriptions" + _p_activity_command: "{{ _apply_olm_command }}" -- name: Show subscriptions state if apply-olm failed - block: - - name: Retrieving state of all operators in project {{ _p_current_cp4d_cluster.operators_project }} +- block: + - name: Run apply-olm command to install {{ _p_subscription_scope }} subscriptions, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.log shell: | - oc get subscriptions.operators.coreos.com -n {{ _p_current_cp4d_cluster.operators_project }} \ - --no-headers \ - --sort-by=.metadata.creationTimestamp \ - -o jsonpath='{range .items[*]}{.metadata.name}{","}{.metadata.creationTimestamp}{","}{.status.installedCSV}{","}{.status.state}{"\n"}{end}' - register: _subscription_state - - fail: - msg: "Creation of the subscriptions failed (possible due to OLM issue): {{ _subscription_state.stdout_lines }}" - when: _apply_olm_result.rc != 0 + {{ _apply_olm_command }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.log 2>&1 + failed_when: False + retries: 2 + delay: 10 + until: _apply_olm_result.rc==0 + register: _apply_olm_result + + - name: Show subscriptions state if apply-olm failed + block: + - name: Retrieving state of all operators in project {{ _p_current_cp4d_cluster.operators_project }} + shell: | + oc get subscriptions.operators.coreos.com -n {{ _p_current_cp4d_cluster.operators_project }} \ + --no-headers \ + --sort-by=.metadata.creationTimestamp \ + -o jsonpath='{range .items[*]}{.metadata.name}{","}{.metadata.creationTimestamp}{","}{.status.installedCSV}{","}{.status.state}{"\n"}{end}' + register: _subscription_state + - fail: + msg: "Creation of the subscriptions failed (possible due to OLM issue): {{ _subscription_state.stdout_lines }}" + when: _apply_olm_result.rc != 0 + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/templates/apply-olm-cartridge-sub.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/templates/apply-olm-cartridge-sub.j2 index f2e0ed0af..fd594f3a1 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/templates/apply-olm-cartridge-sub.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/templates/apply-olm-cartridge-sub.j2 @@ -1,4 +1,4 @@ -/opt/ansible/bin/apply-olm \ +apply-olm \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --case_download=false \ --catsrc=false --sub=true \ diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/templates/operator-group.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/templates/operator-group.j2 deleted file mode 100644 index c1c623a70..000000000 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/templates/operator-group.j2 +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha2 -kind: OperatorGroup -metadata: - name: operatorgroup - namespace: {{ foundational_services_project }} -spec: - targetNamespaces: - - {{ foundational_services_project }} \ No newline at end of file From c6007161b570769e952f6f1e2639fb2ba1b60ae1 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 13:45:56 +0000 Subject: [PATCH 20/51] #820 Dry-run OpenShift AI --- .../tasks/install-opernshift-ai.yml | 134 +++++++++++------- 1 file changed, 79 insertions(+), 55 deletions(-) diff --git a/automation-roles/40-configure-infra/openshift-ai/tasks/install-opernshift-ai.yml b/automation-roles/40-configure-infra/openshift-ai/tasks/install-opernshift-ai.yml index b1776556a..c97d32323 100644 --- a/automation-roles/40-configure-infra/openshift-ai/tasks/install-opernshift-ai.yml +++ b/automation-roles/40-configure-infra/openshift-ai/tasks/install-opernshift-ai.yml @@ -4,73 +4,97 @@ src: openshift-ai-operator.j2 dest: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml" -- name: Apply yaml for OpenShift AI operator - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml - -- name: Wait until OpenShift AI operator CSV has status Succeeded - shell: | - oc get csv -n redhat-ods-operator \ - -l operators.coreos.com/rhods-operator.redhat-ods-operator \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _openshift_ai_csv_status - retries: 30 - delay: 30 - until: _openshift_ai_csv_status.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: "Create OpenShift AI operator" + _p_activity_yaml: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml" + +- block: + - name: Apply yaml for OpenShift AI operator + shell: | + oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml + + - name: Wait until OpenShift AI operator CSV has status Succeeded + shell: | + oc get csv -n redhat-ods-operator \ + -l operators.coreos.com/rhods-operator.redhat-ods-operator \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _openshift_ai_csv_status + retries: 30 + delay: 30 + until: _openshift_ai_csv_status.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 - name: Generate OpenShift AI DSCInitialization {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml template: src: dscinitialization.j2 dest: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml" -- name: Apply yaml for OpenShift AI DSCInitialization - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml - -- name: Wait until OpenShift AI DSCInitialization default-dsci is ready - shell: | - oc get DSCInitialization default-dsci \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i ready | wc -l - register: _openshift_ai_dsc_init_status - retries: 30 - delay: 30 - until: _openshift_ai_dsc_init_status.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: "Create OpenShift AI DSCInitialization" + _p_activity_yaml: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml" + +- block: + - name: Apply yaml for OpenShift AI DSCInitialization + shell: | + oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml + + - name: Wait until OpenShift AI DSCInitialization default-dsci is ready + shell: | + oc get DSCInitialization default-dsci \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i ready | wc -l + register: _openshift_ai_dsc_init_status + retries: 30 + delay: 30 + until: _openshift_ai_dsc_init_status.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 - name: Generate OpenShift AI DataScienceCluster {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml template: src: datasciencecluster.j2 dest: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml" -- name: Apply yaml for OpenShift AI DataScienceCluster - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml - -- name: Wait until OpenShift AI DataScienceCluster default-dsc is ready - shell: | - oc get DataScienceCluster default-dsc \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i ready | wc -l - register: _openshift_ai_dsc_status - retries: 30 - delay: 30 - until: _openshift_ai_dsc_status.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) ... \ No newline at end of file + _p_activity_description: "Create OpenShift AI DataScienceCluster" + _p_activity_yaml: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml" + +- block: + - name: Apply yaml for OpenShift AI DataScienceCluster + shell: | + oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml + + - name: Wait until OpenShift AI DataScienceCluster default-dsc is ready + shell: | + oc get DataScienceCluster default-dsc \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i ready | wc -l + register: _openshift_ai_dsc_status + retries: 30 + delay: 30 + until: _openshift_ai_dsc_status.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 \ No newline at end of file From 8955a1ee6d79170c0f13f01bb63957573ec12a2c Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 13:49:20 +0000 Subject: [PATCH 21/51] #820 Dry-run OpenShift console banner --- .../openshift-console-banner/tasks/main.yaml | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml index 96463804c..436cec9ed 100644 --- a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml +++ b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml @@ -5,12 +5,31 @@ src: console-banner.j2 dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-console-banner.yaml" + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create OpenShift console banner" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-console-banner.yaml" + - name: Create OpenShift console banner shell: | oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-console-banner.yaml + when: not cpd_dry_run when: (_p_openshift_cluster.console_banner | default ("")) != "" -- name: Delete console banner if not specified - shell: - oc delete ConsoleNotification cpd-console-banner --ignore-not-found - when: (_p_openshift_cluster.console_banner | default ("")) == "" \ No newline at end of file +- block: + - set_fact: + _delete_openshift_console_banner: "oc delete ConsoleNotification cpd-console-banner --ignore-not-found" + + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Setup Multicloud Object Gateway" + _p_activity_command: "{{ _setup_mcg_command }}" + + - name: Delete console banner if not specified + shell: | + {{ _delete_openshift_console_banner }} + when: not cpd_dry_run + when: + - (_p_openshift_cluster.console_banner | default ("")) == "" \ No newline at end of file From a59f36de883582424bffed66f8fa8943aea461b1 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 20:53:17 +0000 Subject: [PATCH 22/51] #820 Fix typo --- .../40-configure-infra/odf-operator/tasks/main.yml | 4 ++-- .../cp4d/cp4d-cartridge-install/tasks/main.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml index fa2ae86eb..ad2ee37f0 100644 --- a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml @@ -31,7 +31,7 @@ - name: Create openshift-storage OpenShift project shell: | {{ _create_openshift_storage_project }} - when: not dry_run + when: not cpd_dry_run - name: Retrieve default channel for ocs-operator manifest shell: @@ -87,4 +87,4 @@ --type merge \ --patch '{"spec":{"installPlanApproval":"Manual"}}' when: _aws_sts_mode - when: not dry_run \ No newline at end of file + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/main.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/main.yml index a99d55a88..be759e206 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/main.yml @@ -64,4 +64,4 @@ loop: "{{ _cartridges_to_install | default([]) }}" loop_control: loop_var: _current_cp4d_cartridge - when: not_dry_run \ No newline at end of file + when: not cpd_dry_run \ No newline at end of file From 891d9b44ed463df18cb91a66cbceae177b185519 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 20:53:26 +0000 Subject: [PATCH 23/51] #820 Dry-run for Keycloak --- .../tasks/configure-keycloak.yml | 61 ++++++++++-------- .../tasks/configure-openshift-redhat-sso.yml | 63 +++++++++++++------ 2 files changed, 79 insertions(+), 45 deletions(-) diff --git a/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml b/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml index 578ec9dea..909eb6a49 100644 --- a/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml +++ b/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml @@ -4,32 +4,41 @@ src: redhat-sso-keycloak.j2 dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml" -- name: Create Keycloak from YAML file {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml - shell: | - oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml - -- name: Wait until Keycloak {{ _keycloak_name }} is ready - shell: | - oc get keycloaks.keycloak.org -n {{ _keycloak_name }} {{ _keycloak_name }} \ - -o jsonpath='{.status.ready}' - register: _keycloak_status - retries: 30 - delay: 30 - until: (_keycloak_status.stdout | lower) == "true" +- 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: "Create Keycloak {{ _keycloak_name }}" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" -- name: Get Keycloak information - include_role: - name: get-keycloak-info - vars: - _p_keycloak_name: "{{ _keycloak_name }}" +- block: + - name: Create Keycloak from YAML file {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml + shell: | + oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml + + + - name: Wait until Keycloak {{ _keycloak_name }} is ready + shell: | + oc get keycloaks.keycloak.org -n {{ _keycloak_name }} {{ _keycloak_name }} \ + -o jsonpath='{.status.ready}' + register: _keycloak_status + retries: 30 + delay: 30 + until: (_keycloak_status.stdout | lower) == "true" + 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) ... + + - name: Get Keycloak information + include_role: + name: get-keycloak-info + vars: + _p_keycloak_name: "{{ _keycloak_name }}" -- name: Create Keycloak groups - include_tasks: create-keycloak-group.yml - loop: "{{ _current_openshift_redhat_sso.groups | default([]) }}" - loop_control: - loop_var: _current_keycloak_group \ No newline at end of file + - name: Create Keycloak groups + include_tasks: create-keycloak-group.yml + loop: "{{ _current_openshift_redhat_sso.groups | default([]) }}" + loop_control: + loop_var: _current_keycloak_group + when: not cpd_dry_run diff --git a/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml b/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml index 17f1a89d0..fde72f50c 100644 --- a/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml +++ b/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml @@ -3,40 +3,65 @@ template: src: redhat-sso-namespace.j2 dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-namespace.yaml" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create Red Hat SSO namespace {{ _keycloak_name }}" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-namespace.yaml" + - name: Create Red Hat SSO namespace {{ _keycloak_name }} shell: | oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-namespace.yaml + when: not cpd_dry_run - name: Generate yaml for Red Hat SSO operator group in project {{ _keycloak_name }} template: src: redhat-sso-operatorgroup.j2 dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create Red Hat SSO operatorgroup in project {{ _keycloak_name }}" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" + - name: Create Red Hat SSO operatorgroup in project {{ _keycloak_name }} shell: | oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml + when: not cpd_dry_run - name: Generate yaml for Red Hat SSO subscription in project {{ _keycloak_name }} template: src: redhat-sso-subscription.j2 dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-subscription.yaml" -- name: Create Red Hat SSO operator in project {{ _keycloak_name }} - shell: | - oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-subscription.yaml -# Wait until subscription has been successfully created -- name: Wait until Red Hat SSO operator in project {{ _keycloak_name }} has status Succeeded - shell: | - oc get csv -n {{ _keycloak_name }} \ - -l operators.coreos.com/rhsso-operator.{{ _keycloak_name }} \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _redhat_sso_csv_status - retries: 30 - delay: 30 - until: _redhat_sso_csv_status.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) ... \ No newline at end of file + _p_activity_description: "Create Red Hat SSO operator in project {{ _keycloak_name }}" + _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" + +- block: + - name: Create Red Hat SSO operator in project {{ _keycloak_name }} + shell: | + oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-subscription.yaml + + # Wait until subscription has been successfully created + - name: Wait until Red Hat SSO operator in project {{ _keycloak_name }} has status Succeeded + shell: | + oc get csv -n {{ _keycloak_name }} \ + -l operators.coreos.com/rhsso-operator.{{ _keycloak_name }} \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _redhat_sso_csv_status + retries: 30 + delay: 30 + until: _redhat_sso_csv_status.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 \ No newline at end of file From 6d9250f47a00e7e5e9a97fec2851599736092c2c Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 1 Nov 2024 21:03:15 +0000 Subject: [PATCH 24/51] #820 Dry-run for OpenShift ADP --- .../openshift-adp/tasks/main.yml | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml b/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml index 2afb3ed96..74bd7485c 100644 --- a/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml +++ b/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml @@ -5,10 +5,31 @@ - _p_openshift_cluster is defined - block: - - name: Create project openshift-adp if it doesn't exist + - set_fact: + _create_openshift_adp_ns: "oc create ns openshift-adp || true" + _annotate_openshift_adp_ns: 'oc annotate namespace openshift-adp openshift.io/node-selector="" --overwrite' + + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create project openshift-adp" + _p_activity_commandl: "{{ _create_openshift_adp_ns }}" + + - name: Create project openshift-adp shell: | - oc create ns openshift-adp || true - oc annotate namespace openshift-adp openshift.io/node-selector="" --overwrite + {{ _create_openshift_adp_ns }} + when: not cpd_dry_run + + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Annotate project openshift-adp namespace" + _p_activity_commandl: "{{ _annotate_openshift_adp_ns }}" + + - name: Annotate project openshift-adp namespace + shell: | + {{ _annotate_openshift_adp_ns }} + when: not cpd_dry_run - name: Retrieve default channel for redhad-oadp-operator manifest shell: @@ -23,8 +44,15 @@ src: openshift-adp-sub.j2 dest: "{{ status_dir }}/openshift/openshift-adp-sub.yaml" + - include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Activate OpenShift Advanced Data Protection" + _p_activity_yaml: "{{ status_dir }}/openshift/openshift-adp-sub.yaml" + - name: Apply yaml for Advanced Data Protection subscription shell: | oc apply -f {{ status_dir }}/openshift/openshift-adp-sub.yaml + when: not cpd_dry_run when: (_p_openshift_cluster.oadp | default(False) | bool) \ No newline at end of file From d7ff15fba823bdcad07b5375e295b1953c11b167 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Sun, 3 Nov 2024 20:18:26 +0000 Subject: [PATCH 25/51] #820 Dry-run for OpenLDAP --- .../cloud-native-toolkit/tasks/main.yml | 100 +++++++++++------- .../demo-openldap/tasks/install-openldap.yml | 16 ++- .../demo-openldap/tasks/remove-openldap.yml | 7 ++ 3 files changed, 85 insertions(+), 38 deletions(-) diff --git a/automation-roles/40-configure-infra/cloud-native-toolkit/tasks/main.yml b/automation-roles/40-configure-infra/cloud-native-toolkit/tasks/main.yml index 90fb8e5a1..9ffb97cd7 100644 --- a/automation-roles/40-configure-infra/cloud-native-toolkit/tasks/main.yml +++ b/automation-roles/40-configure-infra/cloud-native-toolkit/tasks/main.yml @@ -10,44 +10,70 @@ repo: "{{ _cntk_github_repo }}" dest: "{{ status_dir }}/openshift/multi-tenancy-gitops" - - name: Install GitOps operator - shell: | - oc apply -f {{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x - - - name: Wait until OpenShift GitOps CSV has status Succeeded - shell: | - oc get csv -n openshift-operators \ - -l operators.coreos.com/openshift-gitops-operator.openshift-operators \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _openshift_gitops_csv_status - retries: 30 - delay: 30 - until: _openshift_gitops_csv_status.stdout == "1" + - name: 'Lookup *.yaml files in {{ status_dir }}/openshift/multi-tenancy-gitops' + find: + paths: '{{ status_dir }}/openshift/multi-tenancy-gitops' + file_type: any + patterns: '*.yaml' + follow: False + recurse: False + register: _gitops_yaml_files + + - 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) ... - - - name: Create ArgoCD instance - shell: | - oc apply -f {{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x/argocd-instance/argocd-instance.yaml \ - -n openshift-gitops - - - name: Wait until ArgoCD instance has been created in OpenShift project openshift-gitops - shell: | - oc get argocd -n openshift-gitops openshift-gitops-cntk \ - --no-headers | wc -l - register: _argocd_instance - retries: 30 - delay: 30 - until: _argocd_instance.stdout == "1" + _p_activity_description: "Install GitOps operator file {{ item.path }}" + _p_activity_yaml: "{{ item.path }}" + loop: '{{ _gitops_yaml_files.files }}' + + - block: + - name: Install GitOps operator + shell: | + oc apply -f {{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x + + - name: Wait until OpenShift GitOps CSV has status Succeeded + shell: | + oc get csv -n openshift-operators \ + -l operators.coreos.com/openshift-gitops-operator.openshift-operators \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _openshift_gitops_csv_status + retries: 30 + delay: 30 + until: _openshift_gitops_csv_status.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 + + - 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: "Create ArgoCD instance" + _p_activity_yaml: "{{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x/argocd-instance/argocd-instance.yaml" + + - block: + - name: Create ArgoCD instance + shell: | + oc apply -f {{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x/argocd-instance/argocd-instance.yaml \ + -n openshift-gitops + + - name: Wait until ArgoCD instance has been created in OpenShift project openshift-gitops + shell: | + oc get argocd -n openshift-gitops openshift-gitops-cntk \ + --no-headers | wc -l + register: _argocd_instance + retries: 30 + delay: 30 + until: _argocd_instance.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 when: (_p_openshift_cluster.cloud_native_toolkit | default(False) | bool) \ No newline at end of file diff --git a/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml b/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml index 782cacc77..11086efe7 100644 --- a/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml +++ b/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml @@ -42,6 +42,12 @@ state: directory mode: u+rwx +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Create project {{ _openldap_project_name }}" + _p_activity_command: "oc adm new-project {{ _openldap_project_name }} || true" + - name: Create Project {{ _openldap_project_name }} ansible.builtin.include_role: name: common @@ -49,6 +55,7 @@ vars: common_namespace_name: "{{ _openldap_project_name }}" common_output_directory: "{{ _v_openldap_base_dir }}" + when: not cpd_dry_run - name: Prepare OpenLDAP yaml file for cluster {{ current_openshift_cluster.name }} ansible.builtin.template: @@ -62,6 +69,12 @@ - deployments - services +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Install OpenLDAP" + _p_activity_yaml: "{{ _v_openldap_base_dir }}/{{ current_openshift_cluster.name }}-{{ _current_demo_openldap.name }}-openldap-{{ item }}.yaml" + - name: Add OpenLDAP item {{ item.name }} kubernetes.core.k8s: state: present @@ -74,4 +87,5 @@ - {name: secrets, wait_sleep: 15, wait_timeout: 15} - {name: persistentvolumeclaims, wait_sleep: 15, wait_timeout: 300} - {name: deployments, wait_sleep: 15, wait_timeout: 600} - - {name: services, wait_sleep: 15, wait_timeout: 15} \ No newline at end of file + - {name: services, wait_sleep: 15, wait_timeout: 15} + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml b/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml index 77184647b..1e4e3d01f 100644 --- a/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml +++ b/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml @@ -1,3 +1,9 @@ +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Delete project {{ _openldap_project_name }}" + _p_activity_command: "oc delete ns {{ _openldap_project_name }} --ignore-not-found" + - name: Remove OpenShift project {{ _openldap_project_name }} kubernetes.core.k8s: state: absent @@ -7,3 +13,4 @@ wait: true wait_sleep: 15 wait_timeout: 120 + when: not cpd_dry_run \ No newline at end of file From 178dd369d4b1c7b0ef03126a28039113124f1f78 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 8 Nov 2024 09:19:00 +0000 Subject: [PATCH 26/51] #820 Wrong variable for console banner --- .../40-configure-infra/openshift-console-banner/tasks/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml index 436cec9ed..dd3b97934 100644 --- a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml +++ b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml @@ -25,7 +25,7 @@ name: log-deployer-activity vars: _p_activity_description: "Setup Multicloud Object Gateway" - _p_activity_command: "{{ _setup_mcg_command }}" + _p_activity_command: "{{ _delete_openshift_console_banner }}" - name: Delete console banner if not specified shell: | From 65b20484ca5f147a27d1710055ffc8a21556ae32 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Fri, 8 Nov 2024 09:19:34 +0000 Subject: [PATCH 27/51] #820 Create catalog fails with dry-run --- .../cp4d-install-cartridges-olm-utils.yml | 48 +++---- .../tasks/cp4d-install-cr-dp.yml | 40 +++--- .../tasks/cp4d-install-cr-ws_runtime.yml | 36 +++--- .../tasks/cp4d-install-separate-cr-apply.yml | 40 +++--- .../tasks/create-catalog-source-olm-utils.yml | 122 +++++++++--------- .../tasks/install-control-plane-olm-utils.yml | 36 +++--- .../cp4d-create-subscriptions-olm-utils.yml | 36 +++--- 7 files changed, 186 insertions(+), 172 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml index 094580312..066f94a8d 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml @@ -6,33 +6,35 @@ loop_var: _current_cp4d_cartridge # Always generate the preview script to log what will be done -- name: Generate command preview script to install cartridges - set_fact: - _apply_cr_command_script: "{{ lookup('template', 'apply-cr-cartridges.j2') }}" - vars: - _p_preview_script: True +- block: + - name: Generate command preview script to install cartridges + set_fact: + _apply_cr_command_script: "{{ lookup('template', 'apply-cr-cartridges.j2') }}" + vars: + _p_preview_script: True -- name: Show apply-cr command for install cartridges preview script - debug: - var: _apply_cr_command_script + - name: Show apply-cr command for install cartridges preview script + debug: + var: _apply_cr_command_script -- name: Generate preview script to install cartridges, 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: Generate preview script to install cartridges, 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-cartridges.sh - copy: - src: "/tmp/work/preview.sh" - dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.sh" - remote_src: True - mode: u+rwx + - name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.sh + copy: + src: "/tmp/work/preview.sh" + dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.sh" + remote_src: True + mode: u+rwx -# TODO: Remove patch once fixed in product -- name: Patch DashboardService in apply-cr script to workaround defect - ansible.builtin.replace: - path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.sh" - regexp: 'kind:\s+dashboardservice' - replace: 'kind: DashboardService' + # TODO: Remove patch once fixed in product + - name: Patch DashboardService in apply-cr script to workaround defect + ansible.builtin.replace: + path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.sh" + regexp: 'kind:\s+dashboardservice' + replace: 'kind: DashboardService' + when: not cpd_dry_run - name: Generate apply-cr command to install cartridges set_fact: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml index 2526effec..4f266da88 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml @@ -4,26 +4,28 @@ msg: "" # 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 +- block: + - 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log - shell: | - {{ _apply_cr_command_script }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.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: 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log + shell: | + {{ _apply_cr_command_script }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.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 + when: not cpd_dry_run - name: Generate apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }} set_fact: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml index fdee54d82..cae9ec7b7 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml @@ -12,26 +12,28 @@ - name: Install NotebookRuntime if it doesn't exist yet or is not of the correct version block: - - name: "Generate command preview script to install runtime {{ _ws_runtime }}" - set_fact: - _apply_ws_runtime_command_script: "{{ lookup('template', 'apply-ws-runtime.j2') }}" - vars: - _p_preview_script: True + - block: + - name: "Generate command preview script to install runtime {{ _ws_runtime }}" + set_fact: + _apply_ws_runtime_command_script: "{{ lookup('template', 'apply-ws-runtime.j2') }}" + vars: + _p_preview_script: True - - name: Show apply-cr command to install runtime - debug: - var: _apply_ws_runtime_command_script + - name: Show apply-cr command to install runtime + debug: + var: _apply_ws_runtime_command_script - - name: Generate preview script to install runtime {{ _ws_runtime }} - shell: | - {{ _apply_ws_runtime_command_script }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log 2>&1 + - name: Generate preview script to install runtime {{ _ws_runtime }} + shell: | + {{ _apply_ws_runtime_command_script }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log 2>&1 - - name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.sh - copy: - src: "/tmp/work/preview.sh" - dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.sh" - remote_src: True - mode: u+rwx + - name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.sh + copy: + src: "/tmp/work/preview.sh" + dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.sh" + remote_src: True + mode: u+rwx + when: not cpd_dry_run - name: "Generate command to install runtime {{ _ws_runtime }}" set_fact: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml index 5a1fc56a5..a85b1d37f 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml @@ -9,26 +9,28 @@ register: _cartridge_install_options_file # 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-separate.j2') }}" - vars: - _p_preview_script: True +- block: + - name: "Generate command preview script to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}" + set_fact: + _apply_cr_command_script: "{{ lookup('template', 'apply-cr-separate.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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log - shell: | - {{ _apply_cr_command_script }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log 2>&1 - -- name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-{{ _current_cp4d_cartridge.olm_utils_name }}.sh - copy: - src: "/tmp/work/preview.sh" - dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-{{ _current_cp4d_cartridge.olm_utils_name }}.sh" - remote_src: True - mode: u+rwx + - 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log + shell: | + {{ _apply_cr_command_script }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log 2>&1 + + - name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-{{ _current_cp4d_cartridge.olm_utils_name }}.sh + copy: + src: "/tmp/work/preview.sh" + dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-{{ _current_cp4d_cartridge.olm_utils_name }}.sh" + remote_src: True + mode: u+rwx + when: not cpd_dry_run - name: Generate apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }} set_fact: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml index 261d64f3b..c504645b9 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml @@ -17,66 +17,68 @@ when: (cpd_airgap | default(False) | bool) # Always generate the preview script to log what will be done -- name: Generate command preview script to create catalog sources for Cloud Pak for Data {{ _p_catsrc_scope }} - set_fact: - _apply_olm_command_script: "{{ lookup('template', 'apply-olm-create-catsrc.j2') }}" - vars: - _p_preview_script: True - -- name: Show apply-olm command to create catalog sources - debug: - var: _apply_olm_command_script - -- name: Write script to "{{ status_dir }}/cp4d/apply-olm-catsrc-{{ _p_catsrc_scope }}.sh" - copy: - content: "{{ _apply_olm_command_script }}" - dest: "{{ status_dir }}/cp4d/apply-olm-catsrc-{{ _p_catsrc_scope }}.sh" - -- name: Generate preview script to create catalog sources, logs are in {{ status_dir }}/log/apply-olm-create-catsrc-{{ _p_catsrc_scope }}.log - shell: | - {{ _apply_olm_command_script }} > {{ status_dir }}/log/apply-olm-create-catsrc-{{ _p_catsrc_scope }}.log 2>&1 - -- name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh - copy: - src: "/tmp/work/preview.sh" - dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh" - remote_src: True - mode: u+rwx - -# TODO: Remove step once problem in preview.sh is fixed -- name: Update script to fix invalid oc apply -f commands - replace: - path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh" - regexp: '^(.*)oc apply -f << EOF(.*)' - replace: 'oc apply -f - << EOF' - -# TODO: Remove step once problem in olm-utils is fixed -- name: Update script to fix invalid cpd-platform catalog source image - replace: - path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh" - 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-{{ _p_catsrc_scope }}.sh" - regexp: '(ibm-ws-pipelines-\d.\d.\d)(.tgz)' - replace: '\1*\2' - -# 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-{{ _p_catsrc_scope }}.sh" - regexp: '(ibm-replication-\d.\d.\d)(.tgz)' - replace: '\1*\2' - -# TODO: Remove step once problem in olm-utils is fixed -- name: Update script to fix invalid DataGate create catalog source command - replace: - path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh" - regexp: '(ibm-datagate-prod-\d.\d.\d)(.tgz)' - replace: '\1*\2' +- block: + - name: Generate preview script to create catalog sources for Cloud Pak for Data {{ _p_catsrc_scope }} + set_fact: + _apply_olm_command_script: "{{ lookup('template', 'apply-olm-create-catsrc.j2') }}" + vars: + _p_preview_script: True + + - name: Show apply-olm command to create catalog sources + debug: + var: _apply_olm_command_script + + - name: Write script to "{{ status_dir }}/cp4d/apply-olm-catsrc-{{ _p_catsrc_scope }}.sh" + copy: + content: "{{ _apply_olm_command_script }}" + dest: "{{ status_dir }}/cp4d/apply-olm-catsrc-{{ _p_catsrc_scope }}.sh" + + - name: Generate script to create catalog sources, logs are in {{ status_dir }}/log/apply-olm-create-catsrc-{{ _p_catsrc_scope }}.log + shell: | + {{ _apply_olm_command_script }} > {{ status_dir }}/log/apply-olm-create-catsrc-{{ _p_catsrc_scope }}.log 2>&1 + + - name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh + copy: + src: "/tmp/work/preview.sh" + dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh" + remote_src: True + mode: u+rwx + + # TODO: Remove step once problem in preview.sh is fixed + - name: Update script to fix invalid oc apply -f commands + replace: + path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh" + regexp: '^(.*)oc apply -f << EOF(.*)' + replace: 'oc apply -f - << EOF' + + # TODO: Remove step once problem in olm-utils is fixed + - name: Update script to fix invalid cpd-platform catalog source image + replace: + path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh" + 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-{{ _p_catsrc_scope }}.sh" + regexp: '(ibm-ws-pipelines-\d.\d.\d)(.tgz)' + replace: '\1*\2' + + # 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-{{ _p_catsrc_scope }}.sh" + regexp: '(ibm-replication-\d.\d.\d)(.tgz)' + replace: '\1*\2' + + # TODO: Remove step once problem in olm-utils is fixed + - name: Update script to fix invalid DataGate create catalog source command + replace: + path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-create-catsrc-{{ _p_catsrc_scope }}.sh" + regexp: '(ibm-datagate-prod-\d.\d.\d)(.tgz)' + replace: '\1*\2' + when: not cpd_dry_run - name: Generate OLM command to create catalog sources for Cloud Pak for Data {{ _p_catsrc_scope }} set_fact: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml index 61e19f3cc..58e0a7187 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml @@ -16,26 +16,28 @@ cloudpakfordata: true iamIntegration: {{ current_cp4d_cluster.use_fs_iam | default(False) | bool }} -- name: Generate apply-cr command to install Cloud Pak for Data platform - set_fact: - _apply_cr_command: "{{ lookup('template', 'apply-cr-cpd-platform.j2') }}" - vars: - _p_preview_script: True +- block: + - name: Generate apply-cr preview script to install Cloud Pak for Data platform + set_fact: + _apply_cr_command: "{{ lookup('template', 'apply-cr-cpd-platform.j2') }}" + vars: + _p_preview_script: True -- name: Show apply-cr command to install Cloud Pak for Data platform - debug: - var: _apply_cr_command + - name: Show apply-cr command to install Cloud Pak for Data platform + debug: + var: _apply_cr_command -- name: Generate preview script 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 + - name: Generate preview script 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 -- name: Copy script to {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-cr-platform.sh - copy: - src: "/tmp/work/preview.sh" - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-cr-platform.sh" - remote_src: True - mode: u+rwx + - name: Copy script to {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-cr-platform.sh + copy: + src: "/tmp/work/preview.sh" + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-cr-platform.sh" + remote_src: True + mode: u+rwx + when: not cpd_dry_run - name: Generate apply-cr command to install Cloud Pak for Data platform set_fact: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/tasks/cp4d-create-subscriptions-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/tasks/cp4d-create-subscriptions-olm-utils.yml index 51e6954ea..e41fb6da3 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/tasks/cp4d-create-subscriptions-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-subscriptions/tasks/cp4d-create-subscriptions-olm-utils.yml @@ -15,26 +15,28 @@ _subscription_cartridges_to_install_list: "cpfs,cpd_platform" when: _p_subscription_scope == 'platform' -- name: Generate preview script to create subscriptions for Cloud Pak for Data {{ _p_subscription_scope }} - set_fact: - _apply_olm_command_script: "{{ lookup('template', 'apply-olm-cartridge-sub.j2') }}" - vars: - _p_preview_script: True +- block: + - name: Generate preview script to create subscriptions for Cloud Pak for Data {{ _p_subscription_scope }} + set_fact: + _apply_olm_command_script: "{{ lookup('template', 'apply-olm-cartridge-sub.j2') }}" + vars: + _p_preview_script: True -- name: Show apply-olm command to create subscriptions for Cloud Pak for Data {{ _p_subscription_scope }} - debug: - var: _apply_olm_command_script + - name: Show apply-olm command to create subscriptions for Cloud Pak for Data {{ _p_subscription_scope }} + debug: + var: _apply_olm_command_script -- name: Generate preview script to install {{ _p_subscription_scope }} subscriptions, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.log - shell: | - {{ _apply_olm_command_script }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.log 2>&1 + - name: Generate preview script to install {{ _p_subscription_scope }} subscriptions, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.log + shell: | + {{ _apply_olm_command_script }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.log 2>&1 -- name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.sh - copy: - src: "/tmp/work/preview.sh" - dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.sh" - remote_src: True - mode: u+rwx + - name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.sh + copy: + src: "/tmp/work/preview.sh" + dest: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-subscriptions-{{ _p_subscription_scope }}.sh" + remote_src: True + mode: u+rwx + when: not cpd_dry_run - name: Generate OLM utils command to create subscriptions for Cloud Pak for Data {{ _p_subscription_scope }} set_fact: From c41538bc2045edec0252ea77af18abd3be4924cc Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Wed, 20 Nov 2024 17:46:29 +0000 Subject: [PATCH 28/51] #820 Skip SSL certificate --- .../tasks/cp4d-cluster-configure.yml | 5 ++++- .../tasks/configure-ssl-certificate.yml | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-cluster-configure/tasks/cp4d-cluster-configure.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-cluster-configure/tasks/cp4d-cluster-configure.yml index 06b8ac785..5b8cac283 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-cluster-configure/tasks/cp4d-cluster-configure.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-cluster-configure/tasks/cp4d-cluster-configure.yml @@ -53,7 +53,9 @@ - name: Error if no secret value is returned fail: msg: Unable to acquire secret value for {{ _cp4d_admin_password_vault_key_name }} - when: "_cp4d_admin_password==''" + when: + - _cp4d_admin_password=='' + - not cpd_dry_run - name: Login to Cloud Pak for Data as the admin user include_role: @@ -61,6 +63,7 @@ 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 diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/configure-ssl-certificate.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/configure-ssl-certificate.yml index 34d0e2d61..2119a67d3 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/configure-ssl-certificate.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/configure-ssl-certificate.yml @@ -41,7 +41,9 @@ _update_cp4d_ssl_config: 1 when: _cp4d_existing_external_tls_secret_result.stdout == "0" -- when: _cp4d_existing_external_tls_secret_result.stdout == "1" +- when: + - _cp4d_existing_external_tls_secret_result.stdout == "1" + - not cpd_dry_run block: - name: Get current cert.crt from Cloud Pak for Data shell: | @@ -66,7 +68,9 @@ msg: "No changes to current TLS certificate of Cloud Pak for Data, skipping configuration of TLS certificate" when: _update_cp4d_ssl_config == 0 -- when: _update_cp4d_ssl_config == 1 +- when: + - _update_cp4d_ssl_config == 1 + - not cpd_dry_run block: - name: Delete existing external-tls-secret if present shell: | From ea1ab0d0e1113237cab3e10730ea138befd72e23 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Sat, 23 Nov 2024 13:10:30 +0000 Subject: [PATCH 29/51] #820 CP4D Audit dry-run --- .../tasks/configure-cpd-audit.yml | 46 +++++++++++-------- .../tasks/configure-ssl-certificate.yml | 6 +++ .../tasks/log-deployer-comment.yml | 16 +++++++ .../log-deployer-activity/tasks/main.yml | 5 +- 4 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-comment.yml diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-audit/tasks/configure-cpd-audit.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-audit/tasks/configure-cpd-audit.yml index 9692dc080..ee0b7405f 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-audit/tasks/configure-cpd-audit.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-audit/tasks/configure-cpd-audit.yml @@ -5,25 +5,33 @@ src: cpd-audit-fluent-config.j2 dest: "{{ status_dir }}/cp4d/fluent.conf" -- name: Apply audit configuration - shell: - oc set data -n {{ current_cp4d_cluster.project }} cm/zen-audit-config \ - --from-file={{ status_dir }}/cp4d/fluent.conf - register: _audit_set_data - changed_when: "'zen-audit-config data updated' in _audit_set_data.stdout" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Apply audit configuration to Cloud Pak for Data instance" + _p_activity_yaml: "{{ status_dir }}/cp4d/fluent.conf" -- name: Restart audit pods if configuration was changed - shell: - oc delete po -n {{ current_cp4d_cluster.project }} -l component=zen-audit - when: _audit_set_data.changed +- block: + - name: Apply audit configuration from {{ status_dir }}/cp4d/fluent.conf + shell: + oc set data -n {{ current_cp4d_cluster.project }} cm/zen-audit-config \ + --from-file={{ status_dir }}/cp4d/fluent.conf + register: _audit_set_data + changed_when: "'zen-audit-config data updated' in _audit_set_data.stdout" -- name: Apply replication factor - shell: - oc scale -n {{ current_cp4d_cluster.project }} deploy/zen-audit --replicas={{ _cp4d_audit_config.audit_replicas | default(1) }} + - name: Restart audit pods if configuration was changed + shell: + oc delete po -n {{ current_cp4d_cluster.project }} -l component=zen-audit + when: _audit_set_data.changed -- name: Apply audit output for OpenShift logging - include_tasks: configure-cpd-audit-openshift.yml - loop: "{{ _cp4d_audit_config.audit_output | default([]) }}" - when: _current_audit_output.type=='openshift-logging' - loop_control: - loop_var: _current_audit_output \ No newline at end of file + - name: Apply replication factor + shell: + oc scale -n {{ current_cp4d_cluster.project }} deploy/zen-audit --replicas={{ _cp4d_audit_config.audit_replicas | default(1) }} + + - name: Apply audit output for OpenShift logging + include_tasks: configure-cpd-audit-openshift.yml + loop: "{{ _cp4d_audit_config.audit_output | default([]) }}" + when: _current_audit_output.type=='openshift-logging' + loop_control: + loop_var: _current_audit_output + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/configure-ssl-certificate.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/configure-ssl-certificate.yml index 2119a67d3..d029ee804 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/configure-ssl-certificate.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/configure-ssl-certificate.yml @@ -41,6 +41,12 @@ _update_cp4d_ssl_config: 1 when: _cp4d_existing_external_tls_secret_result.stdout == "0" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Apply SSL configuration to Cloud Pak for Data" + _p_activity_comment: "Apply SSL configuration to secret external-tls-secret in OpenShift project {{ current_cp4d_cluster.project }}" + - when: - _cp4d_existing_external_tls_secret_result.stdout == "1" - not cpd_dry_run diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-comment.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-comment.yml new file mode 100644 index 000000000..d0fa0b3fc --- /dev/null +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-comment.yml @@ -0,0 +1,16 @@ +--- +- name: Write deployer activity to {{ status_dir }}/log/deployer-actitivies.log + blockinfile: + path: "{{ status_dir }}/log/deployer-actitivies.log" + create: True + insertafter: EOF + marker: "" + block: | + + # --- + # + # Activity timestamp: {{ now(utc=true,fmt='%Y-%m-%d %H:%M:%S') }} + # Deployer activity: {{ _deployer_activity_sequence }} + # Description: {{ _p_activity_description | default("") }} + # Comment: {{ _p_activity_comment }} + # --- \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml index 23f32f612..27ecb21d4 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml @@ -12,4 +12,7 @@ when: _p_activity_yaml | default('') != '' - include_tasks: log-deployer-script-file.yml - when: _p_activity_script | default('') != '' \ No newline at end of file + when: _p_activity_script | default('') != '' + +- include_tasks: log-deployer-comment.yml + when: _p_activity_comment | default('') != '' \ No newline at end of file From b19e4b3b60698eaa4de71c13174209121f415a5b Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Sat, 23 Nov 2024 19:26:13 +0000 Subject: [PATCH 30/51] #820 LDAP dry-run --- .../cp4d/cp4d-configure-ldap/tasks/main.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ldap/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ldap/tasks/main.yml index d6ab32d4f..1241af125 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ldap/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ldap/tasks/main.yml @@ -21,12 +21,17 @@ - name: Configure CP4D LDAP connectivity include_tasks: configure-cpd-ldap-integration.yml + when: not cpd_dry_run - name: Disable CP4D LDAP connectivity include_tasks: disable-cpd-ldap-integration.yml - when: "_cp4d_ldap_config_list|length == 0" + when: + - _cp4d_ldap_config_list|length == 0 + - not cpd_dry_run - name: Configure CP4D LDAP connectivity include_tasks: disable-cpd-ldap-integration.yml - when: all_config.cp4d_ldap_config is not defined + when: + - all_config.cp4d_ldap_config is not defined + - not cpd_dry_run \ No newline at end of file From b7c77bf643373a18d5f7864799a4827635b57eda Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Mon, 25 Nov 2024 10:40:10 +0000 Subject: [PATCH 31/51] #820 CP4D instances --- .../tasks/main.yml | 1 + .../delete_analyticsengine_instances.yml | 47 +- .../tasks/delete_cognos_instances.yml | 1 + .../cp4d/cp4d-instance-cognos/tasks/main.yml | 3 +- .../tasks/provision_cognos_instance.yml | 618 +++++++++--------- .../tasks/delete-cpd-edb-instances.yml | 1 + .../cp4d/cp4d-instance-cpd-edb/tasks/main.yml | 10 +- .../tasks/provision-cpd-edb-instance.yml | 62 +- .../tasks/delete_datastage_instances.yml | 22 +- .../cp4d-instance-datastage/tasks/main.yml | 3 +- .../tasks/provision_datastage_instance.yml | 244 +++---- .../tasks/delete_db2_instances.yml | 1 + .../cp4d/cp4d-instance-db2oltp/tasks/main.yml | 3 +- .../tasks/provision_db2_instance.yml | 172 ++--- .../tasks/delete_dmc_instances.yml | 1 + .../cp4d/cp4d-instance-dmc/tasks/main.yml | 3 +- .../tasks/provision_dmc_instance.yml | 92 +-- .../tasks/delete_dv_instances.yml | 1 + .../cp4d/cp4d-instance-dv/tasks/main.yml | 3 +- .../tasks/provision_dv_instance.yml | 92 +-- .../tasks/delete_openpages_instances.yml | 1 + .../cp4d-instance-openpages/tasks/main.yml | 3 +- .../tasks/provision_openpages_instance.yml | 76 ++- .../tasks/delete_wa_instances.yml | 1 + .../tasks/main.yml | 3 +- .../tasks/provision_wa_instance.yml | 96 +-- .../tasks/delete_wd_instances.yml | 1 + .../tasks/main.yml | 3 +- .../tasks/provision_wd_instance.yml | 97 +-- .../tasks/configure-watsonx_ai-instances.yml | 9 +- .../cp4d-instance-watsonx_ai/tasks/main.yml | 4 +- ...cript.yml => log-deployer-script-file.yml} | 0 32 files changed, 889 insertions(+), 785 deletions(-) rename automation-roles/99-generic/deployer/log-deployer-activity/tasks/{log-deployer-yaml-script.yml => log-deployer-script-file.yml} (100%) diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-dmc-profiles/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-dmc-profiles/tasks/main.yml index 68a7fd3ca..d927836b6 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-dmc-profiles/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-dmc-profiles/tasks/main.yml @@ -20,6 +20,7 @@ validate_certs: no status_code: 200 register: _dmc_instances_lookup_result + when: not cpd_dry_run - include_tasks: create-dmc-profiles.yml when: diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-analyticsengine/tasks/delete_analyticsengine_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-analyticsengine/tasks/delete_analyticsengine_instances.yml index 083077920..74c6ecb3c 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-analyticsengine/tasks/delete_analyticsengine_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-analyticsengine/tasks/delete_analyticsengine_instances.yml @@ -1,27 +1,30 @@ --- -- name: Get all current Analytics Engine instances - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_analyticsengine_instance_addon_type }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _all_ae_instances +- block: + - name: Get all current Analytics Engine instances + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_analyticsengine_instance_addon_type }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _all_ae_instances + -- name: Get all current Analytics Engine storage instances - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_volumes_instance_addon_type }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _all_ae_storage_instances + - name: Get all current Analytics Engine storage instances + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_volumes_instance_addon_type }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _all_ae_storage_instances + when: not cpd_dry_run # Loop through all deployed Analytics Engine instance definitions to check if instance no longer exists in the config - name: Loop through each Analytics Engine instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/delete_cognos_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/delete_cognos_instances.yml index 72511e524..40a5bf75c 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/delete_cognos_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/delete_cognos_instances.yml @@ -10,6 +10,7 @@ validate_certs: no status_code: 200 register: _all_cognos_instances + when: not cpd_dry_run # Loop through all deployed Cognos Analytics instance definitions to check if instance no longer exists in the config - name: Loop through each Cognos Analytics instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/main.yml index 5c3fbb080..c22fc2f09 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/main.yml @@ -30,4 +30,5 @@ - include_tasks: wait_cognos_instances.yml when: - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/provision_cognos_instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/provision_cognos_instance.yml index 3b1d6b2bf..fc498857c 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/provision_cognos_instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cognos/tasks/provision_cognos_instance.yml @@ -10,312 +10,320 @@ msg: "Cognos Analytics size can be small, medium or large. {{ _cp4d_cognos_instance_tshirt_size }} is not supported." when: _cp4d_cognos_instance_tshirt_size not in ['small','medium','large'] -- name: Check if the Cognos Analytics instance is already running - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_cognos_instance_addon_type }}&display_name={{ _cognos_instance.name }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _cognos_lookup_result - -- set_fact: - _cp4d_cognos_instance_storage_class: "{{ ocp_storage_class_file }}" - _cp4d_cognos_instance_storage_class_block: "{{ ocp_storage_class_block }}" - -- name: Determine if Cognos Analytics instance already exists - debug: - msg: "Cognos Analytics instance {{ _cognos_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, will be skipped" - when: _cognos_lookup_result.json.total_count != 0 - -- set_fact: - _internal_db2_instance_id: "" - -- when: _cognos_lookup_result.json.total_count == 0 - block: - - - name: Get provisioned db2oltp instances with name {{ _cognos_instance.metastore_ref }} - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type=db2oltp&display_name={{ _cognos_instance.metastore_ref }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _db2_lookup_result - - - fail: - msg: Db2 OLTP instance {{ _cognos_instance.metastore_ref }} was not found; the Cognos Analytics instance cannot be provisioned without a valid Db2 OLTP instance - when: _db2_lookup_result.json.total_count == 0 - - - when: _db2_lookup_result.json.total_count == 1 - block: - - name: "Prepare Cognos instance creation using provisioned Db2 OLTP instance {{ _cognos_instance.metastore_ref }}" - include_tasks: prepare_provision_cognos_instance_internal.yml - - - set_fact: - _internal_db2_instance_id: "{{ _db2_lookup_result.json.service_instances[0].id }}" - - - name: Get the list of catalogs to extract the Platform assets catalog ID - uri: - url: 'https://{{ cp4d_url.stdout }}/v2/catalogs' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _cp4d_get_catalog_result - - - debug: - var: _cp4d_get_catalog_result - - - set_fact: - _cp4d_platform_access_catalog: "{{ _cp4d_get_catalog_result.json.catalogs | json_query(query) | first | default({}) }}" - vars: - query: >- - [?entity.name=='Platform assets catalog'] - - - name: Fail if Platform assets catalog could not be found - fail: - msg: Platform assets catalog could not be found in the CP4D instance. - when: _cp4d_platform_access_catalog=={} - - - name: Validate if the connection to the Cognos Db2 Content Repository '{{ _cp4d_platform_connection_name }}' is available - uri: - url: 'https://{{ cp4d_url.stdout }}/v2/connections?catalog_id={{ _cp4d_platform_access_catalog.metadata.guid }}&entity.flags=personal_credentials&entity.name={{ _cp4d_platform_connection_name }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _cp4d_cognos_db2_content_repo_result - - - set_fact: - _cp4d_cognos_db2_content_repo: "{{ _cp4d_cognos_db2_content_repo_result.json.resources | json_query(query_db) }}" - vars: - db2_name: "{{ _cp4d_platform_connection_name }}" - query_db: "[?entity.name=='{{ db2_name }}']" - - - name: Show number of data sources matching platform connection name - debug: - msg: "Number of datasources found with name {{ _cp4d_platform_connection_name }}: {{ _cp4d_cognos_db2_content_repo |length }}" - - - name: Create Cognos Repository DB connection {{ _cp4d_platform_connection_name }} if it does not exist - block: - - name: Get the available connection types - uri: - url: 'https://{{ cp4d_url.stdout }}/v2/datasource_types' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _cp4d_datasource_types_result - - - set_fact: - _cp4d_datasource_db2_type: "{{ _cp4d_datasource_types_result.json.resources | json_query(query) | first }}" - vars: - db2_name: 'db2' - query: "[?entity.name=='{{ db2_name }}'].metadata.asset_id" - - - debug: - var: _cp4d_datasource_db2_type - - - name: Create Datasource connection json file - template: - src: cognos_connection.json.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cp4d_platform_connection_name }}-connection.json" - - - name: Create Datasource connection {{ _cp4d_platform_connection_name }} - shell: | - curl -v -k \ - -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' -H 'Content-Type: application/json' \ - -X POST \ - https://{{ cp4d_url.stdout }}/v2/connections?catalog_id={{ _cp4d_platform_access_catalog.metadata.guid }} \ - -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cp4d_platform_connection_name }}-connection.json - register: _create_cognos_connection_result - when: (_cp4d_cognos_db2_content_repo | length) == 0 - - - name: Get the Global platform connection for '{{ _cp4d_platform_connection_name }}' - uri: - url: 'https://{{ cp4d_url.stdout }}/v2/connections?catalog_id={{ _cp4d_platform_access_catalog.metadata.guid }}&entity.flags=personal_credentials&entity.name={{ _cp4d_platform_connection_name }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _cp4d_cognos_db2_platform_connection_result - - - name: Get the Connection Id of Global Platform connection '{{ _cp4d_platform_connection_name }}' - set_fact: - _cp4d_cognos_db2_platform_connection_id_list: "{{ _cp4d_cognos_db2_platform_connection_result.json.resources | json_query(query) | default([]) }}" - vars: - query: "[?entity.name=='{{ _cp4d_platform_connection_name }}'].metadata.asset_id" - - - fail: - msg: "No Global platform connection with name {{ _cp4d_platform_connection_name }} available" - when: _cp4d_cognos_db2_platform_connection_id_list | length != 1 - - - set_fact: - _cp4d_cognos_db2_platform_connection_id: "{{ _cp4d_cognos_db2_platform_connection_id_list | first }}" - - - name: Confirm the Datasource connection {{ _cp4d_platform_connection_name }} is valid - uri: - body_format: json - body: '{}' - return_content: yes - method: PUT - url: "https://{{ cp4d_url.stdout }}/v2/connections/{{ _cp4d_cognos_db2_platform_connection_id }}/actions/test?catalog_id={{ _cp4d_platform_access_catalog.metadata.guid }}" - headers: - Authorization: "Bearer {{ _cp4d_bearer_token }}" - Content-Type: "application/json" - Accept: "application/json" - validate_certs: no - register: _test_global_platform_connection_result - failed_when: false - - - when: _test_global_platform_connection_result.status != 200 - block: - - debug: - msg: "{{ _test_global_platform_connection_result }}" - - - fail: - msg: "Test connection to Global Platform connection {{ _cp4d_platform_connection_name }} failed. Unable to provision Cognos instance. \ - Validate the Global Platform connection properties, or delete the global platform connection so the Deployer will re-create it. \ - \n Returned Error Message: \n\n {{ _test_global_platform_connection_result.content }}" - - - name: Obtain Cognos Analytics version - shell: - oc get caservice -n {{ current_cp4d_cluster.project }} ca-addon-cr -o jsonpath='{.spec.version}' - register: _ca_version - - - set_fact: - _cognos_instance_pods_count: "7" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision Cognos Analytics instance {{ _cognos_instance.name }}" + _p_activity_comment: "Create Cognos Analytics instance {{ _cognos_instance.name }} using REST API" + +- block: + - name: Check if the Cognos Analytics instance is already running + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_cognos_instance_addon_type }}&display_name={{ _cognos_instance.name }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _cognos_lookup_result + + - set_fact: + _cp4d_cognos_instance_storage_class: "{{ ocp_storage_class_file }}" + _cp4d_cognos_instance_storage_class_block: "{{ ocp_storage_class_block }}" + + - name: Determine if Cognos Analytics instance already exists + debug: + msg: "Cognos Analytics instance {{ _cognos_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, will be skipped" + when: _cognos_lookup_result.json.total_count != 0 + + - set_fact: + _internal_db2_instance_id: "" + + - when: _cognos_lookup_result.json.total_count == 0 + block: + + - name: Get provisioned db2oltp instances with name {{ _cognos_instance.metastore_ref }} + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type=db2oltp&display_name={{ _cognos_instance.metastore_ref }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _db2_lookup_result + + - fail: + msg: Db2 OLTP instance {{ _cognos_instance.metastore_ref }} was not found; the Cognos Analytics instance cannot be provisioned without a valid Db2 OLTP instance + when: _db2_lookup_result.json.total_count == 0 + + - when: _db2_lookup_result.json.total_count == 1 + block: + - name: "Prepare Cognos instance creation using provisioned Db2 OLTP instance {{ _cognos_instance.metastore_ref }}" + include_tasks: prepare_provision_cognos_instance_internal.yml + + - set_fact: + _internal_db2_instance_id: "{{ _db2_lookup_result.json.service_instances[0].id }}" + + - name: Get the list of catalogs to extract the Platform assets catalog ID + uri: + url: 'https://{{ cp4d_url.stdout }}/v2/catalogs' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _cp4d_get_catalog_result + + - debug: + var: _cp4d_get_catalog_result + + - set_fact: + _cp4d_platform_access_catalog: "{{ _cp4d_get_catalog_result.json.catalogs | json_query(query) | first | default({}) }}" + vars: + query: >- + [?entity.name=='Platform assets catalog'] + + - name: Fail if Platform assets catalog could not be found + fail: + msg: Platform assets catalog could not be found in the CP4D instance. + when: _cp4d_platform_access_catalog=={} + + - name: Validate if the connection to the Cognos Db2 Content Repository '{{ _cp4d_platform_connection_name }}' is available + uri: + url: 'https://{{ cp4d_url.stdout }}/v2/connections?catalog_id={{ _cp4d_platform_access_catalog.metadata.guid }}&entity.flags=personal_credentials&entity.name={{ _cp4d_platform_connection_name }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _cp4d_cognos_db2_content_repo_result + + - set_fact: + _cp4d_cognos_db2_content_repo: "{{ _cp4d_cognos_db2_content_repo_result.json.resources | json_query(query_db) }}" + vars: + db2_name: "{{ _cp4d_platform_connection_name }}" + query_db: "[?entity.name=='{{ db2_name }}']" + + - name: Show number of data sources matching platform connection name + debug: + msg: "Number of datasources found with name {{ _cp4d_platform_connection_name }}: {{ _cp4d_cognos_db2_content_repo |length }}" + + - name: Create Cognos Repository DB connection {{ _cp4d_platform_connection_name }} if it does not exist + block: + - name: Get the available connection types + uri: + url: 'https://{{ cp4d_url.stdout }}/v2/datasource_types' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _cp4d_datasource_types_result + + - set_fact: + _cp4d_datasource_db2_type: "{{ _cp4d_datasource_types_result.json.resources | json_query(query) | first }}" + vars: + db2_name: 'db2' + query: "[?entity.name=='{{ db2_name }}'].metadata.asset_id" + + - debug: + var: _cp4d_datasource_db2_type + + - name: Create Datasource connection json file + template: + src: cognos_connection.json.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cp4d_platform_connection_name }}-connection.json" + + - name: Create Datasource connection {{ _cp4d_platform_connection_name }} + shell: | + curl -v -k \ + -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' -H 'Content-Type: application/json' \ + -X POST \ + https://{{ cp4d_url.stdout }}/v2/connections?catalog_id={{ _cp4d_platform_access_catalog.metadata.guid }} \ + -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cp4d_platform_connection_name }}-connection.json + register: _create_cognos_connection_result + when: (_cp4d_cognos_db2_content_repo | length) == 0 + + - name: Get the Global platform connection for '{{ _cp4d_platform_connection_name }}' + uri: + url: 'https://{{ cp4d_url.stdout }}/v2/connections?catalog_id={{ _cp4d_platform_access_catalog.metadata.guid }}&entity.flags=personal_credentials&entity.name={{ _cp4d_platform_connection_name }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _cp4d_cognos_db2_platform_connection_result + + - name: Get the Connection Id of Global Platform connection '{{ _cp4d_platform_connection_name }}' + set_fact: + _cp4d_cognos_db2_platform_connection_id_list: "{{ _cp4d_cognos_db2_platform_connection_result.json.resources | json_query(query) | default([]) }}" + vars: + query: "[?entity.name=='{{ _cp4d_platform_connection_name }}'].metadata.asset_id" + + - fail: + msg: "No Global platform connection with name {{ _cp4d_platform_connection_name }} available" + when: _cp4d_cognos_db2_platform_connection_id_list | length != 1 + + - set_fact: + _cp4d_cognos_db2_platform_connection_id: "{{ _cp4d_cognos_db2_platform_connection_id_list | first }}" - - name: Create cognos instance 4.0 json file - template: - src: cognos_instance_40.json.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_instance.json" - when: _ca_cp4d_version == "4.0" - - - when: _ca_cp4d_version != "4.0" - block: - - - name: Get current secrets - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v2/secrets' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _cp4d_secret_get_result - - - set_fact: - _cp4d_secret_query: "{{ _cp4d_secret_get_result.json.secrets | json_query(secret_smtp) }}" - vars: - secret_smtp_name: "smtpSecret" - secret_smtp: "[?secret_name=='{{ secret_smtp_name }}']" - - - when: _cp4d_secret_query | length == 1 - set_fact: - _cp4d_cognos_smtp_secret: "{{ _cp4d_secret_query[0].secret_urn }}" - - - when: _cp4d_secret_query | length == 0 - block: - - name: Create Cognos smtp secret json - template: - src: cognos_smtp_secret.json.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_smtp_secret.json" - - - name: Create Cognos smtp secret - shell: | - curl -v -k \ - -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ - -H 'Content-Type: application/json' \ - -X POST 'https://{{ cp4d_url.stdout }}/zen-data/v2/secrets' \ - -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_smtp_secret.json - register: _cp4d_cognos_smtp_secret_create_result - - - set_fact: - _cp4d_cognos_smtp_secret_result: "{{ _cp4d_cognos_smtp_secret_create_result.stdout | from_json }}" - - - set_fact: - _cp4d_cognos_smtp_secret: "{{ _cp4d_cognos_smtp_secret_result.secret_urn }}" - - - debug: - msg: "Cognos SMTP Secret: {{ _cp4d_cognos_smtp_secret }}" - - - name: Create cognos instance 4.5 json file - template: - src: "cognos_instance_45_{{ _cp4d_cognos_instance_tshirt_size | lower }}.json.j2" - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_instance.json" - - - set_fact: - _cognos_instance_pods_count: "5" - - - name: Create Cognos instance - shell: | - curl -v -k \ - -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ - -H 'Content-Type: application/json' \ - -X POST \ - 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ - -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_instance.json - register: _cognos_instance_create_result - - - set_fact: - _cognos_instance_create_result_json: "{{ _cognos_instance_create_result.stdout | from_json }}" - - - when: _ca_cp4d_version == "4.0" - block: - - name: Wait until Cognos Analytics artifacts pod has started and is ready + - name: Confirm the Datasource connection {{ _cp4d_platform_connection_name }} is valid + uri: + body_format: json + body: '{}' + return_content: yes + method: PUT + url: "https://{{ cp4d_url.stdout }}/v2/connections/{{ _cp4d_cognos_db2_platform_connection_id }}/actions/test?catalog_id={{ _cp4d_platform_access_catalog.metadata.guid }}" + headers: + Authorization: "Bearer {{ _cp4d_bearer_token }}" + Content-Type: "application/json" + Accept: "application/json" + validate_certs: no + register: _test_global_platform_connection_result + failed_when: false + + - when: _test_global_platform_connection_result.status != 200 + block: + - debug: + msg: "{{ _test_global_platform_connection_result }}" + + - fail: + msg: "Test connection to Global Platform connection {{ _cp4d_platform_connection_name }} failed. Unable to provision Cognos instance. \ + Validate the Global Platform connection properties, or delete the global platform connection so the Deployer will re-create it. \ + \n Returned Error Message: \n\n {{ _test_global_platform_connection_result.content }}" + + - name: Obtain Cognos Analytics version + shell: + oc get caservice -n {{ current_cp4d_cluster.project }} ca-addon-cr -o jsonpath='{.spec.version}' + register: _ca_version + + - set_fact: + _cognos_instance_pods_count: "7" + + - name: Create cognos instance 4.0 json file + template: + src: cognos_instance_40.json.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_instance.json" + when: _ca_cp4d_version == "4.0" + + - when: _ca_cp4d_version != "4.0" + block: + + - name: Get current secrets + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v2/secrets' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _cp4d_secret_get_result + + - set_fact: + _cp4d_secret_query: "{{ _cp4d_secret_get_result.json.secrets | json_query(secret_smtp) }}" + vars: + secret_smtp_name: "smtpSecret" + secret_smtp: "[?secret_name=='{{ secret_smtp_name }}']" + + - when: _cp4d_secret_query | length == 1 + set_fact: + _cp4d_cognos_smtp_secret: "{{ _cp4d_secret_query[0].secret_urn }}" + + - when: _cp4d_secret_query | length == 0 + block: + - name: Create Cognos smtp secret json + template: + src: cognos_smtp_secret.json.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_smtp_secret.json" + + - name: Create Cognos smtp secret + shell: | + curl -v -k \ + -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ + -H 'Content-Type: application/json' \ + -X POST 'https://{{ cp4d_url.stdout }}/zen-data/v2/secrets' \ + -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_smtp_secret.json + register: _cp4d_cognos_smtp_secret_create_result + + - set_fact: + _cp4d_cognos_smtp_secret_result: "{{ _cp4d_cognos_smtp_secret_create_result.stdout | from_json }}" + + - set_fact: + _cp4d_cognos_smtp_secret: "{{ _cp4d_cognos_smtp_secret_result.secret_urn }}" + + - debug: + msg: "Cognos SMTP Secret: {{ _cp4d_cognos_smtp_secret }}" + + - name: Create cognos instance 4.5 json file + template: + src: "cognos_instance_45_{{ _cp4d_cognos_instance_tshirt_size | lower }}.json.j2" + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_instance.json" + + - set_fact: + _cognos_instance_pods_count: "5" + + - name: Create Cognos instance shell: | - oc get po \ - -n {{ current_cp4d_cluster.project }} \ - -l app.kubernetes.io/component=ca-artifacts \ - --no-headers \ - -o=jsonpath='{.items[?(.status.containerStatuses[0].ready==true)].metadata.name}' - register: _ca_artifacts_pod - retries: 60 - delay: 10 - until: - - _ca_artifacts_pod.rc==0 - - _ca_artifacts_pod.stdout!='' - - - name: Wait for a bit so that all Cognos Analytics containers are starting - pause: - seconds: 90 - - - name: Destroy the artifacts pod so Cognos Analytics instance provisioning continues + curl -v -k \ + -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ + -H 'Content-Type: application/json' \ + -X POST \ + 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ + -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _cognos_instance.name }}-cognos_instance.json + register: _cognos_instance_create_result + + - set_fact: + _cognos_instance_create_result_json: "{{ _cognos_instance_create_result.stdout | from_json }}" + + - when: _ca_cp4d_version == "4.0" + block: + - name: Wait until Cognos Analytics artifacts pod has started and is ready + shell: | + oc get po \ + -n {{ current_cp4d_cluster.project }} \ + -l app.kubernetes.io/component=ca-artifacts \ + --no-headers \ + -o=jsonpath='{.items[?(.status.containerStatuses[0].ready==true)].metadata.name}' + register: _ca_artifacts_pod + retries: 60 + delay: 10 + until: + - _ca_artifacts_pod.rc==0 + - _ca_artifacts_pod.stdout!='' + + - name: Wait for a bit so that all Cognos Analytics containers are starting + pause: + seconds: 90 + + - name: Destroy the artifacts pod so Cognos Analytics instance provisioning continues + shell: | + oc delete pod \ + -n {{ current_cp4d_cluster.project }} \ + {{ _ca_artifacts_pod.stdout }} + + - name: Cognos Analytics instance being provisioned + debug: + msg: "Cognos Analytics instance being provisioned. ID: {{ _cognos_instance_create_result_json.id }}. Provisioning can take up to 70 minutes to complete" + + - name: Label DB2 STS when using internal metastore shell: | - oc delete pod \ + oc label sts \ -n {{ current_cp4d_cluster.project }} \ - {{ _ca_artifacts_pod.stdout }} - - - name: Cognos Analytics instance being provisioned - debug: - msg: "Cognos Analytics instance being provisioned. ID: {{ _cognos_instance_create_result_json.id }}. Provisioning can take up to 70 minutes to complete" - - - name: Label DB2 STS when using internal metastore - shell: | - oc label sts \ - -n {{ current_cp4d_cluster.project }} \ - c-db2oltp-{{ _internal_db2_instance_id }}-db2u cognos_instance_id={{ _cognos_instance_create_result_json.id }} \ - --overwrite - when: not _internal_db2_instance_id == "" + c-db2oltp-{{ _internal_db2_instance_id }}-db2u cognos_instance_id={{ _cognos_instance_create_result_json.id }} \ + --overwrite + when: not _internal_db2_instance_id == "" + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/delete-cpd-edb-instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/delete-cpd-edb-instances.yml index 2d6b0334f..450c805ca 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/delete-cpd-edb-instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/delete-cpd-edb-instances.yml @@ -10,6 +10,7 @@ validate_certs: no status_code: 200 register: _all_cpd_edb_instances + when: not cpd_dry_run - name: Loop through each EnterpriseDB instance for delete include_tasks: delete-cpd-edb-instance.yml diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/main.yml index 1b5232665..7f936b4cb 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/main.yml @@ -26,7 +26,9 @@ when: - (_p_wait_instances | default(False)) == False -- include_tasks: wait-cpd-edb-instances.yml - when: - - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file +- block: + - include_tasks: wait-cpd-edb-instances.yml + when: + - (_p_delete_all_instances | default(False)) == False + - _p_wait_instances | default(False) + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/provision-cpd-edb-instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/provision-cpd-edb-instance.yml index c71adfd5c..b9c3631cb 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/provision-cpd-edb-instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-cpd-edb/tasks/provision-cpd-edb-instance.yml @@ -3,34 +3,42 @@ debug: var: _cpd_edb_instance -- set_fact: - _cpd_edb_instance_name: "{{ _cpd_edb_instance.name }}" - _cpd_edb_instance_namespace: "{{ current_cp4d_cluster.project }}" - _cpd_edb_instance_type: "{{ _cpd_edb_instance.type | default ('Standard') }}" - _cpd_edb_instance_version: "{{ _cpd_edb_instance.version }}" - _cpd_edb_instance_members: "{{ _cpd_edb_instance.members | default('1') }}" - _cpd_edb_instance_storage_class: "{{ _cpd_edb_instance.storage_class | default(ocp_storage_class_file) }}" - _cpd_edb_instance_storage_size_gb: "{{ _cpd_edb_instance.size_gb | default ('50') }}" - _cpd_edb_instance_resource_request_cpu: "{{ _cpd_edb_instance.resource_request_cpu | default ('1000m') }}" - _cpd_edb_instance_resource_request_memory: "{{ _cpd_edb_instance.resource_request_memory | default ('4Gi') }}" - _cpd_edb_instance_resource_limit_cpu: "{{ _cpd_edb_instance.resource_limit_cpu | default ('1000m') }}" - _cpd_edb_instance_resource_limit_memory: "{{ _cpd_edb_instance.resource_limit_memory | default ('4Gi') }}" +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision EDB instance {{ _cpd_edb_instance.name }}" + _p_activity_comment: "Create EDB instance {{ _cpd_edb_instance.name }} using CPDEdbInstance CR" -- name: "Validate if CPD EDB instance is already present" - shell: oc get CPDEdbInstance -n {{ _cpd_edb_instance_namespace }} --no-headers | grep "^{{ _cpd_edb_instance_name }}[[:space:]]" | wc -l - register: _cpd_edb_instance_lookup_result +- block: + - set_fact: + _cpd_edb_instance_name: "{{ _cpd_edb_instance.name }}" + _cpd_edb_instance_namespace: "{{ current_cp4d_cluster.project }}" + _cpd_edb_instance_type: "{{ _cpd_edb_instance.type | default ('Standard') }}" + _cpd_edb_instance_version: "{{ _cpd_edb_instance.version }}" + _cpd_edb_instance_members: "{{ _cpd_edb_instance.members | default('1') }}" + _cpd_edb_instance_storage_class: "{{ _cpd_edb_instance.storage_class | default(ocp_storage_class_file) }}" + _cpd_edb_instance_storage_size_gb: "{{ _cpd_edb_instance.size_gb | default ('50') }}" + _cpd_edb_instance_resource_request_cpu: "{{ _cpd_edb_instance.resource_request_cpu | default ('1000m') }}" + _cpd_edb_instance_resource_request_memory: "{{ _cpd_edb_instance.resource_request_memory | default ('4Gi') }}" + _cpd_edb_instance_resource_limit_cpu: "{{ _cpd_edb_instance.resource_limit_cpu | default ('1000m') }}" + _cpd_edb_instance_resource_limit_memory: "{{ _cpd_edb_instance.resource_limit_memory | default ('4Gi') }}" -- when: not _cpd_edb_instance_lookup_result.stdout == "0" - debug: - msg: "CPD EDB instance {{ _cpd_edb_instance_name }} already available. Skipping provision..." + - name: "Validate if CPD EDB instance is already present" + shell: oc get CPDEdbInstance -n {{ _cpd_edb_instance_namespace }} --no-headers | grep "^{{ _cpd_edb_instance_name }}[[:space:]]" | wc -l + register: _cpd_edb_instance_lookup_result + + - when: not _cpd_edb_instance_lookup_result.stdout == "0" + debug: + msg: "CPD EDB instance {{ _cpd_edb_instance_name }} already available. Skipping provision..." -- when: _cpd_edb_instance_lookup_result.stdout == "0" - block: - - name: Create CPD EDB Instance CRD yaml file - template: - src: cpd-edb-instance.j2 - dest: "{{ status_dir }}/cp4d/cpd-edb-instance-cr.yaml" + - when: _cpd_edb_instance_lookup_result.stdout == "0" + block: + - name: Create CPD EDB Instance CRD yaml file + template: + src: cpd-edb-instance.j2 + dest: "{{ status_dir }}/cp4d/cpd-edb-instance-cr.yaml" - - name: Provision CPDEdbInstance {{ _cpd_edb_instance_name }} - shell: | - oc create -f {{ status_dir }}/cp4d/cpd-edb-instance-cr.yaml \ No newline at end of file + - name: Provision CPDEdbInstance {{ _cpd_edb_instance_name }} + shell: | + oc create -f {{ status_dir }}/cp4d/cpd-edb-instance-cr.yaml + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/delete_datastage_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/delete_datastage_instances.yml index 77bb7d719..dfc429f8a 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/delete_datastage_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/delete_datastage_instances.yml @@ -1,14 +1,16 @@ --- -- set_fact: - _all_ds_instances: [] -- name: Get all current DataStage instances - shell: | - oc get pxruntime -n {{ current_cp4d_cluster.project }} -o json - failed_when: False - register: _all_ds_instances_output -- set_fact: - _all_ds_instances: "{{ (_all_ds_instances_output.stdout | from_json)['items'] }}" - when: _all_ds_instances_output.rc == 0 +- block: + - set_fact: + _all_ds_instances: [] + - name: Get all current DataStage instances + shell: | + oc get pxruntime -n {{ current_cp4d_cluster.project }} -o json + failed_when: False + register: _all_ds_instances_output + - set_fact: + _all_ds_instances: "{{ (_all_ds_instances_output.stdout | from_json)['items'] }}" + when: _all_ds_instances_output.rc == 0 + when: not cpd_dry_run # Loop through all deployed DataStage instance definitions to check if instance no longer exists in the config - name: Loop through each DataStage instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/main.yml index 59766f841..caf2fe7cd 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/main.yml @@ -44,4 +44,5 @@ - include_tasks: wait_datastage_instances.yml when: - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/provision_datastage_instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/provision_datastage_instance.yml index 770907cc6..5459c6a45 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/provision_datastage_instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-datastage/tasks/provision_datastage_instance.yml @@ -3,122 +3,130 @@ debug: msg: "{{ _ds_instance }}" -- name: Check if the DataStage instance {{ _ds_instance.name }} is already running - shell: | - oc get pxruntime {{ _ds_instance.name }} -n {{ current_cp4d_cluster.project }} --no-headers | wc -l - failed_when: False - register: _ds_instance_lookup_result - -- name: Determine if DataStage instance already exists - debug: - msg: "DataStage instance {{ _ds_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, will be skipped" - when: (_ds_instance_lookup_result.stdout | int) != 0 - -- when: (_ds_instance_lookup_result.stdout | int) == 0 - block: - - - name: Generate DataStage runtime ID - shell: date +%s%N | cut -b1-13 - register: _ds_instance_id_output - - - set_fact: - _ds_instance_name: "{{ _ds_instance.name }}" - _ds_instance_description: "{{ _ds_instance.description | default('') }}" - _ds_instance_namespace: "{{ current_cp4d_cluster.project }}" - _ds_instance_size: "{{ _ds_instance.size | default('small') | lower }}" - _ds_instance_storage_class: "{{ _ds_instance.storage_class | default(ocp_storage_class_file) }}" - _ds_instance_storage_size_gb: "{{ _ds_instance.storage_size_gb | default('50') }}" - _ds_instance_id: "{{ _ds_instance_id_output.stdout }}" - _ds_instance_scale_px_compute: "{{ _ds_instance.scale_px_compute | default(omit) }}" - _ds_px_compute_replicas: "{{ _ds_instance.scale_px_compute.replicas | default(omit) }}" - _ds_px_compute_limit_cpu: "{{ _ds_instance.scale_px_compute.cpu_limit | default(omit) }}" - _ds_px_compute_limit_memory: "{{ _ds_instance.scale_px_compute.memory_limit | default(omit) }}" - _ds_px_compute_request_cpu: "{{ _ds_instance.scale_px_compute.cpu_request | default(omit) }}" - _ds_px_compute_request_memory: "{{ _ds_instance.scale_px_compute.memory_request | default(omit) }}" - _ds_instance_scale_px_runtime: "{{ _ds_instance.scale_px_runtime | default(omit) }}" - _ds_px_runtime_replicas: "{{ _ds_instance.scale_px_runtime.replicas | default(omit) }}" - _ds_px_runtime_limit_cpu: "{{ _ds_instance.scale_px_runtime.cpu_limit | default(omit) }}" - _ds_px_runtime_limit_memory: "{{ _ds_instance.scale_px_runtime.memory_limit | default(omit) }}" - _ds_px_runtime_request_cpu: "{{ _ds_instance.scale_px_runtime.cpu_request | default(omit) }}" - _ds_px_runtime_request_memory: "{{ _ds_instance.scale_px_runtime.memory_request | default(omit) }}" - - - name: If custom PX Compute scale is defined, confirm PX Runtime is defined as well - assert: - that: _ds_instance_scale_px_runtime is defined - fail_msg: "Custom scale properties 'scale_px_compute' found, but missing 'scale_px_runtime'. When using custom scaling options \ - both must be specified." - when: _ds_instance_scale_px_compute is defined - - - name: If custom PX Runtime scale is defined, confirm PX Compute is defined as well - assert: - that: _ds_instance_scale_px_compute is defined - fail_msg: "Custom scale properties 'scale_px_runtime' found, but missing 'scale_px_compute'. When using custom scaling options \ - both must be specified." - when: _ds_instance_scale_px_runtime is defined - - - name: If custom PX Compute scale parameters are defined, confirm all parameters are populated - assert: - that: - - _ds_px_compute_replicas is defined - - _ds_px_compute_limit_cpu is defined - - _ds_px_compute_limit_memory is defined - - _ds_px_compute_request_cpu is defined - - _ds_px_compute_request_memory is defined - fail_msg: "PxRuntime {{ _ds_instance_name }} has missing options for `scale_px_compute`. Ensure the properties replicas, \ - cpu_limit, memory_limit, cpu_request and memory_request are defined" - when: _ds_instance_scale_px_compute is defined - - - name: If custom PX Runtime scale parameters are defined, confirm all parameters are populated - assert: - that: - - _ds_px_runtime_replicas is defined - - _ds_px_runtime_limit_cpu is defined - - _ds_px_runtime_limit_memory is defined - - _ds_px_runtime_request_cpu is defined - - _ds_px_runtime_request_memory is defined - fail_msg: "PxRuntime {{ _ds_instance_name }} has missing `scale_px_runtime` options. Ensure the properties replicas \ - cpu_limit, memory_limit, cpu_request memory_request are defined" - when: _ds_instance_scale_px_runtime is defined - - - fail: - msg: "DataStage instance {{ _ds_instance_name }} has invalid value \"{{ _ds_instance_size }}\" for size property. Only {{ cp4d_datastage_size_options }} are supported." - when: _ds_instance_size not in cp4d_datastage_size_options - - - name: "Validate Storage Class {{ _ds_instance_storage_class }}" - shell: | - oc get sc | grep "^{{ _ds_instance_storage_class }}[[:space:]]" | wc -l - register: _current_ds_instance_storage_class - - - fail: - msg: "Storage Class {{ _ds_instance_storage_class }} configured in DataStage instance {{ _ds_instance_name }} is not available in OCP cluster." - when: _current_ds_instance_storage_class.stdout == "0" - - - name: Get the current CP4D user owner_id - uri: - url: 'https://{{ cp4d_url.stdout }}/icp4d-api/v1/me' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _cp4d_user_details - - - set_fact: - _cp4d_user_owner_id: "{{ _cp4d_user_details.json.UserInfo.uid }}" - - - name: Obtain DataStage version - shell: - oc get datastage -n {{ current_cp4d_cluster.project }} datastage -o jsonpath='{.spec.version}' - register: _cp4d_ds_version - - - name: Create DataStage PXRuntime CRD yaml file - template: - src: ds_instance.yaml.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-datastage-instance-{{ _ds_instance_name }}-cr.yaml" - - - name: Provision PxRunTime {{ _ds_instance_name }} +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision DataStage instance {{ _ds_instance.name }}" + _p_activity_comment: "Create DataStage instance {{ _ds_instance.name }} using datastage CR" + +- block: + - name: Check if the DataStage instance {{ _ds_instance.name }} is already running shell: | - oc create -f {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-datastage-instance-{{ _ds_instance_name }}-cr.yaml - register: _oc_create_ds \ No newline at end of file + oc get pxruntime {{ _ds_instance.name }} -n {{ current_cp4d_cluster.project }} --no-headers | wc -l + failed_when: False + register: _ds_instance_lookup_result + + - name: Determine if DataStage instance already exists + debug: + msg: "DataStage instance {{ _ds_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, will be skipped" + when: (_ds_instance_lookup_result.stdout | int) != 0 + + - when: (_ds_instance_lookup_result.stdout | int) == 0 + block: + + - name: Generate DataStage runtime ID + shell: date +%s%N | cut -b1-13 + register: _ds_instance_id_output + + - set_fact: + _ds_instance_name: "{{ _ds_instance.name }}" + _ds_instance_description: "{{ _ds_instance.description | default('') }}" + _ds_instance_namespace: "{{ current_cp4d_cluster.project }}" + _ds_instance_size: "{{ _ds_instance.size | default('small') | lower }}" + _ds_instance_storage_class: "{{ _ds_instance.storage_class | default(ocp_storage_class_file) }}" + _ds_instance_storage_size_gb: "{{ _ds_instance.storage_size_gb | default('50') }}" + _ds_instance_id: "{{ _ds_instance_id_output.stdout }}" + _ds_instance_scale_px_compute: "{{ _ds_instance.scale_px_compute | default(omit) }}" + _ds_px_compute_replicas: "{{ _ds_instance.scale_px_compute.replicas | default(omit) }}" + _ds_px_compute_limit_cpu: "{{ _ds_instance.scale_px_compute.cpu_limit | default(omit) }}" + _ds_px_compute_limit_memory: "{{ _ds_instance.scale_px_compute.memory_limit | default(omit) }}" + _ds_px_compute_request_cpu: "{{ _ds_instance.scale_px_compute.cpu_request | default(omit) }}" + _ds_px_compute_request_memory: "{{ _ds_instance.scale_px_compute.memory_request | default(omit) }}" + _ds_instance_scale_px_runtime: "{{ _ds_instance.scale_px_runtime | default(omit) }}" + _ds_px_runtime_replicas: "{{ _ds_instance.scale_px_runtime.replicas | default(omit) }}" + _ds_px_runtime_limit_cpu: "{{ _ds_instance.scale_px_runtime.cpu_limit | default(omit) }}" + _ds_px_runtime_limit_memory: "{{ _ds_instance.scale_px_runtime.memory_limit | default(omit) }}" + _ds_px_runtime_request_cpu: "{{ _ds_instance.scale_px_runtime.cpu_request | default(omit) }}" + _ds_px_runtime_request_memory: "{{ _ds_instance.scale_px_runtime.memory_request | default(omit) }}" + + - name: If custom PX Compute scale is defined, confirm PX Runtime is defined as well + assert: + that: _ds_instance_scale_px_runtime is defined + fail_msg: "Custom scale properties 'scale_px_compute' found, but missing 'scale_px_runtime'. When using custom scaling options \ + both must be specified." + when: _ds_instance_scale_px_compute is defined + + - name: If custom PX Runtime scale is defined, confirm PX Compute is defined as well + assert: + that: _ds_instance_scale_px_compute is defined + fail_msg: "Custom scale properties 'scale_px_runtime' found, but missing 'scale_px_compute'. When using custom scaling options \ + both must be specified." + when: _ds_instance_scale_px_runtime is defined + + - name: If custom PX Compute scale parameters are defined, confirm all parameters are populated + assert: + that: + - _ds_px_compute_replicas is defined + - _ds_px_compute_limit_cpu is defined + - _ds_px_compute_limit_memory is defined + - _ds_px_compute_request_cpu is defined + - _ds_px_compute_request_memory is defined + fail_msg: "PxRuntime {{ _ds_instance_name }} has missing options for `scale_px_compute`. Ensure the properties replicas, \ + cpu_limit, memory_limit, cpu_request and memory_request are defined" + when: _ds_instance_scale_px_compute is defined + + - name: If custom PX Runtime scale parameters are defined, confirm all parameters are populated + assert: + that: + - _ds_px_runtime_replicas is defined + - _ds_px_runtime_limit_cpu is defined + - _ds_px_runtime_limit_memory is defined + - _ds_px_runtime_request_cpu is defined + - _ds_px_runtime_request_memory is defined + fail_msg: "PxRuntime {{ _ds_instance_name }} has missing `scale_px_runtime` options. Ensure the properties replicas \ + cpu_limit, memory_limit, cpu_request memory_request are defined" + when: _ds_instance_scale_px_runtime is defined + + - fail: + msg: "DataStage instance {{ _ds_instance_name }} has invalid value \"{{ _ds_instance_size }}\" for size property. Only {{ cp4d_datastage_size_options }} are supported." + when: _ds_instance_size not in cp4d_datastage_size_options + + - name: "Validate Storage Class {{ _ds_instance_storage_class }}" + shell: | + oc get sc | grep "^{{ _ds_instance_storage_class }}[[:space:]]" | wc -l + register: _current_ds_instance_storage_class + + - fail: + msg: "Storage Class {{ _ds_instance_storage_class }} configured in DataStage instance {{ _ds_instance_name }} is not available in OCP cluster." + when: _current_ds_instance_storage_class.stdout == "0" + + - name: Get the current CP4D user owner_id + uri: + url: 'https://{{ cp4d_url.stdout }}/icp4d-api/v1/me' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _cp4d_user_details + + - set_fact: + _cp4d_user_owner_id: "{{ _cp4d_user_details.json.UserInfo.uid }}" + + - name: Obtain DataStage version + shell: + oc get datastage -n {{ current_cp4d_cluster.project }} datastage -o jsonpath='{.spec.version}' + register: _cp4d_ds_version + + - name: Create DataStage PXRuntime CRD yaml file + template: + src: ds_instance.yaml.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-datastage-instance-{{ _ds_instance_name }}-cr.yaml" + + - name: Provision PxRunTime {{ _ds_instance_name }} + shell: | + oc create -f {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-datastage-instance-{{ _ds_instance_name }}-cr.yaml + register: _oc_create_ds + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/delete_db2_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/delete_db2_instances.yml index 6f54b7b25..49fb5a070 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/delete_db2_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/delete_db2_instances.yml @@ -10,6 +10,7 @@ validate_certs: no status_code: 200 register: _all_db2_instances + when: not cpd_dry_run # Loop through all deployed Db2 OLTP instance definitions to check if instance no longer exists in the config - name: Loop through each Db2 OLTP instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/main.yml index 6c5e76292..e90898741 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/main.yml @@ -29,4 +29,5 @@ - include_tasks: wait_db2_instances.yml when: - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/provision_db2_instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/provision_db2_instance.yml index fd5673843..1c476a294 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/provision_db2_instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-db2oltp/tasks/provision_db2_instance.yml @@ -3,35 +3,16 @@ debug: var: _db2_instance -- name: Check if the Db2 OLTP instance is already running - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_db2oltp_instance_addon_type }}&display_name={{ _db2_instance.name }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _db2_instance_lookup_result +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision Db2 instance {{ _db2_instance.name }}" + _p_activity_comment: "Use REST API to provision Db2 instance {{ _db2_instance.name }}" -- name: Determine if Db2 OLTP instance already exists - debug: - msg: "Db2 OLTP instance {{ _db2_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, skipping provisioning" - when: _db2_instance_lookup_result.json.total_count != 0 - -# If instance doesn't exist yet, create it -- when: _db2_instance_lookup_result.json.total_count == 0 - block: - - name: Set the required privileges for Db2 OLTP instance creation for OpenShift Project {{ current_cp4d_cluster.project }} - shell: | - oc adm policy \ - add-cluster-role-to-user system:controller:persistent-volume-binder \ - system:serviceaccount:{{ current_cp4d_cluster.project }}:zen-databases-sa - - - name: Get CP4D Database specifications +- block: + - name: Check if the Db2 OLTP instance is already running uri: - url: 'https://{{ cp4d_url.stdout }}/icp4data/api/v1/databases' + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_db2oltp_instance_addon_type }}&display_name={{ _db2_instance.name }}' method: GET headers: Content-Type: application/json @@ -39,68 +20,95 @@ return_content: yes validate_certs: no status_code: 200 - register: _databases_details_result_v1 - until: _databases_details_result_v1.status == 200 - retries: 12 - delay: 5 - when: current_cp4d_cluster.cp4d_version < '4.7.0' + register: _db2_instance_lookup_result - - name: Get CP4D Database specifications - uri: - url: 'https://{{ cp4d_url.stdout }}/icp4data/api/v1/databases/' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _databases_details_result_v2 - until: _databases_details_result_v2.status == 200 - retries: 12 - delay: 5 - when: current_cp4d_cluster.cp4d_version >= '4.7.0' + - name: Determine if Db2 OLTP instance already exists + debug: + msg: "Db2 OLTP instance {{ _db2_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, skipping provisioning" + when: _db2_instance_lookup_result.json.total_count != 0 - - set_fact: - _databases_details_result: "{{ _databases_details_result_v2 }}" - when: current_cp4d_cluster.cp4d_version >= '4.7.0' + # If instance doesn't exist yet, create it + - when: _db2_instance_lookup_result.json.total_count == 0 + block: + - name: Set the required privileges for Db2 OLTP instance creation for OpenShift Project {{ current_cp4d_cluster.project }} + shell: | + oc adm policy \ + add-cluster-role-to-user system:controller:persistent-volume-binder \ + system:serviceaccount:{{ current_cp4d_cluster.project }}:zen-databases-sa - - debug: - var: _databases_details_result + - name: Get CP4D Database specifications + uri: + url: 'https://{{ cp4d_url.stdout }}/icp4data/api/v1/databases' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _databases_details_result_v1 + until: _databases_details_result_v1.status == 200 + retries: 12 + delay: 5 + when: current_cp4d_cluster.cp4d_version < '4.7.0' - - set_fact: - _db2_cartridge_details: "{{ _databases_details_result.json.result | json_query(query_db2_details) }}" - vars: - cartridge_type: "db2oltp" - query_db2_details: "[?type=='{{ cartridge_type }}']" + - name: Get CP4D Database specifications + uri: + url: 'https://{{ cp4d_url.stdout }}/icp4data/api/v1/databases/' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _databases_details_result_v2 + until: _databases_details_result_v2.status == 200 + retries: 12 + delay: 5 + when: current_cp4d_cluster.cp4d_version >= '4.7.0' - - name: Show Db2 OLTP cartridge details - debug: - msg: "{{ _db2_cartridge_details }}" + - set_fact: + _databases_details_result: "{{ _databases_details_result_v2 }}" + when: current_cp4d_cluster.cp4d_version >= '4.7.0' - - set_fact: - _db2_version: "{{ (_db2_cartridge_details | first).version }}" - _db2_repositories: " {{ (_db2_cartridge_details | first).create.repositories | regex_replace(\"'\", '\"') }}" - _db2_chart: "{{ (_db2_cartridge_details | first).chart }}" + - debug: + var: _databases_details_result - - name: Prepare Db2 OLTP instance {{ _db2_instance.name }} json file - template: - src: db2_instance_40.json.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2_instance_40.json" + - set_fact: + _db2_cartridge_details: "{{ _databases_details_result.json.result | json_query(query_db2_details) }}" + vars: + cartridge_type: "db2oltp" + query_db2_details: "[?type=='{{ cartridge_type }}']" - - name: Create Db2 OLTP instance {{ _db2_instance.name }} - shell: | - curl -v -k \ - -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ - -H 'Content-Type: application/json' \ - -X POST \ - 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ - -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2_instance_40.json - register: _create_db2_instance_result + - name: Show Db2 OLTP cartridge details + debug: + msg: "{{ _db2_cartridge_details }}" - - set_fact: - _db2_instance_id: "{{ (_create_db2_instance_result.stdout | from_json).id }}" + - set_fact: + _db2_version: "{{ (_db2_cartridge_details | first).version }}" + _db2_repositories: " {{ (_db2_cartridge_details | first).create.repositories | regex_replace(\"'\", '\"') }}" + _db2_chart: "{{ (_db2_cartridge_details | first).chart }}" - - name: Show results of Db2 OLTP instance creation - debug: - msg: "{{ _create_db2_instance_result }}" \ No newline at end of file + - name: Prepare Db2 OLTP instance {{ _db2_instance.name }} json file + template: + src: db2_instance_40.json.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2_instance_40.json" + + - name: Create Db2 OLTP instance {{ _db2_instance.name }} + shell: | + curl -v -k \ + -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ + -H 'Content-Type: application/json' \ + -X POST \ + 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ + -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2_instance_40.json + register: _create_db2_instance_result + + - set_fact: + _db2_instance_id: "{{ (_create_db2_instance_result.stdout | from_json).id }}" + + - name: Show results of Db2 OLTP instance creation + debug: + msg: "{{ _create_db2_instance_result }}" + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/delete_dmc_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/delete_dmc_instances.yml index 02845aafb..71a476072 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/delete_dmc_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/delete_dmc_instances.yml @@ -10,6 +10,7 @@ validate_certs: no status_code: 200 register: _all_dmc_instances + when: not cpd_dry_run # Loop through all deployed Data Management Console instance definitions to check if instance no longer exists in the config - name: Loop through each Data Management Console instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/main.yml index c9e319e45..e6f63c291 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/main.yml @@ -40,4 +40,5 @@ - include_tasks: wait_dmc_instances.yml when: - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/provision_dmc_instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/provision_dmc_instance.yml index 3cd01a12d..c4b79be2b 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/provision_dmc_instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dmc/tasks/provision_dmc_instance.yml @@ -3,47 +3,55 @@ debug: msg: "{{ _dmc_instance }}" -- name: Check if the Data Management Console instance is already running - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_dmc_addon_type }}&display_name={{ _dmc_instance.name }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _dmc_instance_lookup_result - -- name: Determine if Data Management Console instance already exists - debug: - msg: "Data Management Console instance {{ _dmc_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, will be skipped" - when: _dmc_instance_lookup_result.json.total_count != 0 - -- when: _dmc_instance_lookup_result.json.total_count == 0 - block: - - name: Obtain Data Management Console version - shell: | - oc get dmcaddon -n {{ current_cp4d_cluster.project }} dmc-addon -o jsonpath='{.spec.version}' - register: _dmc_version - - - name: Create Data Management Console configuration file - template: - src: dmc-instance.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _dmc_instance.name }}-dmc-instance.json" - - - name: Create Data Management Console instance - shell: | - curl -v -k \ - -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ - -H 'Content-Type: application/json' \ - -X POST 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ - -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _dmc_instance.name }}-dmc-instance.json - register: _provision_dmc_result - - - name: Show Data Management Console instance provisioning result +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision DMC instance {{ _dmc_instance.name }}" + _p_activity_comment: "Create DMC instance {{ _dmc_instance.name }} using REST API" + +- block: + - name: Check if the Data Management Console instance is already running + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_dmc_addon_type }}&display_name={{ _dmc_instance.name }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _dmc_instance_lookup_result + + - name: Determine if Data Management Console instance already exists debug: - msg: "{{ _provision_dmc_result }}" + msg: "Data Management Console instance {{ _dmc_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, will be skipped" + when: _dmc_instance_lookup_result.json.total_count != 0 + + - when: _dmc_instance_lookup_result.json.total_count == 0 + block: + - name: Obtain Data Management Console version + shell: | + oc get dmcaddon -n {{ current_cp4d_cluster.project }} dmc-addon -o jsonpath='{.spec.version}' + register: _dmc_version + + - name: Create Data Management Console configuration file + template: + src: dmc-instance.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _dmc_instance.name }}-dmc-instance.json" + + - name: Create Data Management Console instance + shell: | + curl -v -k \ + -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ + -H 'Content-Type: application/json' \ + -X POST 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ + -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _dmc_instance.name }}-dmc-instance.json + register: _provision_dmc_result + + - name: Show Data Management Console instance provisioning result + debug: + msg: "{{ _provision_dmc_result }}" - - set_fact: - _provision_dmc_result_json: "{{ _provision_dmc_result.stdout | from_json }}" \ No newline at end of file + - set_fact: + _provision_dmc_result_json: "{{ _provision_dmc_result.stdout | from_json }}" + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/delete_dv_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/delete_dv_instances.yml index fe08d23fc..d3a814a13 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/delete_dv_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/delete_dv_instances.yml @@ -10,6 +10,7 @@ validate_certs: no status_code: 200 register: _all_dv_instances + when: not cpd_dry_run # Loop through all deployed Data Virtualization instance definitions to check if instance no longer exists in the config - name: Loop through each Data Virtualization instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/main.yml index 67c1e5db7..f51e507b2 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/main.yml @@ -29,4 +29,5 @@ - include_tasks: wait_dv_instances.yml when: - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/provision_dv_instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/provision_dv_instance.yml index a37d1a6e9..b101528c8 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/provision_dv_instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-dv/tasks/provision_dv_instance.yml @@ -3,47 +3,55 @@ debug: msg: "{{ _dv_instance }}" -- name: Check if the Data Virtualization instance is already running - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_dv_addon_type }}&display_name={{ _dv_instance.name }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _dv_instance_lookup_result - -- name: Determine if Data Virtualization instance already exists - debug: - msg: "Data Virtualization instance {{ _dv_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, will be skipped" - when: _dv_instance_lookup_result.json.total_count != 0 - -- when: _dv_instance_lookup_result.json.total_count == 0 - block: - - name: Obtain Data Virtualization version - shell: | - oc get dvservice -n {{ current_cp4d_cluster.project }} dv-service -o jsonpath='{.spec.version}' - register: _dv_version - - - name: Create Data Virtualization configuration file - template: - src: dv_instance_40.json.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _dv_instance.name }}-dv_instance.json" - - - name: Create Data Virtualization instance - shell: | - curl -v -k \ - -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ - -H 'Content-Type: application/json' \ - -X POST 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ - -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _dv_instance.name }}-dv_instance.json - register: _provision_dv_result - - - name: Show Data Virtualization instance provisioning result +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision Data Virtualization instance {{ _dv_instance.name }}" + _p_activity_comment: "Use REST API to provision DV instance {{ _dv_instance.name }}" + +- block: + - name: Check if the Data Virtualization instance is already running + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_dv_addon_type }}&display_name={{ _dv_instance.name }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _dv_instance_lookup_result + + - name: Determine if Data Virtualization instance already exists debug: - msg: "{{ _provision_dv_result }}" + msg: "Data Virtualization instance {{ _dv_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, will be skipped" + when: _dv_instance_lookup_result.json.total_count != 0 + + - when: _dv_instance_lookup_result.json.total_count == 0 + block: + - name: Obtain Data Virtualization version + shell: | + oc get dvservice -n {{ current_cp4d_cluster.project }} dv-service -o jsonpath='{.spec.version}' + register: _dv_version + + - name: Create Data Virtualization configuration file + template: + src: dv_instance_40.json.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _dv_instance.name }}-dv_instance.json" + + - name: Create Data Virtualization instance + shell: | + curl -v -k \ + -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ + -H 'Content-Type: application/json' \ + -X POST 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ + -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _dv_instance.name }}-dv_instance.json + register: _provision_dv_result + + - name: Show Data Virtualization instance provisioning result + debug: + msg: "{{ _provision_dv_result }}" - - set_fact: - _provision_dv_result_json: "{{ _provision_dv_result.stdout | from_json }}" \ No newline at end of file + - set_fact: + _provision_dv_result_json: "{{ _provision_dv_result.stdout | from_json }}" + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/delete_openpages_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/delete_openpages_instances.yml index 7d429c588..16f168df6 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/delete_openpages_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/delete_openpages_instances.yml @@ -10,6 +10,7 @@ validate_certs: no status_code: 200 register: _all_openpages_instances + when: not cpd_dry_run # Loop through all deployed OpenPages instance definitions to check if instance no longer exists in the config - name: Loop through each OpenPages instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/main.yml index 59427e949..22fcab8ae 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/main.yml @@ -39,4 +39,5 @@ - include_tasks: wait_openpages_instances.yml when: - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/provision_openpages_instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/provision_openpages_instance.yml index 429439e09..6cb1181dc 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/provision_openpages_instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-openpages/tasks/provision_openpages_instance.yml @@ -12,37 +12,45 @@ msg: "OpenPages instance {{ _openpages_instance_name }} has invalid value \"{{ _openpages_instance_size }}\" for size property. Only {{ cp4d_openpages_instance_size_options }} are supported." when: _openpages_instance_size not in cp4d_openpages_instance_size_options -- name: "Validate if instance {{ _openpages_instance_name }} already exists" - shell: | - oc get OpenPagesInstance --no-headers \ - -n {{ current_cp4d_cluster.project }} | grep "^{{ _openpages_instance_name }}[[:space:]]" | wc -l - register: _current_openpages_instance - -- when: not _current_openpages_instance.stdout == "0" - debug: - msg: "OpenPages instance {{ _openpages_instance_name }} already created. Skipping provision..." - -- when: _current_openpages_instance.stdout == "0" - block: - - - name: Get current OpenPages version - shell: | - oc get OpenPagesService -n {{ current_cp4d_cluster.project }} openpagesservice-cr \ - -o jsonpath='{.spec.version}' - register: _openpages_version_output - - - set_fact: - _openpages_version: "{{ _openpages_version_output.stdout }}" - - - name: Create OpenPages instance yaml file - template: - src: openpages-instance.yaml.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _openpages_instance_name }}-openpages.yaml" - - - name: Create OpenPages instance {{ _openpages_instance_name }} - shell: | - oc apply -f "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _openpages_instance_name }}-openpages.yaml" - register: _openpages_instance_create_result - - - debug: - var: _openpages_instance_create_result \ No newline at end of file +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision OpenPages instance {{ _openpages_instance.name }}" + _p_activity_comment: "Create OpenPages instance {{ _openpages_instance.name }} using OpenPagesInstance CR" + +- block: + - name: "Validate if instance {{ _openpages_instance_name }} already exists" + shell: | + oc get OpenPagesInstance --no-headers \ + -n {{ current_cp4d_cluster.project }} | grep "^{{ _openpages_instance_name }}[[:space:]]" | wc -l + register: _current_openpages_instance + + - when: not _current_openpages_instance.stdout == "0" + debug: + msg: "OpenPages instance {{ _openpages_instance_name }} already created. Skipping provision..." + + - when: _current_openpages_instance.stdout == "0" + block: + + - name: Get current OpenPages version + shell: | + oc get OpenPagesService -n {{ current_cp4d_cluster.project }} openpagesservice-cr \ + -o jsonpath='{.spec.version}' + register: _openpages_version_output + + - set_fact: + _openpages_version: "{{ _openpages_version_output.stdout }}" + + - name: Create OpenPages instance yaml file + template: + src: openpages-instance.yaml.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _openpages_instance_name }}-openpages.yaml" + + - name: Create OpenPages instance {{ _openpages_instance_name }} + shell: | + oc apply -f "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _openpages_instance_name }}-openpages.yaml" + register: _openpages_instance_create_result + + - debug: + var: _openpages_instance_create_result + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/delete_wa_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/delete_wa_instances.yml index 9463e872d..8b4cddd22 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/delete_wa_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/delete_wa_instances.yml @@ -10,6 +10,7 @@ validate_certs: no status_code: 200 register: _all_wa_instances + when: not cpd_dry_run # Loop through all deployed Watson Assistant instance definitions to check if instance no longer exists in the config - name: Loop through each Watson Assistant instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/main.yml index dfbe96934..1d08b0786 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/main.yml @@ -29,4 +29,5 @@ - include_tasks: wait_wa_instances.yml when: - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/provision_wa_instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/provision_wa_instance.yml index b69d4ec2c..65ebeddab 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/provision_wa_instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_assistant/tasks/provision_wa_instance.yml @@ -3,48 +3,56 @@ debug: var: _wa_instance -- name: Check if the Watson Assistant instance is already running - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_wa_instance_addon_type }}&display_name={{ _wa_instance.name }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _wa_instance_lookup_result - -- name: Determine if Watson Assistant instance already exists - debug: - msg: "Watson Assistant instance {{ _wa_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, skipping provisioning" - when: _wa_instance_lookup_result.json.total_count != 0 - -- when: _wa_instance_lookup_result.json.total_count == 0 - block: - - name: Obtain Watson Assistant version - shell: | - oc get wa -n {{ current_cp4d_cluster.project }} wa -o jsonpath='{.spec.version}' - register: _wa_version - - - name: Prepare Watson Assistant instance {{ _wa_instance.name }} json file - template: - src: wa-instance.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _wa_instance.name }}-wa-instance.json" - - - name: Create Watson Assistant instance {{ _wa_instance.name }} - shell: | - curl -v -k \ - -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ - -H 'Content-Type: application/json' \ - -X POST \ - 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ - -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _wa_instance.name }}-wa-instance.json - register: _create_wa_instance_result - - - set_fact: - _create_wa_instance_result_json: "{{ _create_wa_instance_result.stdout | from_json }}" - - - name: Show Watson Assistant instance result +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision Watson Assistant instance {{ _wa_instance.name }}" + _p_activity_comment: "Create Watson Assistant instance {{ _wa_instance.name }} using REST API" + +- block: + - name: Check if the Watson Assistant instance is already running + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_wa_instance_addon_type }}&display_name={{ _wa_instance.name }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _wa_instance_lookup_result + + - name: Determine if Watson Assistant instance already exists debug: - var: _create_wa_instance_result_json \ No newline at end of file + msg: "Watson Assistant instance {{ _wa_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, skipping provisioning" + when: _wa_instance_lookup_result.json.total_count != 0 + + - when: _wa_instance_lookup_result.json.total_count == 0 + block: + - name: Obtain Watson Assistant version + shell: | + oc get wa -n {{ current_cp4d_cluster.project }} wa -o jsonpath='{.spec.version}' + register: _wa_version + + - name: Prepare Watson Assistant instance {{ _wa_instance.name }} json file + template: + src: wa-instance.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _wa_instance.name }}-wa-instance.json" + + - name: Create Watson Assistant instance {{ _wa_instance.name }} + shell: | + curl -v -k \ + -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ + -H 'Content-Type: application/json' \ + -X POST \ + 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ + -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _wa_instance.name }}-wa-instance.json + register: _create_wa_instance_result + + - set_fact: + _create_wa_instance_result_json: "{{ _create_wa_instance_result.stdout | from_json }}" + + - name: Show Watson Assistant instance result + debug: + var: _create_wa_instance_result_json + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/delete_wd_instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/delete_wd_instances.yml index 8b28fd831..a80462f8f 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/delete_wd_instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/delete_wd_instances.yml @@ -10,6 +10,7 @@ validate_certs: no status_code: 200 register: _all_wd_instances + when: not cpd_dry_run # Loop through all deployed Watson Discovery instance definitions to check if instance no longer exists in the config - name: Loop through each Watson Discovery instance to check if it must be deleted diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/main.yml index ef247076e..e5d2eb45a 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/main.yml @@ -29,4 +29,5 @@ - include_tasks: wait_wd_instances.yml when: - (_p_delete_all_instances | default(False)) == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/provision_wd_instance.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/provision_wd_instance.yml index 31ca8b720..46f45d766 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/provision_wd_instance.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watson_discovery/tasks/provision_wd_instance.yml @@ -3,49 +3,56 @@ debug: var: _wd_instance -- name: Check if the Watson Discovery instance is already running - uri: - url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_wd_instance_addon_type }}&display_name={{ _wd_instance.name }}' - method: GET - headers: - Content-Type: application/json - Authorization: "Bearer {{ _cp4d_bearer_token }}" - return_content: yes - validate_certs: no - status_code: 200 - register: _wd_instance_lookup_result - -- name: Determine if Watson Discovery instance already exists - debug: - msg: "Watson Discovery instance {{ _wd_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, skipping provisioning" - when: _wd_instance_lookup_result.json.total_count != 0 - -- when: _wd_instance_lookup_result.json.total_count == 0 - block: - - - name: Obtain Watson Discovery version - shell: | - oc get wd -n {{ current_cp4d_cluster.project }} wd -o jsonpath='{.spec.version}' - register: _wd_version - - - name: Prepare Watson Discovery instance {{ _wd_instance.name }} json file - template: - src: wd-instance.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _wd_instance.name }}-wd-instance.json" - - - name: Create Watson Discovery instance {{ _wd_instance.name }} - shell: | - curl -v -k \ - -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ - -H 'Content-Type: application/json' \ - -X POST \ - 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ - -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _wd_instance.name }}-wd-instance.json - register: _create_wd_instance_result - - - set_fact: - _create_wd_instance_result_json: "{{ _create_wd_instance_result.stdout | from_json }}" - - - name: Show Watson Discovery instance result +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Provision Watson Discovery instance {{ _wd_instance.name }}" + _p_activity_comment: "Create Watson Discovery instance {{ _wd_instance.name }} using REST API CR" +- block: + - name: Check if the Watson Discovery instance is already running + uri: + url: 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances?addon_type={{ cp4d_wd_instance_addon_type }}&display_name={{ _wd_instance.name }}' + method: GET + headers: + Content-Type: application/json + Authorization: "Bearer {{ _cp4d_bearer_token }}" + return_content: yes + validate_certs: no + status_code: 200 + register: _wd_instance_lookup_result + + - name: Determine if Watson Discovery instance already exists debug: - var: _create_wd_instance_result_json \ No newline at end of file + msg: "Watson Discovery instance {{ _wd_instance.name }} already exists in OpenShift project {{ current_cp4d_cluster.project }}, skipping provisioning" + when: _wd_instance_lookup_result.json.total_count != 0 + + - when: _wd_instance_lookup_result.json.total_count == 0 + block: + + - name: Obtain Watson Discovery version + shell: | + oc get wd -n {{ current_cp4d_cluster.project }} wd -o jsonpath='{.spec.version}' + register: _wd_version + + - name: Prepare Watson Discovery instance {{ _wd_instance.name }} json file + template: + src: wd-instance.j2 + dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _wd_instance.name }}-wd-instance.json" + + - name: Create Watson Discovery instance {{ _wd_instance.name }} + shell: | + curl -v -k \ + -H 'Authorization: Bearer {{ _cp4d_bearer_token }}' \ + -H 'Content-Type: application/json' \ + -X POST \ + 'https://{{ cp4d_url.stdout }}/zen-data/v3/service_instances' \ + -T {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-{{ _wd_instance.name }}-wd-instance.json + register: _create_wd_instance_result + + - set_fact: + _create_wd_instance_result_json: "{{ _create_wd_instance_result.stdout | from_json }}" + + - name: Show Watson Discovery instance result + debug: + var: _create_wd_instance_result_json + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watsonx_ai/tasks/configure-watsonx_ai-instances.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watsonx_ai/tasks/configure-watsonx_ai-instances.yml index 9ae069fd2..57780c59b 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watsonx_ai/tasks/configure-watsonx_ai-instances.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watsonx_ai/tasks/configure-watsonx_ai-instances.yml @@ -5,7 +5,14 @@ dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-patch-watsonxaiifm.sh" mode: u+rwx +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "Patch watsonxaiifm for foundation model instances" + _p_activity_script: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-patch-watsonxaiifm.sh" + - name: Run script to configure running watsonx.ai models, output is in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-patch-watsonxaiifm.log shell: | {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-patch-watsonxaiifm.sh > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-patch-watsonxaiifm.log - register: _patch_watsonxaiifm_result \ No newline at end of file + register: _patch_watsonxaiifm_result + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watsonx_ai/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watsonx_ai/tasks/main.yml index cf60d44ca..b0a87cb01 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watsonx_ai/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-instance-watsonx_ai/tasks/main.yml @@ -28,8 +28,10 @@ - include_tasks: delete-watsonx_ai-instances.yml when: - (_p_wait_instances | default(False)) == False + - not cpd_dry_run - include_tasks: wait-watsonx_ai-instances.yml when: - _delete_all_watsonx_ai_instances == False - - _p_wait_instances | default(False) \ No newline at end of file + - _p_wait_instances | default(False) + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-script.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml similarity index 100% rename from automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-script.yml rename to automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml From 18f5d91f827795cf69129b50fd3072b2ff970204 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Mon, 25 Nov 2024 11:01:53 +0000 Subject: [PATCH 32/51] #820 Skip smoke test with dry-run --- .../80-smoke-tests/cp4d-cluster-show/tasks/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automation-roles/80-smoke-tests/cp4d-cluster-show/tasks/main.yml b/automation-roles/80-smoke-tests/cp4d-cluster-show/tasks/main.yml index a8607fb97..8ff69e560 100644 --- a/automation-roles/80-smoke-tests/cp4d-cluster-show/tasks/main.yml +++ b/automation-roles/80-smoke-tests/cp4d-cluster-show/tasks/main.yml @@ -13,4 +13,5 @@ _p_openshift_cluster_name: "{{ current_cp4d_cluster.openshift_cluster_name }}" - name: Output Cloud pak for Data URL and admin password - include_tasks: cp4d-show-details.yml \ No newline at end of file + include_tasks: cp4d-show-details.yml + when: not cpd_dry_run \ No newline at end of file From f15d4b558d9b5786c098248c9675e23ed2e1ae91 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 26 Nov 2024 18:12:56 +0000 Subject: [PATCH 33/51] #820 Apply yaml using role --- .../cloud-native-toolkit/tasks/main.yml | 81 +++++----- .../nfd-operator/tasks/main.yml | 66 +++----- .../nvidia-operator/tasks/main.yml | 96 +++++------- .../odf-operator/tasks/main.yml | 16 +- .../openshift-adp/tasks/main.yml | 17 +-- .../tasks/install-opernshift-ai.yml | 143 +++++++----------- .../openshift-console-banner/tasks/main.yaml | 22 +-- .../openshift-mcg/tasks/main.yml | 45 +++--- .../tasks/configure-keycloak.yml | 17 +-- .../tasks/configure-openshift-redhat-sso.yml | 85 ++++------- .../tasks/cp4d-install-cr-watson_ks.yml | 17 +-- .../tasks/cp4d-prep-cpd-edb.yml | 17 +-- .../tasks/cp4d-prep-watsonx-orchestrate.yml | 16 +- .../tasks/cp4d-db2u-configmap.yml | 17 +-- .../tasks/create-crio-config-crc.yml | 17 +-- .../tasks/create-kubelet-config.yml | 17 +-- .../cp4d/cp4d-ocp-tuned/tasks/main.yml | 11 +- .../tasks/configure-cpd-audit.yml | 1 - .../tasks/generate-yaml-file.yml | 5 + .../generate-apply-yaml/tasks/main.yml | 13 ++ 20 files changed, 266 insertions(+), 453 deletions(-) create mode 100644 automation-roles/99-generic/deployer/generate-apply-yaml/tasks/generate-yaml-file.yml create mode 100644 automation-roles/99-generic/deployer/generate-apply-yaml/tasks/main.yml diff --git a/automation-roles/40-configure-infra/cloud-native-toolkit/tasks/main.yml b/automation-roles/40-configure-infra/cloud-native-toolkit/tasks/main.yml index 9ffb97cd7..ffdb46ceb 100644 --- a/automation-roles/40-configure-infra/cloud-native-toolkit/tasks/main.yml +++ b/automation-roles/40-configure-infra/cloud-native-toolkit/tasks/main.yml @@ -20,60 +20,49 @@ register: _gitops_yaml_files - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Install GitOps operator file {{ item.path }}" - _p_activity_yaml: "{{ item.path }}" + _p_apply_yaml_description: "Install GitOps operator" + _p_apply_yaml_output_file: "{{ item.path }}" loop: '{{ _gitops_yaml_files.files }}' - - - block: - - name: Install GitOps operator - shell: | - oc apply -f {{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x - - name: Wait until OpenShift GitOps CSV has status Succeeded - shell: | - oc get csv -n openshift-operators \ - -l operators.coreos.com/openshift-gitops-operator.openshift-operators \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _openshift_gitops_csv_status - retries: 30 - delay: 30 - until: _openshift_gitops_csv_status.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) ... + - name: Wait until OpenShift GitOps CSV has status Succeeded + shell: | + oc get csv -n openshift-operators \ + -l operators.coreos.com/openshift-gitops-operator.openshift-operators \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _openshift_gitops_csv_status + retries: 30 + delay: 30 + until: _openshift_gitops_csv_status.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 - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create ArgoCD instance" - _p_activity_yaml: "{{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x/argocd-instance/argocd-instance.yaml" - - - block: - - name: Create ArgoCD instance - shell: | - oc apply -f {{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x/argocd-instance/argocd-instance.yaml \ - -n openshift-gitops + _p_apply_yaml_description: "Create ArgoCD instance" + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/multi-tenancy-gitops/setup/ocp4x/argocd-instance/argocd-instance.yaml" - - name: Wait until ArgoCD instance has been created in OpenShift project openshift-gitops - shell: | - oc get argocd -n openshift-gitops openshift-gitops-cntk \ - --no-headers | wc -l - register: _argocd_instance - retries: 30 - delay: 30 - until: _argocd_instance.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) ... + - name: Wait until ArgoCD instance has been created in OpenShift project openshift-gitops + shell: | + oc get argocd -n openshift-gitops openshift-gitops-cntk \ + --no-headers | wc -l + register: _argocd_instance + retries: 30 + delay: 30 + until: _argocd_instance.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 when: (_p_openshift_cluster.cloud_native_toolkit | default(False) | bool) \ No newline at end of file diff --git a/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml b/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml index 532f58127..c9bfafb33 100644 --- a/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml @@ -21,56 +21,38 @@ - set_fact: _nfd_channel: "{{ _nfd_packagemanifest.stdout }}" -- name: Generate NFD operator file {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml - template: - src: nfd-operator.j2 - dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create NFD operator" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml" - -- block: - - name: Create NFD operator - shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml + _p_apply_yaml_description: Create NFD operator + _p_apply_yaml_template: nfd-operator.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-operator.yaml" - - name: Wait until NFD Operator CSV has status Succeeded - shell: | - oc get csv -n openshift-nfd \ - -l operators.coreos.com/nfd.openshift-nfd \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _nfd_csv_status - retries: 30 - delay: 30 - until: _nfd_csv_status.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) ... +- name: Wait until NFD Operator CSV has status Succeeded + shell: | + oc get csv -n openshift-nfd \ + -l operators.coreos.com/nfd.openshift-nfd \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _nfd_csv_status + retries: 30 + delay: 30 + until: _nfd_csv_status.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 - name: Get OpenShift version include_role: name: openshift-get-version -- name: Generate NodeFeatureDiscovery CR file {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml - template: - src: nfd-cr.j2 - dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create NFD CR" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml" - -- name: Create NFD CR - shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml - when: not cpd_dry_run \ No newline at end of file + _p_apply_yaml_description: Generate NodeFeatureDiscovery CR + _p_apply_yaml_template: nfd-cr.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nfd-cr.yaml" \ No newline at end of file diff --git a/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml b/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml index a2653692e..d9f8be319 100644 --- a/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml @@ -21,69 +21,51 @@ - set_fact: _nvidia_channel: "{{ _nvidia_packagemanifest.stdout }}" -- name: Generate NVIDIA operator file {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml - template: - src: nvidia-operator.j2 - dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create NVIDIA operator" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml" - -- block: - - name: Create NVIDIA operator - shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml + _p_apply_yaml_description: Create NVIDIA operator + _p_apply_yaml_template: nvidia-operator.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-operator.yaml" - - name: Wait until NVIDIA Operator CSV has status Succeeded - shell: | - oc get csv -n nvidia-gpu-operator \ - -l operators.coreos.com/gpu-operator-certified.nvidia-gpu-operator \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _nvidia_csv_status - retries: 30 - delay: 30 - until: _nvidia_csv_status.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) ... +- name: Wait until NVIDIA Operator CSV has status Succeeded + shell: | + oc get csv -n nvidia-gpu-operator \ + -l operators.coreos.com/gpu-operator-certified.nvidia-gpu-operator \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _nvidia_csv_status + retries: 30 + delay: 30 + until: _nvidia_csv_status.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 -- name: Generate NVIDIA ClusterPolicy CR file {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml - template: - src: nvidia-cluster-policy-cr.j2 - dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create NVIDIA ClusterPolicy CR" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml" - -- block: - - name: Create NVIDIA ClusterPolicy CR - shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml + _p_apply_yaml_description: Generate NVIDIA ClusterPolicy CR + _p_apply_yaml_template: nvidia-cluster-policy-cr.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-nvidia-cluster-policy-cr.yaml" - - name: Wait until NVIDIA ClusterPolicy has status Ready - shell: | - oc get clusterpolicies.nvidia.com gpu-cluster-policy \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.state' | \ - grep -i ready | wc -l - register: _nvidia_cluster_policy_status - retries: 30 - delay: 30 - until: _nvidia_cluster_policy_status.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) ... +- name: Wait until NVIDIA ClusterPolicy has status Ready + shell: | + oc get clusterpolicies.nvidia.com gpu-cluster-policy \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.state' | \ + grep -i ready | wc -l + register: _nvidia_cluster_policy_status + retries: 30 + delay: 30 + until: _nvidia_cluster_policy_status.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 \ No newline at end of file diff --git a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml index ad2ee37f0..e2b81dea3 100644 --- a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml @@ -41,22 +41,14 @@ - set_fact: _odf_channel: "{{ _odf_packagemanifest.stdout }}" -- name: Generate ODF operator file {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml - template: - src: odf-operator.j2 - dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create ODF operator" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml" + _p_apply_yaml_description: Create ODF operator + _p_apply_yaml_template: odf-operator.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml" - block: - - name: Create ODF operator - shell: | - oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-odf-operator.yaml - - name: Wait until ODF Operator CSV has status Succeeded shell: | oc get csv -n openshift-storage \ diff --git a/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml b/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml index 74bd7485c..38a82aa17 100644 --- a/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml +++ b/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml @@ -39,20 +39,11 @@ - set_fact: _oadp_channel: "{{ _oadp_packagemanifest.stdout }}" - - name: Generate operator subscription for Advanced Data Protection into "{{ status_dir }}/openshift/openshift-adp-sub.yaml" - template: - src: openshift-adp-sub.j2 - dest: "{{ status_dir }}/openshift/openshift-adp-sub.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Activate OpenShift Advanced Data Protection" - _p_activity_yaml: "{{ status_dir }}/openshift/openshift-adp-sub.yaml" - - - name: Apply yaml for Advanced Data Protection subscription - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-adp-sub.yaml - when: not cpd_dry_run + _p_apply_yaml_description: Create OpenShift Advanced Data Protection operator + _p_apply_yaml_template: openshift-adp-sub.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/openshift-adp-sub.yaml" when: (_p_openshift_cluster.oadp | default(False) | bool) \ No newline at end of file diff --git a/automation-roles/40-configure-infra/openshift-ai/tasks/install-opernshift-ai.yml b/automation-roles/40-configure-infra/openshift-ai/tasks/install-opernshift-ai.yml index c97d32323..4c60495b7 100644 --- a/automation-roles/40-configure-infra/openshift-ai/tasks/install-opernshift-ai.yml +++ b/automation-roles/40-configure-infra/openshift-ai/tasks/install-opernshift-ai.yml @@ -1,100 +1,73 @@ --- -- name: Generate OpenShift AI operator {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml - template: - src: openshift-ai-operator.j2 - dest: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create OpenShift AI operator" - _p_activity_yaml: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml" - -- block: - - name: Apply yaml for OpenShift AI operator - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml + _p_apply_yaml_description: Create OpenShift AI operator + _p_apply_yaml_template: openshift-ai-operator.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-operator.yaml" - - name: Wait until OpenShift AI operator CSV has status Succeeded - shell: | - oc get csv -n redhat-ods-operator \ - -l operators.coreos.com/rhods-operator.redhat-ods-operator \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _openshift_ai_csv_status - retries: 30 - delay: 30 - until: _openshift_ai_csv_status.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) ... +- name: Wait until OpenShift AI operator CSV has status Succeeded + shell: | + oc get csv -n redhat-ods-operator \ + -l operators.coreos.com/rhods-operator.redhat-ods-operator \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _openshift_ai_csv_status + retries: 30 + delay: 30 + until: _openshift_ai_csv_status.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 -- name: Generate OpenShift AI DSCInitialization {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml - template: - src: dscinitialization.j2 - dest: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create OpenShift AI DSCInitialization" - _p_activity_yaml: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml" - -- block: - - name: Apply yaml for OpenShift AI DSCInitialization - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml + _p_apply_yaml_description: Create OpenShift AI DSCInitialization + _p_apply_yaml_template: dscinitialization.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc-init.yaml" - - name: Wait until OpenShift AI DSCInitialization default-dsci is ready - shell: | - oc get DSCInitialization default-dsci \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i ready | wc -l - register: _openshift_ai_dsc_init_status - retries: 30 - delay: 30 - until: _openshift_ai_dsc_init_status.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) ... +- name: Wait until OpenShift AI DSCInitialization default-dsci is ready + shell: | + oc get DSCInitialization default-dsci \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i ready | wc -l + register: _openshift_ai_dsc_init_status + retries: 30 + delay: 30 + until: _openshift_ai_dsc_init_status.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 -- name: Generate OpenShift AI DataScienceCluster {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml - template: - src: datasciencecluster.j2 - dest: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create OpenShift AI DataScienceCluster" - _p_activity_yaml: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml" + _p_apply_yaml_description: Create OpenShift AI DataScienceCluster + _p_apply_yaml_template: datasciencecluster.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml" -- block: - - name: Apply yaml for OpenShift AI DataScienceCluster - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-openshift-ai-dsc.yaml - - - name: Wait until OpenShift AI DataScienceCluster default-dsc is ready - shell: | - oc get DataScienceCluster default-dsc \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i ready | wc -l - register: _openshift_ai_dsc_status - retries: 30 - delay: 30 - until: _openshift_ai_dsc_status.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) ... +- name: Wait until OpenShift AI DataScienceCluster default-dsc is ready + shell: | + oc get DataScienceCluster default-dsc \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i ready | wc -l + register: _openshift_ai_dsc_status + retries: 30 + delay: 30 + until: _openshift_ai_dsc_status.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 \ No newline at end of file diff --git a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml index dd3b97934..70e625ebd 100644 --- a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml +++ b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml @@ -1,20 +1,10 @@ --- -- block: - - name: Create OpenShift console banner - template: - src: console-banner.j2 - dest: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-console-banner.yaml" - - - include_role: - name: log-deployer-activity - vars: - _p_activity_description: "Create OpenShift console banner" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-console-banner.yaml" - - - name: Create OpenShift console banner - shell: | - oc apply -f {{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-console-banner.yaml - when: not cpd_dry_run +- include_role: + name: generate-apply-yaml + vars: + _p_apply_yaml_description: Create OpenShift console banner + _p_apply_yaml_template: console-banner.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-console-banner.yaml" when: (_p_openshift_cluster.console_banner | default ("")) != "" - block: diff --git a/automation-roles/40-configure-infra/openshift-mcg/tasks/main.yml b/automation-roles/40-configure-infra/openshift-mcg/tasks/main.yml index 175d412ba..816efd7d8 100644 --- a/automation-roles/40-configure-infra/openshift-mcg/tasks/main.yml +++ b/automation-roles/40-configure-infra/openshift-mcg/tasks/main.yml @@ -27,36 +27,27 @@ vars: _p_openshift_cluster: "{{ current_openshift_cluster }}" - - name: Generate MCG StorageCluster ocs-storagecluster into {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml - template: - src: openshift-mcg-storagecluster.j2 - dest: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create MCG StorageCluster" - _p_activity_yaml: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml" - - - block: - - name: Apply yaml for MCG StorageCluster ocs-storagecluster - shell: | - oc apply -f {{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml + _p_apply_yaml_description: Create MCG StorageCluster ocs-storagecluster + _p_apply_yaml_template: openshift-mcg-storagecluster.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/openshift-{{ _p_openshift_cluster.name }}-mcg-storagecluster.yaml" - - name: Wait until MCG StorageCluster has status Ready - shell: | - oc get StorageCluster ocs-storagecluster -n openshift-storage \ - --no-headers \ - -o custom-columns='phase:status.phase' - register: _storage_cluster_status - retries: 60 - delay: 30 - until: _storage_cluster_status.stdout == "Ready" - 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) ... + - name: Wait until MCG StorageCluster has status Ready + shell: | + oc get StorageCluster ocs-storagecluster -n openshift-storage \ + --no-headers \ + -o custom-columns='phase:status.phase' + register: _storage_cluster_status + retries: 60 + delay: 30 + until: _storage_cluster_status.stdout == "Ready" + 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 when: diff --git a/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml b/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml index 909eb6a49..0b3025bba 100644 --- a/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml +++ b/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-keycloak.yml @@ -1,21 +1,12 @@ --- -- name: Generate yaml for Keycloak {{ _keycloak_name }} in namespace {{ _keycloak_name }} - template: - src: redhat-sso-keycloak.j2 - dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create Keycloak {{ _keycloak_name }}" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" + _p_apply_yaml_description: Create Keycloak + _p_apply_yaml_template: redhat-sso-keycloak.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml" - block: - - name: Create Keycloak from YAML file {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml - shell: | - oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-keycloak.yaml - - - name: Wait until Keycloak {{ _keycloak_name }} is ready shell: | oc get keycloaks.keycloak.org -n {{ _keycloak_name }} {{ _keycloak_name }} \ diff --git a/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml b/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml index fde72f50c..3daada023 100644 --- a/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml +++ b/automation-roles/40-configure-infra/openshift-redhat-sso/tasks/configure-openshift-redhat-sso.yml @@ -1,67 +1,40 @@ --- -- name: Generate yaml for {{ _keycloak_name }} namespace - template: - src: redhat-sso-namespace.j2 - dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-namespace.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create Red Hat SSO namespace {{ _keycloak_name }}" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-namespace.yaml" - -- name: Create Red Hat SSO namespace {{ _keycloak_name }} - shell: | - oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-namespace.yaml - when: not cpd_dry_run - -- name: Generate yaml for Red Hat SSO operator group in project {{ _keycloak_name }} - template: - src: redhat-sso-operatorgroup.j2 - dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" + _p_apply_yaml_description: Create Red Hat SSO namespace {{ _keycloak_name }} + _p_apply_yaml_template: redhat-sso-namespace.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-namespace.yaml" - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create Red Hat SSO operatorgroup in project {{ _keycloak_name }}" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" - -- name: Create Red Hat SSO operatorgroup in project {{ _keycloak_name }} - shell: | - oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml - when: not cpd_dry_run - -- name: Generate yaml for Red Hat SSO subscription in project {{ _keycloak_name }} - template: - src: redhat-sso-subscription.j2 - dest: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-subscription.yaml" + _p_apply_yaml_description: Create Red Hat SSO operator group in project {{ _keycloak_name }} + _p_apply_yaml_template: redhat-sso-operatorgroup.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create Red Hat SSO operator in project {{ _keycloak_name }}" - _p_activity_yaml: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-operatorgroup.yaml" + _p_apply_yaml_description: Create Red Hat SSO subscription in project {{ _keycloak_name }} + _p_apply_yaml_template: redhat-sso-subscription.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-subscription.yaml" -- block: - - name: Create Red Hat SSO operator in project {{ _keycloak_name }} - shell: | - oc apply -f {{ status_dir }}/openshift/{{ current_openshift_cluster.name }}-{{ _keycloak_name }}-redhat-sso-subscription.yaml - - # Wait until subscription has been successfully created - - name: Wait until Red Hat SSO operator in project {{ _keycloak_name }} has status Succeeded - shell: | - oc get csv -n {{ _keycloak_name }} \ - -l operators.coreos.com/rhsso-operator.{{ _keycloak_name }} \ - --no-headers \ - -o custom-columns='name:metadata.name,phase:status.phase' | \ - grep -i succeeded | wc -l - register: _redhat_sso_csv_status - retries: 30 - delay: 30 - until: _redhat_sso_csv_status.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) ... +# Wait until subscription has been successfully created +- name: Wait until Red Hat SSO operator in project {{ _keycloak_name }} has status Succeeded + shell: | + oc get csv -n {{ _keycloak_name }} \ + -l operators.coreos.com/rhsso-operator.{{ _keycloak_name }} \ + --no-headers \ + -o custom-columns='name:metadata.name,phase:status.phase' | \ + grep -i succeeded | wc -l + register: _redhat_sso_csv_status + retries: 30 + delay: 30 + until: _redhat_sso_csv_status.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 \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-watson_ks.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-watson_ks.yml index 7f9498b09..621f14342 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-watson_ks.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-watson_ks.yml @@ -2,18 +2,9 @@ - include_tasks: cp4d-setup-mcg-secrets.yml when: _p_current_cp4d_cluster.cp4d_version >= "4.7.0" -- name: Prepare yaml file for Watson Knowledge Studio CR - template: - src: watson-ks-cr-45.j2 - dest: "{{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create Watson Knowledge Studio CR" - _p_activity_yaml: "{{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml" - -- name: Create Watson Knowledge Studio CR - shell: | - oc apply -f {{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml - when: not cpd_dry_run \ No newline at end of file + _p_apply_yaml_description: Create Watson Knowledge Studio CR + _p_apply_yaml_template: watson-ks-cr-45.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-cpd-edb.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-cpd-edb.yml index 844c2cdc2..f0e64d1fd 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-cpd-edb.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-cpd-edb.yml @@ -13,18 +13,9 @@ - set_fact: _cpd_edb_license_key: "{{ secret_value | b64encode }}" -- name: Create EDB PostgreSQL license secret object - template: - src: "cpd-edb-license-secret.j2" - dest: "{{ status_dir }}/cp4d/cpd-edb-postgresql-secret.yml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create EDB PostgreSQL license secret object" - _p_activity_yaml: "{{ status_dir }}/cp4d/cpd-edb-postgresql-secret.yml" - -- name: Apply EDB PostgreSQL secret - command: | - oc apply -f "{{ status_dir }}/cp4d/cpd-edb-postgresql-secret.yml" - when: not cpd_dry_run \ No newline at end of file + _p_apply_yaml_description: Create EDB PostgreSQL license secret + _p_apply_yaml_template: cpd-edb-license-secret.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/cp4d/cpd-edb-postgresql-secret.yml" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml index 76f2cb763..30877e137 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml @@ -84,21 +84,13 @@ {{ _create_app_connect_catsrc }} when: not cpd_dry_run -- 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" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create IBM App Connect operator" - _p_activity_yaml: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-ibm-app-connect.yaml" + _p_apply_yaml_description: Create IBM App Connect operator + _p_apply_yaml_template: ibm-app-connect.j2 + _p_apply_yaml_output_file: "{{ 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 - when: not cpd_dry_run - name: Wait for IBM App Connect operator to be installed shell: | diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/cp4d-db2u-configmap.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/cp4d-db2u-configmap.yml index 4acc17756..6c97e13fe 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/cp4d-db2u-configmap.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/cp4d-db2u-configmap.yml @@ -1,16 +1,7 @@ --- -- name: Generate configmap file {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2u-product-cm.yml - template: - src: db2u-product-cm.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2u-product-cm.yml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml 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 - when: not cpd_dry_run \ No newline at end of file + _p_apply_yaml_description: Create Db2U configmap + _p_apply_yaml_template: db2u-product-cm.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-db2u-product-cm.yml" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-crio-config/tasks/create-crio-config-crc.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-crio-config/tasks/create-crio-config-crc.yml index 0c13ac091..0b147e19d 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-crio-config/tasks/create-crio-config-crc.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-crio-config/tasks/create-crio-config-crc.yml @@ -1,16 +1,7 @@ --- -- name: Create Container Runtime Configuration definition {{ status_dir }}/openshift/cp4d-container-runtime-config.yaml - template: - src: cp4d-container-runtime-config.j2 - dest: "{{ status_dir }}/openshift/cp4d-container-runtime-config.yaml" - - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create Container Runtime Configuration" - _p_activity_yaml: "{{ status_dir }}/openshift/cp4d-container-runtime-config.yaml" - -- name: Apply Container Runtime configuration - shell: | - oc apply -f {{ status_dir }}/openshift/cp4d-container-runtime-config.yaml - when: not cpd_dry_run \ No newline at end of file + _p_apply_yaml_description: Create Container Runtime Configuration + _p_apply_yaml_template: cp4d-container-runtime-config.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/cp4d-container-runtime-config.yaml" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/create-kubelet-config.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/create-kubelet-config.yml index a69633e50..794f20d34 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/create-kubelet-config.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-kubelet-config/tasks/create-kubelet-config.yml @@ -3,22 +3,13 @@ shell: | oc delete KubeletConfig cpd-crio-kubeletconfig --ignore-not-found when: not cpd_dry_run - -- name: Create KubeletConfig yaml - template: - src: cp4d-kubeletconfig.j2 - dest: "{{ status_dir }}/openshift/cp4d-kubeletconfig.yaml" - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create KubeletConfig" - _p_activity_yaml: "{{ status_dir }}/openshift/cp4d-kubeletconfig.yaml" - -- name: Create KubeletConfig {{ kubelet_config_name }} - shell: | - oc apply -f {{ status_dir }}/openshift/cp4d-kubeletconfig.yaml - when: not cpd_dry_run + _p_apply_yaml_description: Create KubeletConfig + _p_apply_yaml_template: cp4d-kubeletconfig.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/cp4d-kubeletconfig.yaml" - name: Label worker machine config pool to allow KubeletConfig shell: | diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-tuned/tasks/main.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-tuned/tasks/main.yml index b33cdfe3b..6101625a6 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-tuned/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-ocp-tuned/tasks/main.yml @@ -33,12 +33,7 @@ -f {{ status_dir }}/openshift/cp4d-tuned.yaml - include_role: - name: log-deployer-activity + name: generate-apply-yaml vars: - _p_activity_description: "Create Tuned resource" - _p_activity_yaml: "{{ status_dir }}/openshift/cp4d-tuned.yaml" - -- name: Create Tuned cp4d_ipc - shell: | - oc apply -f {{ status_dir }}/openshift/cp4d-tuned.yaml - when: not cpd_dry_run \ No newline at end of file + _p_apply_yaml_description: Create Tuned resource + _p_apply_yaml_output_file: "{{ status_dir }}/openshift/cp4d-tuned.yaml" \ No newline at end of file diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-audit/tasks/configure-cpd-audit.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-audit/tasks/configure-cpd-audit.yml index ee0b7405f..42c42f2d6 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-audit/tasks/configure-cpd-audit.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-audit/tasks/configure-cpd-audit.yml @@ -1,5 +1,4 @@ --- - - name: Generate audit configuration template: src: cpd-audit-fluent-config.j2 diff --git a/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/generate-yaml-file.yml b/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/generate-yaml-file.yml new file mode 100644 index 000000000..372f95130 --- /dev/null +++ b/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/generate-yaml-file.yml @@ -0,0 +1,5 @@ +--- +- name: "Generate YAML file for {{ _p_apply_yaml_description }}" + template: + src: "{{ _p_apply_yaml_template }}" + dest: "{{ _p_apply_yaml_output_file }}" \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/main.yml b/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/main.yml new file mode 100644 index 000000000..4b0b8323d --- /dev/null +++ b/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/main.yml @@ -0,0 +1,13 @@ +--- +- include_tasks: generate-yaml-file.yml + when: (_p_apply_yaml_template | default('')) != '' + +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "{{ _p_apply_yaml_description }}" + _p_activity_yaml: "{{ _p_apply_yaml_output_file }}" + +- name: "{{ _p_apply_yaml_description }} using file {{ _p_apply_yaml_output_file }}" + shell: | + oc apply -f {{ _p_apply_yaml_output_file }} \ No newline at end of file From bbbb4b6136fddc5d2da121266c80d514d0cae91d Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 26 Nov 2024 19:17:36 +0000 Subject: [PATCH 34/51] #820 Unify execution of command with dry-run --- .../demo-openldap/tasks/install-openldap.yml | 13 +------ .../demo-openldap/tasks/remove-openldap.yml | 17 ++------ .../nfd-operator/tasks/main.yml | 14 ++----- .../nvidia-operator/tasks/main.yml | 14 ++----- .../odf-operator/tasks/main.yml | 14 ++----- .../openshift-adp/tasks/main.yml | 26 +++---------- .../openshift-console-banner/tasks/main.yaml | 22 +++-------- .../tasks/cp4d-prep-watsonx-orchestrate.yml | 24 +++--------- .../tasks/cp4d-set-cartridge-options.yml | 9 +---- .../tasks/cp4d-set-cartridge-scaling.yml | 9 +---- .../tasks/cp4d-setup-mcg-secrets.yml | 16 ++------ .../tasks/cp4d-remove-cr.yml | 18 ++------- .../tasks/create-catalog-source-olm-utils.yml | 9 +---- .../templates/apply-olm-create-catsrc.j2 | 2 +- .../tasks/install-control-plane-olm-utils.yml | 39 ++++++++----------- .../tasks/openshift-install-knative.yml | 9 +---- .../tasks/openshift-prepare-project.yml | 28 +++---------- .../templates/apply-cr-cpd-platform.j2 | 2 +- .../templates/deploy-knative-eventing.j2 | 2 +- .../tasks/install-scheduler.yml | 11 ++---- .../tasks/uninstall-scheduler.yml | 14 ++----- .../templates/apply-scheduler.j2 | 2 +- .../apply-global-pull-secret-private.yml | 6 +-- .../tasks/log-deployer-script-file.yml | 2 +- .../deployer/run-command/tasks/main.yml | 11 ++++++ 25 files changed, 93 insertions(+), 240 deletions(-) create mode 100644 automation-roles/99-generic/deployer/run-command/tasks/main.yml diff --git a/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml b/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml index 11086efe7..42cd6af83 100644 --- a/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml +++ b/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml @@ -43,20 +43,11 @@ mode: u+rwx - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create project {{ _openldap_project_name }}" + _p_activity_description: Create project {{ _openldap_project_name }} _p_activity_command: "oc adm new-project {{ _openldap_project_name }} || true" -- name: Create Project {{ _openldap_project_name }} - ansible.builtin.include_role: - name: common - tasks_from: create-project - vars: - common_namespace_name: "{{ _openldap_project_name }}" - common_output_directory: "{{ _v_openldap_base_dir }}" - when: not cpd_dry_run - - name: Prepare OpenLDAP yaml file for cluster {{ current_openshift_cluster.name }} ansible.builtin.template: src: "{{ item }}.yaml.j2" diff --git a/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml b/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml index 1e4e3d01f..a037f0583 100644 --- a/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml +++ b/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml @@ -1,16 +1,5 @@ - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Delete project {{ _openldap_project_name }}" - _p_activity_command: "oc delete ns {{ _openldap_project_name }} --ignore-not-found" - -- name: Remove OpenShift project {{ _openldap_project_name }} - kubernetes.core.k8s: - state: absent - api_version: project.openshift.io/v1 - kind: Project - name: "{{ _openldap_project_name }}" - wait: true - wait_sleep: 15 - wait_timeout: 120 - when: not cpd_dry_run \ No newline at end of file + _p_activity_description: Delete project {{ _openldap_project_name }} + _p_activity_command: "oc delete ns {{ _openldap_project_name }} --ignore-not-found" \ No newline at end of file diff --git a/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml b/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml index c9bfafb33..5e53ef714 100644 --- a/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml @@ -1,17 +1,9 @@ --- -- set_fact: - _create_nfd_ns: "oc create ns openshift-nfd || true" - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create Node Feature Discovery operator namespace" - _p_activity_commandl: "{{ _create_nfd_ns }}" - -- name: Create openshift-nfd OpenShift project - shell: | - {{ _create_nfd_ns }} - when: not cpd_dry_run + _p_activity_description: Create Node Feature Discovery operator namespace + _p_activity_command: "oc create ns openshift-nfd || true" - name: Retrieve default channel for Node Feature Discovery manifest shell: diff --git a/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml b/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml index d9f8be319..1738dca7d 100644 --- a/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml @@ -1,17 +1,9 @@ --- -- set_fact: - _create_nvidia_operator_ns: "oc create ns nvidia-gpu-operator || true" - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create NVIDIA operator namespace" - _p_activity_commandl: "{{ _create_nvidia_operator_ns }}" - -- name: Create nvidia-gpu-operator OpenShift project - shell: | - {{ _create_nvidia_operator_ns }} - when: not cpd_dry_run + _p_activity_description: Create NVIDIA operator namespace nvidia-gpu-operator + _p_activity_command: "oc create ns nvidia-gpu-operator || true" - name: Retrieve default channel for the NVIDIA GPU manifest shell: diff --git a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml index e2b81dea3..5d872500e 100644 --- a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml @@ -19,19 +19,11 @@ - include_tasks: aws-s3-sts-role.yml when: _aws_sts_mode -- set_fact: - _create_openshift_storage_project: "oc create ns openshift-storage || true" - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create openshift-storage project" - _p_activity_command: "{{ _create_openshift_storage_project }}" - -- name: Create openshift-storage OpenShift project - shell: | - {{ _create_openshift_storage_project }} - when: not cpd_dry_run + _p_activity_description: Create OpenShift project openshift-storage + _p_activity_command: "oc create ns openshift-storage || true" - name: Retrieve default channel for ocs-operator manifest shell: diff --git a/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml b/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml index 38a82aa17..cd84cc4f1 100644 --- a/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml +++ b/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml @@ -5,31 +5,17 @@ - _p_openshift_cluster is defined - block: - - set_fact: - _create_openshift_adp_ns: "oc create ns openshift-adp || true" - _annotate_openshift_adp_ns: 'oc annotate namespace openshift-adp openshift.io/node-selector="" --overwrite' - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create project openshift-adp" - _p_activity_commandl: "{{ _create_openshift_adp_ns }}" - - - name: Create project openshift-adp - shell: | - {{ _create_openshift_adp_ns }} - when: not cpd_dry_run + _p_activity_description: Create project openshift-adp + _p_activity_command: "oc create ns openshift-adp || true" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Annotate project openshift-adp namespace" - _p_activity_commandl: "{{ _annotate_openshift_adp_ns }}" - - - name: Annotate project openshift-adp namespace - shell: | - {{ _annotate_openshift_adp_ns }} - when: not cpd_dry_run + _p_activity_description: Annotate project openshift-adp + _p_activity_command: "oc annotate namespace openshift-adp openshift.io/node-selector= --overwrite" - name: Retrieve default channel for redhad-oadp-operator manifest shell: diff --git a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml index 70e625ebd..62fa6b675 100644 --- a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml +++ b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml @@ -7,19 +7,9 @@ _p_apply_yaml_output_file: "{{ status_dir }}/openshift/{{ _p_openshift_cluster.name }}-console-banner.yaml" when: (_p_openshift_cluster.console_banner | default ("")) != "" -- block: - - set_fact: - _delete_openshift_console_banner: "oc delete ConsoleNotification cpd-console-banner --ignore-not-found" - - - include_role: - name: log-deployer-activity - vars: - _p_activity_description: "Setup Multicloud Object Gateway" - _p_activity_command: "{{ _delete_openshift_console_banner }}" - - - name: Delete console banner if not specified - shell: | - {{ _delete_openshift_console_banner }} - when: not cpd_dry_run - when: - - (_p_openshift_cluster.console_banner | default ("")) == "" \ No newline at end of file +- include_role: + name: run-command + vars: + _p_activity_description: Delete OpenShift console banner + _p_activity_command: oc delete ConsoleNotification cpd-console-banner --ignore-not-found + when: (_p_openshift_cluster.console_banner | default ("")) == "" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml index 30877e137..a0bcd6e33 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml @@ -55,35 +55,22 @@ dest: /tmp remote_src: True -- set_fact: - _create_app_connect_project: "oc new-project {{ _app_connect.app_connect_project }} || true" - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create App Connect project" - _p_activity_command: "{{ _create_app_connect_project }}" - -- name: Create OpenShift Project {{ _app_connect.app_connect_project }} - shell: | - {{ _create_app_connect_project }} - when: not cpd_dry_run + _p_activity_description: Create App Connect project {{ _app_connect.app_connect_project }} + _p_activity_command: "oc adn new-project {{ _app_connect.app_connect_project }} || true" - name: Generate command to create IBM App Connect catalog source set_fact: _create_app_connect_catsrc: "{{ lookup('template', 'create-app-connect-catsrc.j2') }}" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create App Connect catalog source" + _p_activity_description: Create IBM App Connect catalog source _p_activity_command: "{{ _create_app_connect_catsrc }}" -- name: Create IBM App Connect catalog source - shell: | - {{ _create_app_connect_catsrc }} - when: not cpd_dry_run - - include_role: name: generate-apply-yaml vars: @@ -91,7 +78,6 @@ _p_apply_yaml_template: ibm-app-connect.j2 _p_apply_yaml_output_file: "{{ 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 }} \ diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml index b6e555fca..b00546c70 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml @@ -9,13 +9,8 @@ _set_cartridge_options: "{{ lookup('template', 'set-cartridge-options.j2') }}" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Set cartridge options for {{ _current_cp4d_cartridge.CR_Kind }}" + _p_activity_description: Set cartridge options for {{ _current_cp4d_cartridge.CR_Kind }} _p_activity_command: "{{ _set_cartridge_options }}" - - - name: Set cartridge installation options for cartridge {{ _current_cp4d_cartridge.name }} - shell: | - {{ _set_cartridge_options }} - when: not cpd_dry_run when: (_current_cp4d_cartridge.installation_options | default({})) != {} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml index 4b6df87d1..551096e03 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml @@ -5,14 +5,9 @@ _set_cartridge_scaling: "{{ lookup('template', 'set-cartridge-scaling.j2') }}" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Set cartridge scaling for {{ _current_cp4d_cartridge.CR_Kind }}" + _p_activity_description: Set cartridge scaling for {{ _current_cp4d_cartridge.CR_Kind }} _p_activity_command: "{{ _set_cartridge_scaling }}" - - - name: Scale service - shell: | - {{ _set_cartridge_scaling }} - when: not cpd_dry_run when: (_current_cp4d_cartridge.size | default('')) != '' \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml index d70ab8756..7243d9ee4 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml @@ -3,18 +3,8 @@ set_fact: _setup_mcg_command: "{{ lookup('template', 'setup-mcg.j2') }}" -- name: Show setup-mcg command - debug: - var: _setup_mcg_command - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Setup Multicloud Object Gateway" - _p_activity_command: "{{ _setup_mcg_command }}" - -- name: Set up Multicloud Object Gateway (MCG) secrets for {{ _current_cp4d_cartridge.olm_utils_name }} in CP4D project {{ _p_current_cp4d_cluster.project }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-setup-mcg.log - shell: | - {{ _setup_mcg_command }} - when: not cpd_dry_run - + _p_activity_description: Set up Multicloud Object Gateway (MCG) secrets for {{ _current_cp4d_cartridge.olm_utils_name }} in CP4D project {{ _p_current_cp4d_cluster.project }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-setup-mcg.log + _p_activity_command: "{{ _setup_mcg_command }}" diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml index f9f588772..fae07ea4d 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml @@ -7,20 +7,8 @@ - name: Delete instances of {{ _current_cartridge_cr.name }} include_tasks: cp4d-delete-cr-instances.yml -- set_fact: - _delete_cartridge_cr_command: "{{ oc delete {{ _current_cartridge_cr.cr_cr }} --namespace {{ _p_current_cp4d_cluster.project }} --all }}" - -- name: Show ommand for delete cartridge CR - debug: - var: _delete_cartridge_cr_command - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Remove cartridge {{ _current_cartridge_cr.name }}" - _p_activity_command: "{{ _delete_cartridge_cr_command }}" - -- name: Remove cartridge {{ _current_cartridge_cr.name }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log - shell: | - {{ _delete_cartridge_cr_command }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log 2>&1 - when: not cpd_dry_run \ No newline at end of file + _p_activity_description: Remove cartridge {{ _current_cartridge_cr.name }} in namespace {{ _p_current_cp4d_cluster.project }} + _p_activity_command: "oc delete {{ _current_cartridge_cr.cr_cr }} --namespace {{ _p_current_cp4d_cluster.project }} --all >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log 2>&1" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml index c504645b9..5cc2807fd 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml @@ -87,16 +87,11 @@ _p_preview_script: False - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create catalog sources for {{ _p_catsrc_scope }}" + _p_activity_description: Create catalog sources for {{ _p_catsrc_scope }} _p_activity_command: "{{ _apply_olm_command }}" -- name: Run apply-olm command to create catalog sources for {{ _p_catsrc_scope }}, logs are in {{ status_dir }}/log/apply-olm-create-catsrc-{{ _p_catsrc_scope }}.log - shell: | - {{ _apply_olm_command }} > {{ status_dir }}/log/apply-olm-create-catsrc{{ _p_catsrc_scope }}.log 2>&1 - when: not cpd_dry_run - - name: If not air-gapped, copy case files from /tmp/work/offline to {{ status_dir }}/cp4d/offline copy: src: /tmp/work/offline diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/templates/apply-olm-create-catsrc.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/templates/apply-olm-create-catsrc.j2 index 2f6957fc5..6cc2bdf31 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/templates/apply-olm-create-catsrc.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/templates/apply-olm-create-catsrc.j2 @@ -5,4 +5,4 @@ --cpd_operator_ns={{ _p_current_cp4d_cluster.operators_project }} \ --preview={%- if _p_preview_script -%}true{%- else -%}false{%- endif %} \ --upgrade={%- if _upgrade_cp4d -%}true{%- else -%}false{%- endif %} \ - --components={{ _catsrc_cartridges_to_install_list }} \ No newline at end of file + --components={{ _catsrc_cartridges_to_install_list }} > {{ status_dir }}/log/apply-olm-create-catsrc{{ _p_catsrc_scope }}.log 2>&1 \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml index 58e0a7187..f43ea8df5 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml @@ -46,29 +46,24 @@ _p_preview_script: False - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Run apply-cr to install Cloud Pak for Data platform" + _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) ... +# 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 \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml index 8a0a4d559..bdc43df6f 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml @@ -35,16 +35,11 @@ _deploy_knative_eventing_command: "{{ lookup('template','deploy-knative-eventing.j2') }}" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Deploy KNative eventing" + _p_activity_description: Deploy KNative eventing, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log _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: | - {{ _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' - (_knative_eventing_dependency | default(False)) \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml index 230000c13..b5a57e150 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml @@ -8,33 +8,17 @@ fail: msg="cloud_platform {{ cloud_platform }} is not implemented, current implemented cloud platforms are {{ implemented_cloud_platform_types }} " when: "cloud_platform not in implemented_cloud_platform_types" -- set_fact: - _create_operators_project: "oc new-project {{ current_cp4d_cluster.operators_project }} | true" - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create oeprators project {{ current_cp4d_cluster.operators_project }}" - _p_activity_command: "{{ _create_operators_project }}" - -- name: Create operators project {{ current_cp4d_cluster.operators_project }} - shell: | - {{ _create_operators_project }} - when: not cpd_dry_run - -- set_fact: - _create_instance_project: "oc new-project {{ current_cp4d_cluster.project }} | true" + _p_activity_description: Create operators project {{ current_cp4d_cluster.operators_project }} + _p_activity_command: "oc new-project {{ current_cp4d_cluster.operators_project }} || true" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create instance project {{ current_cp4d_cluster.project }}" - _p_activity_command: "{{ _create_instance_project }}" - -- name: Create instance project {{ current_cp4d_cluster.project }} - shell: | - {{ _create_instance_project }} - when: not cpd_dry_run + _p_activity_description: Create instance project {{ current_cp4d_cluster.project }} + _p_activity_command: "oc new-project {{ current_cp4d_cluster.project }} || true" # Set configmap to control if Db2U must run with elevated or limited privileges - include_tasks: cp4d-db2u-configmap.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/apply-cr-cpd-platform.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/apply-cr-cpd-platform.j2 index 261788e29..52f36c3b8 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/apply-cr-cpd-platform.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/apply-cr-cpd-platform.j2 @@ -7,4 +7,4 @@ apply-cr \ --cpd_instance_ns={{ current_cp4d_cluster.project }} \ --components=cpfs,cpd_platform \ --file_storage_class={{ ocp_storage_class_file }} --block_storage_class={{ ocp_storage_class_block }} \ - --param-file={{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-install-options.yml \ No newline at end of file + --param-file={{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-install-options.yml > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-cr-cpd-platform.log 2>&1 \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 index d932103b7..0d32ff195 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 @@ -1,3 +1,3 @@ deploy-knative-eventing \ --release={{ current_cp4d_cluster.cp4d_version }} \ - --block_storage_class={{ ocp_storage_class_block }} \ No newline at end of file + --block_storage_class={{ ocp_storage_class_block }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml index d4e15aa9a..83231cd31 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml @@ -4,12 +4,7 @@ _apply_scheduler_command: "{{ lookup('template','apply-scheduler.j2') }}" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Apply scheduler" - _p_activity_command: "{{ _apply_scheduler_command }}" - -- name: Install scheduler, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log - shell: | - {{ _apply_scheduler_command }} > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log - when: not cpd_dry_run \ No newline at end of file + _p_activity_description: Apply scheduler, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log + _p_activity_command: "{{ _apply_scheduler_command }}" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml index 573cb68b9..fd3b95545 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml @@ -1,14 +1,6 @@ --- -- name: Generate delete scheduler command - set_fact: - _delete_scheduler_command: "oc delete Scheduling ibm-cpd-scheduler -n {{ _scheduler_project }} --ignore-not-found --wait=true || true" - - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Delete scheduler" - _p_activity_command: "{{ _delete_scheduler_command }}" - -- name: Uninstall scheduling service from project {{ _scheduler_project }} - shell: | - {{ _delete_scheduler_command }} \ No newline at end of file + _p_activity_description: Uninstall scheduling service from project {{ _scheduler_project }} + _p_activity_command: "oc delete Scheduling ibm-cpd-scheduler -n {{ _scheduler_project }} --ignore-not-found --wait=true || true" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 index 7f878022a..635528d28 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 @@ -1,4 +1,4 @@ apply-scheduler \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --license_acceptance=true \ - --scheduler_ns={{ scheduling_service_project }} + --scheduler_ns={{ scheduling_service_project }} > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml index 150dd6560..d7bf4828b 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-global-pull-secret/tasks/apply-global-pull-secret-private.yml @@ -10,11 +10,11 @@ - include_role: name: log-deployer-activity vars: - _p_activity_description: "Set global pull secret for private registry {{ _p_registry_url }}" - _p_activity_command: "{{ _aadd_cred_globl_pull_secret_command }}" + _p_activity_description: Set global pull secret for private registry {{ _p_registry_url }} + _p_activity_command: "{{ _add_cred_global_pull_secret_command }}" - name: Set global pull secret for private registry {{ _p_registry_url }}, output is in {{ status_dir }}/log/add-cred-to-global-pull-secret.log shell: | set -o pipefail - {{ _aadd_cred_globl_pull_secret_command }} | tee -a {{ status_dir }}/log/add-cred-to-global-pull-secret.log + {{ _add_cred_global_pull_secret_command }} | tee -a {{ status_dir }}/log/add-cred-to-global-pull-secret.log when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml index 808ea726a..d656e4e74 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml @@ -1,5 +1,5 @@ --- -- name: Write deployer script file to {{ status_dir }}/log/deployer-actitivies.log +- name: Write deployer script file {{ _p_activity_script }} to {{ status_dir }}/log/deployer-actitivies.log blockinfile: path: "{{ status_dir }}/log/deployer-actitivies.log" create: True diff --git a/automation-roles/99-generic/deployer/run-command/tasks/main.yml b/automation-roles/99-generic/deployer/run-command/tasks/main.yml new file mode 100644 index 000000000..5bc5be85d --- /dev/null +++ b/automation-roles/99-generic/deployer/run-command/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "{{ _p_activity_description }}" + _p_activity_command: "{{ _p_activity_command }}" + +- name: "Run command: {{ _p_activity_command }}" + shell: | + {{ _p_activity_command }} + when: not cpd_dry_run \ No newline at end of file From d3758d0c29804c7fd55250320d069e4c11e5b90c Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Sat, 30 Nov 2024 06:49:09 +0100 Subject: [PATCH 35/51] #820 Refactor run-command --- .../demo-openldap/tasks/install-openldap.yml | 4 +- .../demo-openldap/tasks/remove-openldap.yml | 4 +- .../nfd-operator/tasks/main.yml | 4 +- .../nvidia-operator/tasks/main.yml | 4 +- .../odf-operator/tasks/main.yml | 4 +- .../openshift-adp/tasks/main.yml | 8 +-- .../openshift-console-banner/tasks/main.yaml | 4 +- .../tasks/cp4d-apply-single-entitlement.yml | 19 ++---- .../cp4d-install-cartridges-olm-utils.yml | 61 +++++++++---------- .../tasks/cp4d-install-cr-dp.yml | 50 +++++++-------- .../tasks/cp4d-prep-watsonx-orchestrate.yml | 9 +-- .../tasks/cp4d-set-cartridge-options.yml | 2 +- .../tasks/cp4d-set-cartridge-scaling.yml | 4 +- .../tasks/cp4d-setup-mcg-secrets.yml | 4 +- .../templates/setup-mcg.j2 | 2 +- .../tasks/cp4d-remove-cr.yml | 5 +- .../tasks/create-catalog-source-olm-utils.yml | 5 +- .../templates/apply-olm-create-catsrc.j2 | 4 +- .../tasks/install-control-plane-olm-utils.yml | 5 +- .../tasks/openshift-install-knative.yml | 5 +- .../tasks/openshift-prepare-project.yml | 8 +-- .../templates/apply-cr-cpd-platform.j2 | 2 +- .../templates/deploy-knative-eventing.j2 | 2 +- .../tasks/install-scheduler.yml | 5 +- .../tasks/uninstall-scheduler.yml | 4 +- .../templates/apply-scheduler.j2 | 2 +- .../deployer/run-command/tasks/main.yml | 13 ++-- .../tasks/run-command-with-log-file.yml | 14 +++++ .../run-command/tasks/run-command.yml | 13 ++++ 29 files changed, 142 insertions(+), 128 deletions(-) create mode 100644 automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml create mode 100644 automation-roles/99-generic/deployer/run-command/tasks/run-command.yml diff --git a/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml b/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml index 42cd6af83..b8ce6d8de 100644 --- a/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml +++ b/automation-roles/40-configure-infra/demo-openldap/tasks/install-openldap.yml @@ -45,8 +45,8 @@ - include_role: name: run-command vars: - _p_activity_description: Create project {{ _openldap_project_name }} - _p_activity_command: "oc adm new-project {{ _openldap_project_name }} || true" + _p_command_description: Create project {{ _openldap_project_name }} + _p_command: "oc adm new-project {{ _openldap_project_name }} || true" - name: Prepare OpenLDAP yaml file for cluster {{ current_openshift_cluster.name }} ansible.builtin.template: diff --git a/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml b/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml index a037f0583..3c1fbabb9 100644 --- a/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml +++ b/automation-roles/40-configure-infra/demo-openldap/tasks/remove-openldap.yml @@ -1,5 +1,5 @@ - include_role: name: run-command vars: - _p_activity_description: Delete project {{ _openldap_project_name }} - _p_activity_command: "oc delete ns {{ _openldap_project_name }} --ignore-not-found" \ No newline at end of file + _p_command_description: Delete project {{ _openldap_project_name }} + _p_command: "oc delete ns {{ _openldap_project_name }} --ignore-not-found" \ No newline at end of file diff --git a/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml b/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml index 5e53ef714..d1c492b0a 100644 --- a/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/nfd-operator/tasks/main.yml @@ -2,8 +2,8 @@ - include_role: name: run-command vars: - _p_activity_description: Create Node Feature Discovery operator namespace - _p_activity_command: "oc create ns openshift-nfd || true" + _p_command_description: Create Node Feature Discovery operator namespace + _p_command: "oc create ns openshift-nfd || true" - name: Retrieve default channel for Node Feature Discovery manifest shell: diff --git a/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml b/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml index 1738dca7d..42627d6c3 100644 --- a/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/nvidia-operator/tasks/main.yml @@ -2,8 +2,8 @@ - include_role: name: run-command vars: - _p_activity_description: Create NVIDIA operator namespace nvidia-gpu-operator - _p_activity_command: "oc create ns nvidia-gpu-operator || true" + _p_command_description: Create NVIDIA operator namespace nvidia-gpu-operator + _p_command: "oc create ns nvidia-gpu-operator || true" - name: Retrieve default channel for the NVIDIA GPU manifest shell: diff --git a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml index 5d872500e..37fdda56d 100644 --- a/automation-roles/40-configure-infra/odf-operator/tasks/main.yml +++ b/automation-roles/40-configure-infra/odf-operator/tasks/main.yml @@ -22,8 +22,8 @@ - include_role: name: run-command vars: - _p_activity_description: Create OpenShift project openshift-storage - _p_activity_command: "oc create ns openshift-storage || true" + _p_command_description: Create OpenShift project openshift-storage + _p_command: "oc create ns openshift-storage || true" - name: Retrieve default channel for ocs-operator manifest shell: diff --git a/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml b/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml index cd84cc4f1..13a7f9b8c 100644 --- a/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml +++ b/automation-roles/40-configure-infra/openshift-adp/tasks/main.yml @@ -8,14 +8,14 @@ - include_role: name: run-command vars: - _p_activity_description: Create project openshift-adp - _p_activity_command: "oc create ns openshift-adp || true" + _p_command_description: Create project openshift-adp + _p_command: "oc create ns openshift-adp || true" - include_role: name: run-command vars: - _p_activity_description: Annotate project openshift-adp - _p_activity_command: "oc annotate namespace openshift-adp openshift.io/node-selector= --overwrite" + _p_command_description: Annotate project openshift-adp + _p_command: "oc annotate namespace openshift-adp openshift.io/node-selector= --overwrite" - name: Retrieve default channel for redhad-oadp-operator manifest shell: diff --git a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml index 62fa6b675..5a10db96e 100644 --- a/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml +++ b/automation-roles/40-configure-infra/openshift-console-banner/tasks/main.yaml @@ -10,6 +10,6 @@ - include_role: name: run-command vars: - _p_activity_description: Delete OpenShift console banner - _p_activity_command: oc delete ConsoleNotification cpd-console-banner --ignore-not-found + _p_command_description: Delete OpenShift console banner + _p_command: oc delete ConsoleNotification cpd-console-banner --ignore-not-found when: (_p_openshift_cluster.console_banner | default ("")) == "" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/tasks/cp4d-apply-single-entitlement.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/tasks/cp4d-apply-single-entitlement.yml index f9ee67f91..106de97b4 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/tasks/cp4d-apply-single-entitlement.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-apply-entitlement/tasks/cp4d-apply-single-entitlement.yml @@ -1,22 +1,11 @@ --- -- name: Generate apply-entitlement script {{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-entitlement-{{ _p_entitlement }}.sh for entitlement {{ _p_entitlement }} - template: - src: apply-entitlement.j2 - dest: "{{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-apply-entitlement-{{ _p_entitlement }}.sh" - mode: u=rwx - - name: Generate apply-entitlement command for entitlement {{ _p_entitlement }} set_fact: _apply_entitlement_command: "{{ lookup('template','apply-entitlement.j2') }}" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Apply entitlement {{ _p_entitlement }}" - _p_activity_command: "{{ _apply_entitlement_command }}" - -- name: Apply entitlement {{ _p_entitlement }}, output is in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-entitlement.log - shell: | - set -o pipefail - {{ _apply_entitlement_command }} | tee -a {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-entitlement.log - when: not cpd_dry_run \ No newline at end of file + _p_command_description: Apply entitlement {{ _p_entitlement }} + _p_command: "{{ _apply_entitlement_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-entitlement.log" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml index 066f94a8d..c935110de 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml @@ -13,13 +13,11 @@ vars: _p_preview_script: True - - name: Show apply-cr command for install cartridges preview script - debug: - var: _apply_cr_command_script - - - name: Generate preview script to install cartridges, 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 + - include_role: + name: run-command + vars: + _p_command_description: Generate preview script to install cartridges + _p_command: "{{ _apply_cr_command_script }}" - name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.sh copy: @@ -46,34 +44,33 @@ debug: var: _apply_cr_command + - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Run apply-cr command to install cartridges" - _p_activity_command: "{{ _apply_cr_command }}" - -- block: - - name: Run apply-cr command to install cartridges, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log - shell: | - set -o pipefail - {{ _apply_cr_command }} > {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log 2>&1 - register: _install_cartridges_result - failed_when: False + _p_command_description: Run apply-cr command to install cartridges into project {{ _p_current_cp4d_cluster.project }} + _p_command: "{{ _apply_cr_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log" + _p_command_register_variable: _install_cartridges_result + _p_command_failed_when: False - - name: Fail if there was an error installing the cartridge(s) using apply-cr - fail: - msg: "{{ _install_cartridges_result }}" - when: - - _install_cartridges_result.rc!=0 - - not (cpd_test_cartridges | default(False) | bool) +- name: Fail if there was an error installing the cartridge(s) using apply-cr + fail: + msg: "{{ _install_cartridges_result }}" + when: + - _install_cartridges_result.rc!=0 + - not (cpd_test_cartridges | default(False) | bool) + - not cpd_dry_run - - set_fact: - _cp4d_cartridges_installed_successfully: False - when: _install_cartridges_result.rc!=0 +- set_fact: + _cp4d_cartridges_installed_successfully: False + when: + - _install_cartridges_result.rc!=0 + - not cpd_dry_run - - name: Wait for cartridges to finish installation - include_tasks: cp4d-wait-cartridges-ready.yml - loop: "{{ _apply_cr_cartridges | default([]) }}" - loop_control: - loop_var: _current_cp4d_cartridge +- name: Wait for cartridges to finish installation + include_tasks: cp4d-wait-cartridges-ready.yml + loop: "{{ _apply_cr_cartridges | default([]) }}" + loop_control: + loop_var: _current_cp4d_cartridge when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml index 4f266da88..f7b3fdb4d 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml @@ -15,9 +15,11 @@ 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log - shell: | - {{ _apply_cr_command_script }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log 2>&1 + - include_role: + name: run-command + vars: + _p_command_description: Generate preview script to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }} + _p_command: "{{ _apply_cr_command_script }}" - name: Copy script to {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-apply-cr-dp.sh copy: @@ -34,26 +36,24 @@ _p_preview_script: False - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }}" - _p_activity_command: "{{ _apply_cr_command }}" - -- block: - - 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log - shell: | - {{ _apply_cr_command }} >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.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: not cpd_dry_run \ No newline at end of file + _p_command_description: Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }} + _p_command: "{{ _apply_cr_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log" + _p_command_register_variable: _install_cartridges_result + _p_command_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) + - not cpd_dry_run + +- set_fact: + _cp4d_cartridges_installed_successfully: False + when: + - _install_cartridges_result.rc!=0 + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml index a0bcd6e33..cc767e46f 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml @@ -58,8 +58,8 @@ - include_role: name: run-command vars: - _p_activity_description: Create App Connect project {{ _app_connect.app_connect_project }} - _p_activity_command: "oc adn new-project {{ _app_connect.app_connect_project }} || true" + _p_command_description: Create App Connect project {{ _app_connect.app_connect_project }} + _p_command: "oc adm new-project {{ _app_connect.app_connect_project }} || true" - name: Generate command to create IBM App Connect catalog source set_fact: @@ -68,8 +68,9 @@ - include_role: name: run-command vars: - _p_activity_description: Create IBM App Connect catalog source - _p_activity_command: "{{ _create_app_connect_catsrc }}" + _p_command_description: Create IBM App Connect catalog source + _p_command: "{{ _create_app_connect_catsrc }}" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-setup-mcg.log" - include_role: name: generate-apply-yaml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml index b00546c70..621878357 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml @@ -12,5 +12,5 @@ name: run-command vars: _p_activity_description: Set cartridge options for {{ _current_cp4d_cartridge.CR_Kind }} - _p_activity_command: "{{ _set_cartridge_options }}" + _p_command: "{{ _set_cartridge_options }}" when: (_current_cp4d_cartridge.installation_options | default({})) != {} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml index 551096e03..bddb2848d 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-scaling.yml @@ -7,7 +7,7 @@ - include_role: name: run-command vars: - _p_activity_description: Set cartridge scaling for {{ _current_cp4d_cartridge.CR_Kind }} - _p_activity_command: "{{ _set_cartridge_scaling }}" + _p_command_description: Set cartridge scaling for {{ _current_cp4d_cartridge.CR_Kind }} + _p_command: "{{ _set_cartridge_scaling }}" when: (_current_cp4d_cartridge.size | default('')) != '' \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml index 7243d9ee4..e3ee2d939 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-setup-mcg-secrets.yml @@ -6,5 +6,5 @@ - include_role: name: run-command vars: - _p_activity_description: Set up Multicloud Object Gateway (MCG) secrets for {{ _current_cp4d_cartridge.olm_utils_name }} in CP4D project {{ _p_current_cp4d_cluster.project }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-setup-mcg.log - _p_activity_command: "{{ _setup_mcg_command }}" + _p_command_description: Set up Multicloud Object Gateway (MCG) secrets for {{ _current_cp4d_cartridge.olm_utils_name }} in CP4D project {{ _p_current_cp4d_cluster.project }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-setup-mcg.log + _p_command: "{{ _setup_mcg_command }}" diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-mcg.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-mcg.j2 index e6d392c60..337a5386c 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-mcg.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/setup-mcg.j2 @@ -3,4 +3,4 @@ setup-mcg \ --components={{ _current_cp4d_cartridge.olm_utils_name }} \ --cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \ --noobaa_account_secret={{ _current_cp4d_cartridge.noobaa_account_secret | default('noobaa-admin') }} \ - --noobaa_cert_secret={{ _current_cp4d_cartridge.noobaa_cert_secret | default('noobaa-s3-serving-cert') }} | tee {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-setup-mcg.log \ No newline at end of file + --noobaa_cert_secret={{ _current_cp4d_cartridge.noobaa_cert_secret | default('noobaa-s3-serving-cert') }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml index fae07ea4d..095f2ba6b 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml @@ -10,5 +10,6 @@ - include_role: name: run-command vars: - _p_activity_description: Remove cartridge {{ _current_cartridge_cr.name }} in namespace {{ _p_current_cp4d_cluster.project }} - _p_activity_command: "oc delete {{ _current_cartridge_cr.cr_cr }} --namespace {{ _p_current_cp4d_cluster.project }} --all >> {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log 2>&1" \ No newline at end of file + _p_command_description: Remove cartridge {{ _current_cartridge_cr.name }} in namespace {{ _p_current_cp4d_cluster.project }} + _p_command: "oc delete {{ _current_cartridge_cr.cr_cr }} --namespace {{ _p_current_cp4d_cluster.project }} --all" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log 2>&1 \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml index 5cc2807fd..f125a4ef1 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/tasks/create-catalog-source-olm-utils.yml @@ -89,8 +89,9 @@ - include_role: name: run-command vars: - _p_activity_description: Create catalog sources for {{ _p_catsrc_scope }} - _p_activity_command: "{{ _apply_olm_command }}" + _p_command_description: Create catalog sources for {{ _p_catsrc_scope }} + _p_command: "{{ _apply_olm_command }}" + _p_command_log_file: "{{ status_dir }}/log/apply-olm-create-catsrc{{ _p_catsrc_scope }}.log" - name: If not air-gapped, copy case files from /tmp/work/offline to {{ status_dir }}/cp4d/offline copy: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/templates/apply-olm-create-catsrc.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/templates/apply-olm-create-catsrc.j2 index 6cc2bdf31..bb5815405 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/templates/apply-olm-create-catsrc.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-catalog-source/templates/apply-olm-create-catsrc.j2 @@ -1,8 +1,8 @@ -/opt/ansible/bin/apply-olm \ +apply-olm \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --case_download={%- if cpd_airgap | default(False) | bool -%}false{%- else -%}true{%- endif %} \ --catsrc=true --sub=false \ --cpd_operator_ns={{ _p_current_cp4d_cluster.operators_project }} \ --preview={%- if _p_preview_script -%}true{%- else -%}false{%- endif %} \ --upgrade={%- if _upgrade_cp4d -%}true{%- else -%}false{%- endif %} \ - --components={{ _catsrc_cartridges_to_install_list }} > {{ status_dir }}/log/apply-olm-create-catsrc{{ _p_catsrc_scope }}.log 2>&1 \ No newline at end of file + --components={{ _catsrc_cartridges_to_install_list }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml index f43ea8df5..7bc0ed62f 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/install-control-plane-olm-utils.yml @@ -48,8 +48,9 @@ - include_role: name: run-command vars: - _p_activity_description: Run apply-cr to install Cloud Pak for Data platform - _p_activity_command: "{{ _apply_cr_command }}" + _p_command_description: Run apply-cr to install Cloud Pak for Data platform + _p_command: "{{ _apply_cr_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-cr-cpd-platform.log" # Wait for ZenService to be created (can take 10-15 minutes) - name: Wait for ZenService to be completed diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml index bdc43df6f..4d7f5d169 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml @@ -37,8 +37,9 @@ - include_role: name: run-command vars: - _p_activity_description: Deploy KNative eventing, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log - _p_activity_command: "{{ _deploy_knative_eventing_command }}" + _p_command_description: Deploy KNative eventing + _p_command: "{{ _deploy_knative_eventing_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log" when: - current_cp4d_cluster.cp4d_version >= '4.8.0' diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml index b5a57e150..5f9764647 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-prepare-project.yml @@ -11,14 +11,14 @@ - include_role: name: run-command vars: - _p_activity_description: Create operators project {{ current_cp4d_cluster.operators_project }} - _p_activity_command: "oc new-project {{ current_cp4d_cluster.operators_project }} || true" + _p_command_description: Create operators project {{ current_cp4d_cluster.operators_project }} + _p_command: "oc new-project {{ current_cp4d_cluster.operators_project }} || true" - include_role: name: run-command vars: - _p_activity_description: Create instance project {{ current_cp4d_cluster.project }} - _p_activity_command: "oc new-project {{ current_cp4d_cluster.project }} || true" + _p_command_description: Create instance project {{ current_cp4d_cluster.project }} + _p_command: "oc new-project {{ current_cp4d_cluster.project }} || true" # Set configmap to control if Db2U must run with elevated or limited privileges - include_tasks: cp4d-db2u-configmap.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/apply-cr-cpd-platform.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/apply-cr-cpd-platform.j2 index 52f36c3b8..261788e29 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/apply-cr-cpd-platform.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/apply-cr-cpd-platform.j2 @@ -7,4 +7,4 @@ apply-cr \ --cpd_instance_ns={{ current_cp4d_cluster.project }} \ --components=cpfs,cpd_platform \ --file_storage_class={{ ocp_storage_class_file }} --block_storage_class={{ ocp_storage_class_block }} \ - --param-file={{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-install-options.yml > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-cr-cpd-platform.log 2>&1 \ No newline at end of file + --param-file={{ status_dir }}/cp4d/{{ current_cp4d_cluster.project }}-install-options.yml \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 index 0d32ff195..d932103b7 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/templates/deploy-knative-eventing.j2 @@ -1,3 +1,3 @@ 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 \ No newline at end of file + --block_storage_class={{ ocp_storage_class_block }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml index 83231cd31..406058f4e 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/install-scheduler.yml @@ -6,5 +6,6 @@ - include_role: name: run-command vars: - _p_activity_description: Apply scheduler, output can be found in {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log - _p_activity_command: "{{ _apply_scheduler_command }}" \ No newline at end of file + _p_command_description: Apply scheduler + _p_command: "{{ _apply_scheduler_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml index fd3b95545..6a6a935d8 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/tasks/uninstall-scheduler.yml @@ -2,5 +2,5 @@ - include_role: name: run-command vars: - _p_activity_description: Uninstall scheduling service from project {{ _scheduler_project }} - _p_activity_command: "oc delete Scheduling ibm-cpd-scheduler -n {{ _scheduler_project }} --ignore-not-found --wait=true || true" \ No newline at end of file + _p_command_description: Uninstall scheduling service from project {{ _scheduler_project }} + _p_command: "oc delete Scheduling ibm-cpd-scheduler -n {{ _scheduler_project }} --ignore-not-found --wait=true || true" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 index 635528d28..7f878022a 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-scheduling-service/templates/apply-scheduler.j2 @@ -1,4 +1,4 @@ apply-scheduler \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --license_acceptance=true \ - --scheduler_ns={{ scheduling_service_project }} > {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-apply-scheduler.log + --scheduler_ns={{ scheduling_service_project }} diff --git a/automation-roles/99-generic/deployer/run-command/tasks/main.yml b/automation-roles/99-generic/deployer/run-command/tasks/main.yml index 5bc5be85d..aad6ee867 100644 --- a/automation-roles/99-generic/deployer/run-command/tasks/main.yml +++ b/automation-roles/99-generic/deployer/run-command/tasks/main.yml @@ -1,11 +1,6 @@ --- -- include_role: - name: log-deployer-activity - vars: - _p_activity_description: "{{ _p_activity_description }}" - _p_activity_command: "{{ _p_activity_command }}" +- include_tasks: run-command.yml + when: (_p_command_log_file | default('')) == '' -- name: "Run command: {{ _p_activity_command }}" - shell: | - {{ _p_activity_command }} - when: not cpd_dry_run \ No newline at end of file +- include_tasks: run-command-with-log-file.yml + when: (_p_command_log_file | default('')) != '' \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml b/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml new file mode 100644 index 000000000..22ba2db54 --- /dev/null +++ b/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml @@ -0,0 +1,14 @@ +--- +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "{{ _p_command_description }}" + _p_activity_command: "{{ _p_command }}" + +- name: "Run command: {{ _p_command }}, output is in file {{ _p_command_log_file }}" + shell: | + set -o pipefail + {{ _p_command }} 2>&1 | tee -a {{ _p_command_log_file }} + register: "{{ _p_command_register_variable | default(omit) }}" + failed_when: "{{ _p_command_failed_when | default(omit) }}" + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml b/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml new file mode 100644 index 000000000..78ba32f1f --- /dev/null +++ b/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml @@ -0,0 +1,13 @@ +--- +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "{{ _p_command_description }}" + _p_activity_command: "{{ _p_command }}" + +- name: "Run command: {{ _p_command }}" + shell: | + {{ _p_command }} + register: "{{ _p_command_register_variable | default(omit) }}" + failed_when: "{{ _p_command_failed_when | default(omit) }}" + when: not cpd_dry_run \ No newline at end of file From 2fee1fb4257d9affb2381cd6e6f16fee5dd32562 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Sat, 30 Nov 2024 06:57:00 +0100 Subject: [PATCH 36/51] #820 Register variabled --- .../deployer/run-command/tasks/run-command-with-log-file.yml | 2 +- .../99-generic/deployer/run-command/tasks/run-command.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml b/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml index 22ba2db54..4f8a6446a 100644 --- a/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml +++ b/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml @@ -9,6 +9,6 @@ shell: | set -o pipefail {{ _p_command }} 2>&1 | tee -a {{ _p_command_log_file }} - register: "{{ _p_command_register_variable | default(omit) }}" + register: "{{ _p_command_register_variable | default('_run_command_result') }}" failed_when: "{{ _p_command_failed_when | default(omit) }}" when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml b/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml index 78ba32f1f..73c974667 100644 --- a/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml +++ b/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml @@ -8,6 +8,6 @@ - name: "Run command: {{ _p_command }}" shell: | {{ _p_command }} - register: "{{ _p_command_register_variable | default(omit) }}" + register: "{{ _p_command_register_variable | default('_run_command_result') }}" failed_when: "{{ _p_command_failed_when | default(omit) }}" when: not cpd_dry_run \ No newline at end of file From ba013421e2893d091472a45032e4733f23dafe42 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Sat, 30 Nov 2024 05:58:13 +0000 Subject: [PATCH 37/51] #820 Start with clean activities log --- .../99-generic/deployer/log-deployer-activity/tasks/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml index 27ecb21d4..b0d2f9dac 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml @@ -5,6 +5,11 @@ - set_fact: _deployer_activity_sequence: "{{ (_deployer_activity_sequence | default(0)) | int + 1 }}" +- file: + path: "{{ status_dir }}/log/deployer-actitivies.log" + state: absent + when: _deployer_activity_sequence==1 + - include_tasks: log-deployer-command.yml when: _p_activity_command | default('') != '' From e1abb222728bb0eebab1abef37881b004efd89d6 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Sun, 1 Dec 2024 08:05:02 +0000 Subject: [PATCH 38/51] #820 Refactor run-command --- .../cp4d-install-cartridges-olm-utils.yml | 4 +++- .../tasks/cp4d-install-cr-dp.yml | 4 +++- .../tasks/cp4d-set-cartridge-options.yml | 2 +- .../deployer/run-command/tasks/main.yml | 18 ++++++++++++++++-- .../tasks/run-command-failed-when.yml | 13 +++++++++++++ .../run-command-with-log-file-failed-when.yml | 14 ++++++++++++++ .../tasks/run-command-with-log-file.yml | 3 +-- .../deployer/run-command/tasks/run-command.yml | 3 +-- 8 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 automation-roles/99-generic/deployer/run-command/tasks/run-command-failed-when.yml create mode 100644 automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file-failed-when.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml index c935110de..aa63762ae 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml @@ -51,9 +51,11 @@ _p_command_description: Run apply-cr command to install cartridges into project {{ _p_current_cp4d_cluster.project }} _p_command: "{{ _apply_cr_command }}" _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log" - _p_command_register_variable: _install_cartridges_result _p_command_failed_when: False +- set_fact: + _install_cartridges_result: "{{ _run_command_result }}" + - name: Fail if there was an error installing the cartridge(s) using apply-cr fail: msg: "{{ _install_cartridges_result }}" diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml index f7b3fdb4d..6b63feb03 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml @@ -41,9 +41,11 @@ _p_command_description: Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }} _p_command: "{{ _apply_cr_command }}" _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log" - _p_command_register_variable: _install_cartridges_result _p_command_failed_when: False +- set_fact: + _install_cartridges_result: "{{ _run_command_result }}" + - name: Fail if there was an error installing the cartridge {{ _current_cp4d_cartridge.olm_utils_name }} using apply-cr fail: msg: "{{ _install_cartridges_result }}" diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml index 621878357..c339201bd 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-set-cartridge-options.yml @@ -11,6 +11,6 @@ - include_role: name: run-command vars: - _p_activity_description: Set cartridge options for {{ _current_cp4d_cartridge.CR_Kind }} + _p_command_description: Set cartridge options for {{ _current_cp4d_cartridge.CR_Kind }} _p_command: "{{ _set_cartridge_options }}" when: (_current_cp4d_cartridge.installation_options | default({})) != {} \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/run-command/tasks/main.yml b/automation-roles/99-generic/deployer/run-command/tasks/main.yml index aad6ee867..4efb08caf 100644 --- a/automation-roles/99-generic/deployer/run-command/tasks/main.yml +++ b/automation-roles/99-generic/deployer/run-command/tasks/main.yml @@ -1,6 +1,20 @@ --- - include_tasks: run-command.yml - when: (_p_command_log_file | default('')) == '' + when: + - (_p_command_log_file | default('')) == '' + - not _p_command_failed_when is defined + +- include_tasks: run-command-failed-when.yml + when: + - (_p_command_log_file | default('')) == '' + - _p_command_failed_when is defined - include_tasks: run-command-with-log-file.yml - when: (_p_command_log_file | default('')) != '' \ No newline at end of file + when: + - (_p_command_log_file | default('')) != '' + - not _p_command_failed_when is defined + +- include_tasks: run-command-with-log-file-failed-when.yml + when: + - (_p_command_log_file | default('')) != '' + - _p_command_failed_when is defined \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/run-command/tasks/run-command-failed-when.yml b/automation-roles/99-generic/deployer/run-command/tasks/run-command-failed-when.yml new file mode 100644 index 000000000..5874f9591 --- /dev/null +++ b/automation-roles/99-generic/deployer/run-command/tasks/run-command-failed-when.yml @@ -0,0 +1,13 @@ +--- +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "{{ _p_command_description }}" + _p_activity_command: "{{ _p_command }}" + +- name: "Run command: {{ _p_command }}" + shell: | + {{ _p_command }} + register: _run_command_result + failed_when: "{{ _p_command_failed_when }}" + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file-failed-when.yml b/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file-failed-when.yml new file mode 100644 index 000000000..612f3eca0 --- /dev/null +++ b/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file-failed-when.yml @@ -0,0 +1,14 @@ +--- +- include_role: + name: log-deployer-activity + vars: + _p_activity_description: "{{ _p_command_description }}" + _p_activity_command: "{{ _p_command }}" + +- name: "Run command: {{ _p_command }}, output is in file {{ _p_command_log_file }}" + shell: | + set -o pipefail + {{ _p_command }} 2>&1 | tee -a {{ _p_command_log_file }} + register: _run_command_result + failed_when: "{{ _p_command_failed_when }}" + when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml b/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml index 4f8a6446a..02c7aa345 100644 --- a/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml +++ b/automation-roles/99-generic/deployer/run-command/tasks/run-command-with-log-file.yml @@ -9,6 +9,5 @@ shell: | set -o pipefail {{ _p_command }} 2>&1 | tee -a {{ _p_command_log_file }} - register: "{{ _p_command_register_variable | default('_run_command_result') }}" - failed_when: "{{ _p_command_failed_when | default(omit) }}" + register: _run_command_result when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml b/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml index 73c974667..4a342c627 100644 --- a/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml +++ b/automation-roles/99-generic/deployer/run-command/tasks/run-command.yml @@ -8,6 +8,5 @@ - name: "Run command: {{ _p_command }}" shell: | {{ _p_command }} - register: "{{ _p_command_register_variable | default('_run_command_result') }}" - failed_when: "{{ _p_command_failed_when | default(omit) }}" + register: _run_command_result when: not cpd_dry_run \ No newline at end of file From 9aafd05e21bd1fd350b6b1d9c347ec575a990c5c Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Sun, 1 Dec 2024 10:03:26 +0000 Subject: [PATCH 39/51] #820 Additional dry-run conditions --- .../cp4d-install-cartridges-olm-utils.yml | 37 +++++++++---------- .../tasks/cp4d-install-cr-dp.yml | 32 ++++++++-------- .../tasks/cp4d-install-cr-ws_runtime.yml | 16 ++++---- .../tasks/cp4d-install-separate-cr-apply.yml | 16 ++++---- .../tasks/cp4d-pre-wd.yml | 31 +++------------- .../tasks/cp4d-prep-watsonx-orchestrate.yml | 17 +++------ .../3-run/existing-openshift.md | 5 ++- 7 files changed, 63 insertions(+), 91 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml index aa63762ae..f62c0b611 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cartridges-olm-utils.yml @@ -53,26 +53,25 @@ _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-cr-cartridges.log" _p_command_failed_when: False -- set_fact: - _install_cartridges_result: "{{ _run_command_result }}" +- block: + - set_fact: + _install_cartridges_result: "{{ _run_command_result }}" -- name: Fail if there was an error installing the cartridge(s) using apply-cr - fail: - msg: "{{ _install_cartridges_result }}" - when: - - _install_cartridges_result.rc!=0 - - not (cpd_test_cartridges | default(False) | bool) - - not cpd_dry_run + - name: Fail if there was an error installing the cartridge(s) 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 - - not cpd_dry_run + - set_fact: + _cp4d_cartridges_installed_successfully: False + when: + - _install_cartridges_result.rc!=0 -- name: Wait for cartridges to finish installation - include_tasks: cp4d-wait-cartridges-ready.yml - loop: "{{ _apply_cr_cartridges | default([]) }}" - loop_control: - loop_var: _current_cp4d_cartridge + - name: Wait for cartridges to finish installation + include_tasks: cp4d-wait-cartridges-ready.yml + loop: "{{ _apply_cr_cartridges | default([]) }}" + loop_control: + loop_var: _current_cp4d_cartridge when: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml index 6b63feb03..bf43c0a20 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-dp.yml @@ -43,19 +43,19 @@ _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log" _p_command_failed_when: False -- set_fact: - _install_cartridges_result: "{{ _run_command_result }}" - -- 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) - - not cpd_dry_run - -- set_fact: - _cp4d_cartridges_installed_successfully: False - when: - - _install_cartridges_result.rc!=0 - - not cpd_dry_run \ No newline at end of file +- block: + - set_fact: + _install_cartridges_result: "{{ _run_command_result }}" + + - 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: not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml index cae9ec7b7..94a0a931d 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-cr-ws_runtime.yml @@ -42,18 +42,16 @@ _p_preview_script: False - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Install Watson Studio runtime {{ _ws_runtime }}" - _p_activity_command: "{{ _apply_ws_runtime_command }}" + _p_command_description: Run apply-cr command to install Watson Studio runtime {{ _ws_runtime }} + _p_command: "{{ _apply_ws_runtime_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log" + _p_command_failed_when: False - block: - - name: Run apply-cr command to install Watson Studio runtime {{ _ws_runtime }}, logs are in {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log - shell: | - set -o pipefail - {{ _apply_ws_runtime_command }} | tee -a {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-{{ _ws_runtime }}.log 2>&1 - register: _install_cartridges_result - failed_when: False + - set_fact: + _install_cartridges_result: "{{ _run_command_result }}" - name: Fail if there was an error installing the runtime {{ _ws_runtime }} using apply-cr fail: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml index a85b1d37f..a903ea521 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-install-separate-cr-apply.yml @@ -39,18 +39,16 @@ _p_preview_script: False - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Innstall cartridge {{ _current_cp4d_cartridge.olm_utils_name }}" - _p_activity_command: "{{ _apply_cr_command }}" + _p_command_description: Run apply-cr command to install cartridge {{ _current_cp4d_cartridge.olm_utils_name }} + _p_command: "{{ _apply_cr_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log" + _p_command_failed_when: False - block: - - 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 }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log - shell: | - set -o pipefail - {{ _apply_cr_command }} | tee -a {{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-{{ _current_cp4d_cartridge.olm_utils_name }}-apply-cr.log 2>&1 - register: _install_cartridges_result - failed_when: False + - set_fact: + _install_cartridges_result: "{{ _run_command_result }}" - name: Fail if there was an error installing the cartridge {{ _current_cp4d_cartridge.olm_utils_name }} using apply-cr fail: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml index 29db5d590..c800413b2 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml @@ -1,29 +1,10 @@ --- -- block: - - name: Prepare yaml file for network policy - template: - src: cpd-network-policy.j2 - dest: "{{ status_dir }}/cp4d/ccpd-network-policy-{{ current_cp4d_cluster.project }}.yml" - - - include_role: - name: log-deployer-activity - vars: - _p_activity_description: "Create network policy for Cloud Pak for Data on IBM Cloud" - _p_activity_yaml: "{{ status_dir }}/cp4d/ccpd-network-policy-{{ current_cp4d_cluster.project }}.yml" - - - name: Create Network Policy - shell: | - oc apply -f {{ status_dir }}/cp4d/ccpd-network-policy-{{ current_cp4d_cluster.project }}.yml - register: _network_policy_create_result - retries: 10 - delay: 30 - until: _network_policy_create_result.rc == 0 - 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 +- include_role: + name: generate-apply-yaml + vars: + _p_apply_yaml_description: Create network policy for Cloud Pak for Data on IBM Cloud + _p_apply_yaml_template: cpd-network-policy.j2 + _p_apply_yaml_output_file: "{{ status_dir }}/cp4d/ccpd-network-policy-{{ current_cp4d_cluster.project }}.yml" when: cloud_platform == "ibm-cloud" and _p_current_cp4d_cluster.cp4d_version >= "4.5.0" - include_tasks: cp4d-setup-mcg-secrets.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml index cc767e46f..37018ce93 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml @@ -21,19 +21,12 @@ var: _apply_olm_wxo_command - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create watsonx Orchestrate subscription" - _p_activity_command: "{{ _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 - when: not cpd_dry_run + _p_command_description: Run apply-olm command to install watsonx Orchestrate subscriptions + _p_command: "{{ _apply_olm_wxo_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-apply-olm-wxo.log" + _p_command_failed_when: False - set_fact: _app_connect: "{{ _current_cp4d_cartridge.app_connect }}" diff --git a/docs/src/10-use-deployer/3-run/existing-openshift.md b/docs/src/10-use-deployer/3-run/existing-openshift.md index 8fbab5891..e997afd70 100644 --- a/docs/src/10-use-deployer/3-run/existing-openshift.md +++ b/docs/src/10-use-deployer/3-run/existing-openshift.md @@ -4,7 +4,10 @@ When running the Cloud Pak Deployer on an existing OpenShift cluster, the follow - The OpenShift cluster is up and running with sufficient compute nodes - The appropriate storage class(es) have been pre-created -- You have cluster administrator permissions to OpenShift +- You have cluster administrator permissions to OpenShift (except when using `--dry-run`) + +!!! info + If you don't want to make changes to the OpenShift cluster and only want to review the steps deployer will run, you can use the `--dry-run` option with `cp-deploy.sh`. This will generate a log file `$STATUS_DIR/log/deployer-actitivies.log`, which lists the steps deployer will execute when running without `--dry-run`. Please note that the dry-run option has only been implemented for Cloud Pak for Data i.e. watsonx. !!! info You can also choose to run Cloud Pak Deployer as a job on the OpenShift cluster. This removes the dependency on a separate server or workstation to run the deployer. **Please note that you may need unrestricted OpenShift entitlements for this.** To run the deployer on OpenShift via the OpenShift console, see [Run on OpenShift using console](./existing-openshift-console.md) From 5e28328068fee37515ce849d11e1d89f89d13d50 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Mon, 2 Dec 2024 08:43:01 +0000 Subject: [PATCH 40/51] #820 Handle dry-run for destroy --- .../validate-variables-destroy/tasks/main.yml | 12 +++++------- .../cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml | 4 +++- .../cp4d/cp4d-cluster-delete/tasks/main.yml | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/automation-roles/10-validation/validate-variables-destroy/tasks/main.yml b/automation-roles/10-validation/validate-variables-destroy/tasks/main.yml index 0a87c3626..47722a7f7 100644 --- a/automation-roles/10-validation/validate-variables-destroy/tasks/main.yml +++ b/automation-roles/10-validation/validate-variables-destroy/tasks/main.yml @@ -18,19 +18,17 @@ - cloud_platform != 'existing-ocp' - include_tasks: ibmcloud-validate-variables.yml - when: - - cloud_platform == 'ibm-cloud' + when: cloud_platform == 'ibm-cloud' - include_tasks: aws-validate-variables.yml - when: - - cloud_platform == 'aws' + when: cloud_platform == 'aws' - include_tasks: azure-validate-variables.yml - when: - - cloud_platform == 'azure' + when: cloud_platform == 'azure' - name: Fail if destroy was not confirmed fail: msg: "Destroy was not confirmed with --confirm-destroy parameter or via global_config confirm_destroy property" when: - - _confirm_destroy | bool != True + - _confirm_destroy | bool != True + - not cpd_dry_run diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml index 095f2ba6b..36ac6981f 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-remove/tasks/cp4d-remove-cr.yml @@ -2,7 +2,9 @@ - name: Fail if destroy was not confirmed fail: msg: "Will not delete cartridge {{ _current_cartridge_cr.name }}. Destroy was not confirmed with --confirm-destroy parameter or global_config confirm_destroy property" - when: (_confirm_destroy | default(False) | bool) != True + when: + - (_confirm_destroy | default(False) | bool) != True + - not cpd_dry_run - name: Delete instances of {{ _current_cartridge_cr.name }} include_tasks: cp4d-delete-cr-instances.yml diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster-delete/tasks/main.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster-delete/tasks/main.yml index db122d0db..cf1b24dcf 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster-delete/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster-delete/tasks/main.yml @@ -3,7 +3,8 @@ fail: msg: "Destroy of Cloud Pak for Data cluster {{ _p_current_cp4d_cluster.project }} was not confirmed with --confirm-destroy parameter or via global_config confirm_destroy property" when: - - _confirm_destroy | bool != True + - _confirm_destroy | bool != True + - not cpd_dry_run - name: Login to the OpenShift cluster "{{ _p_current_cp4d_cluster.openshift_cluster_name }}" include_role: From c64f6e9e5b4f4e7dd388beabd41190b810a7a884 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Mon, 2 Dec 2024 20:15:31 +0000 Subject: [PATCH 41/51] #820 Fix wxo --- .../tasks/cp4d-prep-watsonx-orchestrate.yml | 20 ++++++++----------- .../config-samples/cp4d-503.yaml | 4 ++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml index 37018ce93..ecf8eea35 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml @@ -85,23 +85,19 @@ - name: Generate command to create IBM App Connect instance for watsonx Ochestrate set_fact: - _create_app_connect_instance: "{{ lookup('template', 'create-app-connect-instance.j2') }}" + _create_app_connect_instance: "{{ lookup('template', 'setup-app-connect.j2') }}" - include_role: - name: log-deployer-activity + name: run-command vars: - _p_activity_description: "Create App Connect instance for watsonx Orchestrate" - _p_activity_command: "{{ _create_app_connect_instance }}" - -- name: Create IBM App Connect instance for watsonx Orchestrate - shell: | - {{ _create_app_connect_instance }} - when: not cpd_dry_run - -- set_fact: - _cp4d_admin_password_vault_key_name: "cp4d_admin_{{ _p_current_cp4d_cluster.project| replace('-','_') }}_{{ _p_current_cp4d_cluster.openshift_cluster_name| replace('-','_') }}" + _p_command_description: Create App Connect instance for watsonx Orchestrate + _p_command: "{{ _create_app_connect_instance }}" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-app-connect-instance.log" - block: + - 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 diff --git a/sample-configurations/sample-dynamic/config-samples/cp4d-503.yaml b/sample-configurations/sample-dynamic/config-samples/cp4d-503.yaml index 45879f208..45f5eec3a 100644 --- a/sample-configurations/sample-dynamic/config-samples/cp4d-503.yaml +++ b/sample-configurations/sample-dynamic/config-samples/cp4d-503.yaml @@ -330,8 +330,8 @@ cp4d: description: watsonx.orchestrate app_connect: app_connect_project: ibm-app-connect - app_connect_case_version: 11.5.0 - app_connect_channel_version: v11.5 + app_connect_case_version: 12.2.1 + app_connect_channel_version: v12.2 state: removed - name: wca-ansible From 16d5d8a68514339d9cd0452388ad8bb776287952 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Mon, 2 Dec 2024 20:15:55 +0000 Subject: [PATCH 42/51] #820 Remove path from apply-cr --- .../cp4d/cp4d-cartridge-install/templates/apply-cr-dp.j2 | 2 +- .../cp4d/cp4d-cartridge-install/templates/apply-cr-separate.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-dp.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-dp.j2 index bf81b6ba8..e053b605e 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-dp.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-dp.j2 @@ -1,4 +1,4 @@ -/opt/ansible/bin/apply-cr \ +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 %} \ diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-separate.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-separate.j2 index 515bff5a0..6d5f53a7c 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-separate.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-separate.j2 @@ -1,4 +1,4 @@ -/opt/ansible/bin/apply-cr \ +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 %} \ From 8dd05d2a32421804a4fa35c8ff1d26f63d2089c2 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 05:43:00 +0000 Subject: [PATCH 43/51] #820 Remove /opt/ansible from command path --- .../cp4d-cartridge-install/templates/apply-olm-cartridge-wxo.j2 | 2 +- .../cp4d/cp4d-variables/templates/list-components-olm-utils.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-olm-cartridge-wxo.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-olm-cartridge-wxo.j2 index 1c64add7a..312bdfd7a 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-olm-cartridge-wxo.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-olm-cartridge-wxo.j2 @@ -1,4 +1,4 @@ -/opt/ansible/bin/apply-olm \ +apply-olm \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ --case_download=false \ --catsrc=false --sub=true \ diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-variables/templates/list-components-olm-utils.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-variables/templates/list-components-olm-utils.j2 index 4b837861e..be476c37c 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-variables/templates/list-components-olm-utils.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-variables/templates/list-components-olm-utils.j2 @@ -1,2 +1,2 @@ -/opt/ansible/bin/list-components \ +list-components \ --release={{ _p_current_cp4d_cluster.cp4d_version }} \ No newline at end of file From ba45b52ca7659bb2d3754982fb7b7edc1e4d9419 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 07:38:09 +0000 Subject: [PATCH 44/51] #820 Fix wxo command --- .../tasks/cp4d-prep-watsonx-orchestrate.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml index ecf8eea35..6ff748ba1 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-prep-watsonx-orchestrate.yml @@ -16,10 +16,6 @@ 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 - - include_role: name: run-command vars: From c7a984dda0895c2637a6660980e90d3e9310b3ef Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 07:38:22 +0000 Subject: [PATCH 45/51] #820 Fix apply cluster components --- .../cp-fs-cluster-components/tasks/main.yml | 37 ++++++++++--------- .../templates/apply-cluster-components.j2 | 4 -- .../templates/set-threads.j2 | 3 ++ .../generate-apply-yaml/tasks/main.yml | 3 +- 4 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/templates/set-threads.j2 diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/tasks/main.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/tasks/main.yml index e50a439a5..b90766598 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/tasks/main.yml @@ -24,20 +24,23 @@ _cert_manager_project: 'cert-manager' when: (_p_cert_manager | default('ibm')) != 'ibm' -- name: Generate apply-cluster-components script {{ _v_template_dest_directory }}/{{ _p_openshift_cluster_name }}-apply-cluster-components.sh - template: - src: apply-cluster-components.j2 - dest: "{{ _v_template_dest_directory }}/{{ _p_openshift_cluster_name }}-apply-cluster-components.sh" - mode: u+rwx - -- name: Run shell script to apply cluster components on OpenShift cluster {{ _p_openshift_cluster_name }}, logs are in {{ status_dir }}/log/{{ _p_openshift_cluster_name }}-apply-cluster-components.log - shell: | - {{ _v_template_dest_directory }}/{{ _p_openshift_cluster_name }}-apply-cluster-components.sh - when: - - not _p_preview - -- name: Set number of threads per core to {{ _threads_per_core }} - shell: | - oc patch ibmlicensing instance \ - --type=merge \ - -p '{"spec": {"features": {"hyperThreading": {"threadsPerCore" : {{ _threads_per_core }} }}}}' \ No newline at end of file +- name: Generate apply-cluster-components command + set_fact: + _apply_cluster_components_command: "{{ lookup('template', 'apply-cluster-components.j2') }}" + +- include_role: + name: run-command + vars: + _p_command_description: Apply cluster components for OpenShift cluster {{ _p_openshift_cluster_name }} + _p_command: "{{ _apply_cluster_components_command }}" + _p_command_log_file: "{{ status_dir }}/log/{{ _p_openshift_cluster_name }}-apply-cluster-components.log" + +- name: Generate command to set threads per core + set_fact: + _set_threads_per_core_command: "{{ lookup('template', 'set-threads.j2') }}" + +- include_role: + name: run-command + vars: + _p_command_description: Set threads per core to {{ _threads_per_core }} + _p_command: "{{ _set_threads_per_core_command }}" \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/templates/apply-cluster-components.j2 b/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/templates/apply-cluster-components.j2 index ee606d214..693d66fc8 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/templates/apply-cluster-components.j2 +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/templates/apply-cluster-components.j2 @@ -1,7 +1,3 @@ -#! /bin/bash -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ) - -set -o pipefail apply-cluster-components \ --release={{ _p_cp4d_version }} \ --license_acceptance=true \ diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/templates/set-threads.j2 b/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/templates/set-threads.j2 new file mode 100644 index 000000000..cde7961af --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-fs-cluster-components/templates/set-threads.j2 @@ -0,0 +1,3 @@ + oc patch ibmlicensing instance \ + --type=merge \ + -p '{"spec": {"features": {"hyperThreading": {"threadsPerCore" : {{ _threads_per_core }} }}}}' \ No newline at end of file diff --git a/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/main.yml b/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/main.yml index 4b0b8323d..b6d3728d0 100644 --- a/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/main.yml +++ b/automation-roles/99-generic/deployer/generate-apply-yaml/tasks/main.yml @@ -10,4 +10,5 @@ - name: "{{ _p_apply_yaml_description }} using file {{ _p_apply_yaml_output_file }}" shell: | - oc apply -f {{ _p_apply_yaml_output_file }} \ No newline at end of file + oc apply -f {{ _p_apply_yaml_output_file }} + when: not cpd_dry_run \ No newline at end of file From 940b0db1faf7a9c75092bed2a02b3a2dab1ece3e Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 15:19:16 +0000 Subject: [PATCH 46/51] #820 Retry knative eventing --- .../tasks/openshift-install-knative.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml index 4d7f5d169..d9802b24c 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cluster/tasks/openshift-install-knative.yml @@ -35,11 +35,19 @@ _deploy_knative_eventing_command: "{{ lookup('template','deploy-knative-eventing.j2') }}" - include_role: - name: run-command + name: log-deployer-activity vars: - _p_command_description: Deploy KNative eventing - _p_command: "{{ _deploy_knative_eventing_command }}" - _p_command_log_file: "{{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log" + _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: | + {{ _deploy_knative_eventing_command }} 2>&1 | tee {{ status_dir }}/log/{{ current_cp4d_cluster.project }}-deploy-knative-eventing.log + register: _deploy_knative_eventing + retries: 10 + delay: 15 + until: _deploy_knative_eventing.rc==0 + when: not cpd_dry_run when: - current_cp4d_cluster.cp4d_version >= '4.8.0' From a1ddec61a2ac778cf0f81895b8176dc751b647b6 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 15:45:33 +0000 Subject: [PATCH 47/51] #820 Completion message --- .../80-smoke-tests/deployer-show-info/tasks/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/automation-roles/80-smoke-tests/deployer-show-info/tasks/main.yml b/automation-roles/80-smoke-tests/deployer-show-info/tasks/main.yml index 29dfa7d80..3e2d98f4f 100644 --- a/automation-roles/80-smoke-tests/deployer-show-info/tasks/main.yml +++ b/automation-roles/80-smoke-tests/deployer-show-info/tasks/main.yml @@ -1,4 +1,7 @@ --- - name: Show deployer application info ansible.builtin.debug: - msg: "{{ lookup('file', status_dir + '/cloud-paks/cloud-pak-deployer-info.txt') }}" \ No newline at end of file + msg: "{{ lookup('file', status_dir + '/cloud-paks/cloud-pak-deployer-info.txt') }}" + +- ansible.builtin.debug: + msg: "Deployer activities are logged in {{ status_dir }}/log/deployer-activities.log" \ No newline at end of file From 6f78c9e8e90d4bc2e0e437e227fc459bbe639bb5 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 15:45:57 +0000 Subject: [PATCH 48/51] #820 Typo in activities output file --- .../log-deployer-activity/tasks/log-deployer-command.yml | 4 ++-- .../log-deployer-activity/tasks/log-deployer-comment.yml | 4 ++-- .../log-deployer-activity/tasks/log-deployer-script-file.yml | 4 ++-- .../log-deployer-activity/tasks/log-deployer-yaml-file.yml | 4 ++-- .../99-generic/deployer/log-deployer-activity/tasks/main.yml | 2 +- docs/src/10-use-deployer/3-run/existing-openshift.md | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-command.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-command.yml index 9fc58e3b6..244f6757c 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-command.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-command.yml @@ -1,7 +1,7 @@ --- -- name: Write deployer activity to {{ status_dir }}/log/deployer-actitivies.log +- name: Write deployer activity to {{ status_dir }}/log/deployer-activities.log blockinfile: - path: "{{ status_dir }}/log/deployer-actitivies.log" + path: "{{ status_dir }}/log/deployer-activities.log" create: True insertafter: EOF marker: "" diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-comment.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-comment.yml index d0fa0b3fc..cc0fa4f57 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-comment.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-comment.yml @@ -1,7 +1,7 @@ --- -- name: Write deployer activity to {{ status_dir }}/log/deployer-actitivies.log +- name: Write deployer activity to {{ status_dir }}/log/deployer-activities.log blockinfile: - path: "{{ status_dir }}/log/deployer-actitivies.log" + path: "{{ status_dir }}/log/deployer-activities.log" create: True insertafter: EOF marker: "" diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml index d656e4e74..ec495f22a 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-script-file.yml @@ -1,7 +1,7 @@ --- -- name: Write deployer script file {{ _p_activity_script }} to {{ status_dir }}/log/deployer-actitivies.log +- name: Write deployer script file {{ _p_activity_script }} to {{ status_dir }}/log/deployer-activities.log blockinfile: - path: "{{ status_dir }}/log/deployer-actitivies.log" + path: "{{ status_dir }}/log/deployer-activities.log" create: True insertafter: EOF marker: "" diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml index 0853d39b8..94a57d45e 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/log-deployer-yaml-file.yml @@ -1,7 +1,7 @@ --- -- name: Write deployer YAML file to {{ status_dir }}/log/deployer-actitivies.log +- name: Write deployer YAML file to {{ status_dir }}/log/deployer-activities.log blockinfile: - path: "{{ status_dir }}/log/deployer-actitivies.log" + path: "{{ status_dir }}/log/deployer-activities.log" create: True insertafter: EOF marker: "" diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml index b0d2f9dac..d0930f235 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml @@ -6,7 +6,7 @@ _deployer_activity_sequence: "{{ (_deployer_activity_sequence | default(0)) | int + 1 }}" - file: - path: "{{ status_dir }}/log/deployer-actitivies.log" + path: "{{ status_dir }}/log/deployer-activities.log" state: absent when: _deployer_activity_sequence==1 diff --git a/docs/src/10-use-deployer/3-run/existing-openshift.md b/docs/src/10-use-deployer/3-run/existing-openshift.md index e997afd70..d8372dff3 100644 --- a/docs/src/10-use-deployer/3-run/existing-openshift.md +++ b/docs/src/10-use-deployer/3-run/existing-openshift.md @@ -7,7 +7,7 @@ When running the Cloud Pak Deployer on an existing OpenShift cluster, the follow - You have cluster administrator permissions to OpenShift (except when using `--dry-run`) !!! info - If you don't want to make changes to the OpenShift cluster and only want to review the steps deployer will run, you can use the `--dry-run` option with `cp-deploy.sh`. This will generate a log file `$STATUS_DIR/log/deployer-actitivies.log`, which lists the steps deployer will execute when running without `--dry-run`. Please note that the dry-run option has only been implemented for Cloud Pak for Data i.e. watsonx. + If you don't want to make changes to the OpenShift cluster and only want to review the steps deployer will run, you can use the `--dry-run` option with `cp-deploy.sh`. This will generate a log file `$STATUS_DIR/log/deployer-activities.log`, which lists the steps deployer will execute when running without `--dry-run`. Please note that the dry-run option has only been implemented for Cloud Pak for Data i.e. watsonx. !!! info You can also choose to run Cloud Pak Deployer as a job on the OpenShift cluster. This removes the dependency on a separate server or workstation to run the deployer. **Please note that you may need unrestricted OpenShift entitlements for this.** To run the deployer on OpenShift via the OpenShift console, see [Run on OpenShift using console](./existing-openshift-console.md) From 5acc690e0ae92de51f92c8558070ba6f3b89879f Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 16:24:03 +0000 Subject: [PATCH 49/51] #820 Run DNS through dry-run --- .../configure-openshift-dns/tasks/main.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/automation-roles/40-configure-infra/configure-openshift-dns/tasks/main.yml b/automation-roles/40-configure-infra/configure-openshift-dns/tasks/main.yml index d3f5b68e7..d0dd46a62 100644 --- a/automation-roles/40-configure-infra/configure-openshift-dns/tasks/main.yml +++ b/automation-roles/40-configure-infra/configure-openshift-dns/tasks/main.yml @@ -4,11 +4,8 @@ that: - _p_upstream_dns is defined -- shell: | - echo '{{ lookup('template','dns.j2',convert_data=False) | string }}' - -- name: Patch the DNS custom resource - shell: - oc patch dns.operator/default \ - --type=json \ - -p '[{"op":"replace","path":"/spec/servers","value":{{ lookup('template','dns.j2',convert_data=False) }} }]' -o yaml \ No newline at end of file +- include_role: + name: run-command + vars: + _p_command_description: Patch the DNS custom resource + _p_command: oc patch dns.operator/default --type=json -p '[{"op":"replace","path":"/spec/servers","value":{{ lookup('template','dns.j2',convert_data=False) }} }]' -o yaml \ No newline at end of file From cd915ba235c6292f92e14760c40e0e3ae040d0b9 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 16:24:23 +0000 Subject: [PATCH 50/51] #820 Fix typo --- .../99-generic/deployer/log-deployer-activity/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml index d0930f235..7360eee0a 100644 --- a/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml +++ b/automation-roles/99-generic/deployer/log-deployer-activity/tasks/main.yml @@ -6,7 +6,7 @@ _deployer_activity_sequence: "{{ (_deployer_activity_sequence | default(0)) | int + 1 }}" - file: - path: "{{ status_dir }}/log/deployer-activities.log" + path: "{{ status_dir }}/log/deployer-activities.log" state: absent when: _deployer_activity_sequence==1 From cfa388109bed7d102765111055aa0a45ccb48ec3 Mon Sep 17 00:00:00 2001 From: Frank Ketelaars Date: Tue, 3 Dec 2024 16:24:45 +0000 Subject: [PATCH 51/51] #820 Dry-run for MCO --- .../cpfs/cp-ocp-mco-pause/tasks/pause-mco.yml | 12 ++++++++---- .../cpfs/cp-ocp-mco-resume/tasks/main.yml | 3 ++- .../cpfs/cp-ocp-mco-resume/tasks/resume-mco.yml | 8 +++++--- .../cp4d-configure-ssl-certificate/tasks/main.yml | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-pause/tasks/pause-mco.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-pause/tasks/pause-mco.yml index b06f770c8..e2b03ea68 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-pause/tasks/pause-mco.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-pause/tasks/pause-mco.yml @@ -31,12 +31,16 @@ - not _mco_exists - _existing_ocp_infra_type != 'ibm-roks' -- name: Pause the MachineConfig operator to disable rebooting of compute nodes - shell: | - oc patch --type=merge --patch='{"spec":{"paused":true}}' machineconfigpool/worker +- include_role: + name: run-command + vars: + _p_command_description: Pause the MachineConfig operator to disable rebooting of compute nodes + _p_command: oc patch --type=merge --patch='{"spec":{"paused":true}}' machineconfigpool/worker when: - _mco_exists - _existing_ocp_infra_type != 'aws-rosa' - include_tasks: non-mco-prepare-node-settings.yml - when: not _mco_exists \ No newline at end of file + when: + - not _mco_exists + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-resume/tasks/main.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-resume/tasks/main.yml index f36ae8a1d..82cbd6ff6 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-resume/tasks/main.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-resume/tasks/main.yml @@ -8,4 +8,5 @@ - name: Apply the node settings if the Machine Config Operator does not exist include_tasks: non-mco-apply-node-settings.yml when: - - not _mco_exists \ No newline at end of file + - not _mco_exists + - not cpd_dry_run \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-resume/tasks/resume-mco.yml b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-resume/tasks/resume-mco.yml index 4990746e2..821894ca3 100644 --- a/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-resume/tasks/resume-mco.yml +++ b/automation-roles/50-install-cloud-pak/cpfs/cp-ocp-mco-resume/tasks/resume-mco.yml @@ -1,7 +1,9 @@ --- -- name: Allow MachineConfig operator to reboot compute nodes again - shell: | - oc patch --type=merge --patch='{"spec":{"paused":false}}' machineconfigpool/worker +- include_role: + name: run-command + vars: + _p_command_description: Allow MachineConfig operator to reboot compute nodes again + _p_command: oc patch --type=merge --patch='{"spec":{"paused":false}}' machineconfigpool/worker - name: Get number of compute nodes shell: | diff --git a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/main.yml b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/main.yml index a42203c46..8c17a8336 100644 --- a/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/main.yml +++ b/automation-roles/60-configure-cloud-pak/cp4d/cp4d-configure-ssl-certificate/tasks/main.yml @@ -7,6 +7,7 @@ shell: | oc get -n openshift-ingress-operator ingresscontrollers/default -o jsonpath='{.spec.defaultCertificate.name}' register: _current_ingress_certificate_result + failed_when: False - set_fact: _current_certificate: "{{ _current_ingress_certificate_result.stdout }}"