From 58535757a3563a09291fda5dc2fb712b7bd47c30 Mon Sep 17 00:00:00 2001 From: Amartya Sinha Date: Fri, 5 Dec 2025 15:28:22 +0530 Subject: [PATCH] [multiple] Consolidate operator_namespace var to group_vars Move all the definitions and hardcoding of operator_namespace so that it can be easily changed and managed from group_vars. Signed-off-by: Amartya Sinha --- group_vars/all.yml | 2 ++ roles/kustomize_deploy/tasks/install_operators.yml | 4 ++-- roles/kustomize_deploy/tasks/install_plan.yml | 6 +++--- roles/os_must_gather/defaults/main.yml | 2 +- roles/run_hook/tasks/playbook.yml | 6 ------ roles/set_openstack_containers/tasks/main.yml | 8 +++----- roles/update/tasks/main.yml | 4 ++-- 7 files changed, 13 insertions(+), 19 deletions(-) diff --git a/group_vars/all.yml b/group_vars/all.yml index b55c0b3931..6570f04bfa 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -10,3 +10,5 @@ cifmw_installyamls_repos_relative: src/github.com/openstack-k8s-operators/instal cifmw_installyamls_repos: "{{ ansible_user_dir }}/{{ cifmw_installyamls_repos_relative }}" cifmw_architecture_repo_relative: src/github.com/openstack-k8s-operators/architecture cifmw_architecture_repo: "{{ ansible_user_dir }}/{{ cifmw_architecture_repo_relative }}" + +operator_namespace: "{{ cifmw_install_yamls_defaults['OPERATOR_NAMESPACE'] | default('openstack-operators') }}" diff --git a/roles/kustomize_deploy/tasks/install_operators.yml b/roles/kustomize_deploy/tasks/install_operators.yml index d4a76c7367..031a5ffbff 100644 --- a/roles/kustomize_deploy/tasks/install_operators.yml +++ b/roles/kustomize_deploy/tasks/install_operators.yml @@ -438,7 +438,7 @@ kubeconfig: "{{ cifmw_openshift_kubeconfig }}" api_version: "operator.openstack.org/v1beta1" kind: OpenStack - namespace: openstack-operators + namespace: "{{ operator_namespace }}" name: openstack wait: true wait_condition: @@ -462,7 +462,7 @@ kubernetes.core.k8s_info: kubeconfig: "{{ cifmw_openshift_kubeconfig }}" kind: Deployment - namespace: openstack-operators + namespace: "{{ operator_namespace }}" label_selectors: - "{{ item }}" wait: true diff --git a/roles/kustomize_deploy/tasks/install_plan.yml b/roles/kustomize_deploy/tasks/install_plan.yml index 2bd19de0dc..cc49f21fe0 100644 --- a/roles/kustomize_deploy/tasks/install_plan.yml +++ b/roles/kustomize_deploy/tasks/install_plan.yml @@ -24,7 +24,7 @@ context: "{{ cifmw_openshift_context | default(omit) }}" api_version: operators.coreos.com/v1alpha1 kind: InstallPlan - namespace: openstack-operators + namespace: "{{ operator_namespace }}" register: _cifmw_kustomize_deploy_install_plans until: > _cifmw_kustomize_deploy_install_plans.resources | @@ -50,7 +50,7 @@ api_key: "{{ cifmw_openshift_token | default(omit) }}" context: "{{ cifmw_openshift_context | default(omit) }}" state: present - namespace: openstack-operators + namespace: "{{ operator_namespace }}" definition: apiVersion: operators.coreos.com/v1alpha1 kind: InstallPlan @@ -70,7 +70,7 @@ context: "{{ cifmw_openshift_context | default(omit) }}" api_version: operators.coreos.com/v1alpha1 kind: InstallPlan - namespace: openstack-operators + namespace: "{{ operator_namespace }}" name: "{{ _cifmw_kustomize_deploy_installplan_name }}" register: _cifmw_kustomize_deploy_installplan until: diff --git a/roles/os_must_gather/defaults/main.yml b/roles/os_must_gather/defaults/main.yml index 458c1c08a9..529469373a 100644 --- a/roles/os_must_gather/defaults/main.yml +++ b/roles/os_must_gather/defaults/main.yml @@ -26,7 +26,7 @@ cifmw_os_must_gather_repo_path: "{{ ansible_user_dir }}/src/github.com/openstack cifmw_os_must_gather_timeout: "30m" cifmw_os_must_gather_additional_namespaces: "kuttl,openshift-storage,openshift-marketplace,openshift-operators,sushy-emulator,tobiko" cifmw_os_must_gather_namespaces: - - openstack-operators + - "{{ operator_namespace }}" - openstack - baremetal-operator-system - openshift-machine-api diff --git a/roles/run_hook/tasks/playbook.yml b/roles/run_hook/tasks/playbook.yml index 5f6e79afd8..bdd4377826 100644 --- a/roles/run_hook/tasks/playbook.yml +++ b/roles/run_hook/tasks/playbook.yml @@ -14,11 +14,6 @@ {%- endif -%} _bdir: >- {{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }} - _operator_namespace: >- - {{ - cifmw_install_yamls_defaults['OPERATOR_NAMESPACE'] | - default('openstack-operators') - }} _namespace: >- {{ cifmw_install_yamls_defaults['NAMESPACE'] | @@ -31,7 +26,6 @@ log_path: >- {{ _bdir }}/logs/{{ step }}_{{ _hook_name }}.log extra_vars: >- - -e operator_namespace={{ _operator_namespace }} -e namespace={{ _namespace}} {%- if hook.extra_vars is defined and hook.extra_vars|length > 0 -%} {% for key,value in hook.extra_vars.items() -%} diff --git a/roles/set_openstack_containers/tasks/main.yml b/roles/set_openstack_containers/tasks/main.yml index 9fb4bc5212..614b076388 100644 --- a/roles/set_openstack_containers/tasks/main.yml +++ b/roles/set_openstack_containers/tasks/main.yml @@ -37,11 +37,6 @@ - name: Set common facts for the role ansible.builtin.set_fact: operator_name: "{{ cifmw_set_openstack_containers_operator_name }}" - operator_namespace: >- - {{ - cifmw_install_yamls_defaults['OPERATOR_NAMESPACE'] | - default(cifmw_set_openstack_containers_operators_namespace) - }} cifmw_set_openstack_containers_common_env: >- {{ ( cifmw_install_yamls_environment | @@ -59,6 +54,9 @@ output_dir: "{{ cifmw_set_openstack_containers_basedir }}/artifacts" script: "oc set env $(oc get pods -n {{ operator_namespace }} -o name -l openstack.org/operator-name={{ operator_name }}) -n {{ operator_namespace }} --list" register: containers_env_list + until: containers_env_list.rc == 0 + retries: 10 + delay: 5 - name: Generate update_env_vars.sh script ansible.builtin.template: diff --git a/roles/update/tasks/main.yml b/roles/update/tasks/main.yml index 627475977e..536fda0112 100644 --- a/roles/update/tasks/main.yml +++ b/roles/update/tasks/main.yml @@ -74,7 +74,7 @@ kind: OpenStack metadata: name: openstack - namespace: openstack-operators + namespace: "{{ operator_namespace }}" - name: Set update step to Wait for successful deployment of the openstack operator ansible.builtin.command: @@ -89,7 +89,7 @@ context: "{{ cifmw_openshift_context | default(omit) }}" api_version: operator.openstack.org/v1beta1 kind: OpenStack - namespace: openstack-operators + namespace: "{{ operator_namespace }}" register: _cifmw_update_openstack_info until: > _cifmw_update_openstack_info.resources[0].status.conditions is defined