From 2f2edda9277f5a159e8b7fdcaa8cdb586c1bc3d2 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 12 Mar 2026 19:49:36 +0100 Subject: [PATCH 1/4] Change the pattern operator subscription namespace under certain conditions If there already is a pattern-operator subscription in the openshift-operators then do nothing and stay with openshift-operators as a default. If it does not exist in that namespace then override it and put the subscription in the "pattern-operator" namespace. --- roles/install_settings/tasks/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/roles/install_settings/tasks/main.yml b/roles/install_settings/tasks/main.yml index b5e0e8b..015e019 100644 --- a/roles/install_settings/tasks/main.yml +++ b/roles/install_settings/tasks/main.yml @@ -56,6 +56,23 @@ else "" }} +- name: Check for existing patterns-operator subscription in openshift-operators + kubernetes.core.k8s_info: + api_version: operators.coreos.com/v1alpha1 + kind: Subscription + namespace: openshift-operators + name: patterns-operator + register: _existing_subscription + failed_when: false + +- name: Build subscription_namespace_opt + ansible.builtin.set_fact: + subscription_namespace_opt: >- + {{ + "" if (_existing_subscription.resources | default([]) | length > 0) + else "--set main.patternsOperator.subscriptionNamespace=pattern-operator" + }} + - name: Assemble _install_helm_opts ansible.builtin.set_fact: install_helm_opts: >- @@ -64,6 +81,7 @@ --set main.git.revision={{ target_branch }} {{ secret_opts }} {{ clustergroup_opt }} + {{ subscription_namespace_opt }} {{ uuid_helm_opts }} {{ extra_helm_opts }} {{ include_crds_opt }} From 4931ec5752b6a74880693230b3360531a9e64a19 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Thu, 12 Mar 2026 20:41:51 +0100 Subject: [PATCH 2/4] Only use the new namespace if the available pattern-operator version is > 0.0.65 and when there is no subscription in the openshift-operators ns --- roles/install_settings/tasks/main.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/roles/install_settings/tasks/main.yml b/roles/install_settings/tasks/main.yml index 015e019..49e64c3 100644 --- a/roles/install_settings/tasks/main.yml +++ b/roles/install_settings/tasks/main.yml @@ -65,12 +65,29 @@ register: _existing_subscription failed_when: false +- name: Get patterns-operator packagemanifest + kubernetes.core.k8s_info: + api_version: packages.operators.coreos.com/v1 + kind: PackageManifest + name: patterns-operator + namespace: openshift-marketplace + register: _pkg_manifest + failed_when: false + +- name: Determine available patterns-operator version + ansible.builtin.set_fact: + _patterns_operator_version: >- + {{ _pkg_manifest.resources[0].status.channels[0].currentCSVDesc.version | default('0.0.0') }} + when: _pkg_manifest.resources | default([]) | length > 0 + - name: Build subscription_namespace_opt ansible.builtin.set_fact: subscription_namespace_opt: >- {{ - "" if (_existing_subscription.resources | default([]) | length > 0) - else "--set main.patternsOperator.subscriptionNamespace=pattern-operator" + "--set main.patternsOperator.subscriptionNamespace=pattern-operator" + if ((_existing_subscription.resources | default([]) | length == 0) + and (_patterns_operator_version | default('0.0.0') is version('0.0.65', '>'))) + else "" }} - name: Assemble _install_helm_opts From a3969e97af662bc21d35bef8dafb08e946bf0a4e Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Fri, 13 Mar 2026 07:11:32 +0100 Subject: [PATCH 3/4] Make the packagemanifest fact setting more robust --- roles/install_settings/tasks/main.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/roles/install_settings/tasks/main.yml b/roles/install_settings/tasks/main.yml index 49e64c3..88e5dec 100644 --- a/roles/install_settings/tasks/main.yml +++ b/roles/install_settings/tasks/main.yml @@ -75,9 +75,13 @@ failed_when: false - name: Determine available patterns-operator version + vars: + _manifest: "{{ _pkg_manifest.resources[0] | default({}) }}" + _channels: "{{ (_manifest.status | default({})).channels | default([]) }}" + _first_channel: "{{ _channels[0] if _channels else {} }}" + _csv_desc: "{{ _first_channel.currentCSVDesc | default({}) }}" ansible.builtin.set_fact: - _patterns_operator_version: >- - {{ _pkg_manifest.resources[0].status.channels[0].currentCSVDesc.version | default('0.0.0') }} + _patterns_operator_version: "{{ _csv_desc.version | default('0.0.0') }}" when: _pkg_manifest.resources | default([]) | length > 0 - name: Build subscription_namespace_opt From 45992178d4dc917024e5f23e51438fa67792be40 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Fri, 13 Mar 2026 09:13:08 +0100 Subject: [PATCH 4/4] Add a comment explaining some reasoning --- roles/install_settings/tasks/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roles/install_settings/tasks/main.yml b/roles/install_settings/tasks/main.yml index 88e5dec..9db49ac 100644 --- a/roles/install_settings/tasks/main.yml +++ b/roles/install_settings/tasks/main.yml @@ -84,6 +84,10 @@ _patterns_operator_version: "{{ _csv_desc.version | default('0.0.0') }}" when: _pkg_manifest.resources | default([]) | length > 0 +# So 0.0.65 is the last version of the pattern-operator that deployed by default into +# openshift-operators namespace. Starting with 0.0.66 if there is no existing pattern-operator +# subscription in the openshift-operators namespace we want to default to the +# pattern-operator namespace to install our subscription (and our operator) - name: Build subscription_namespace_opt ansible.builtin.set_fact: subscription_namespace_opt: >-