diff --git a/roles/default/kiali-deploy/tasks/openshift/os-main.yml b/roles/default/kiali-deploy/tasks/openshift/os-main.yml index f36f207c..3ee5bfb5 100644 --- a/roles/default/kiali-deploy/tasks/openshift/os-main.yml +++ b/roles/default/kiali-deploy/tasks/openshift/os-main.yml @@ -4,6 +4,16 @@ when: - is_openshift == True +# If it is Removed, the web console is disabled. +# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html +- name: Determine if OpenShift Console is installed and enabled + vars: + console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}" + set_fact: + has_openshift_console: "{{ console_res | length > 0 and console_res[0].spec.managementState != 'Removed' }}" + when: + - is_openshift == True + - name: Create Kiali objects on OpenShift include_tasks: process-resource.yml vars: @@ -95,6 +105,8 @@ {% endfor %} when: - is_openshift == True + - has_openshift_console is defined + - has_openshift_console == True - no_longer_accessible_namespaces is defined - name: Process OpenShift Console Links diff --git a/roles/default/kiali-remove/tasks/main.yml b/roles/default/kiali-remove/tasks/main.yml index db9a36b8..b25bf9c4 100644 --- a/roles/default/kiali-remove/tasks/main.yml +++ b/roles/default/kiali-remove/tasks/main.yml @@ -239,6 +239,17 @@ when: - is_openshift == True +# If it is Removed, the web console is disabled. +# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html +- name: Determine if OpenShift Console is installed and enabled + ignore_errors: yes + vars: + console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}" + set_fact: + has_openshift_console: "{{ console_res | length > 0 and console_res[0].spec.managementState != 'Removed' }}" + when: + - is_openshift == True + - name: Delete OpenShift-specific Kiali ConsoleLinks ignore_errors: yes k8s: @@ -254,3 +265,5 @@ {% endfor %} when: - is_openshift == True + - has_openshift_console is defined + - has_openshift_console == True diff --git a/roles/default/ossmconsole-deploy/tasks/main.yml b/roles/default/ossmconsole-deploy/tasks/main.yml index 281f3cb0..2314e724 100644 --- a/roles/default/ossmconsole-deploy/tasks/main.yml +++ b/roles/default/ossmconsole-deploy/tasks/main.yml @@ -17,6 +17,17 @@ serviceNamespace: null servicePort: null +# There are three possible values for the console managementState: Managed, Unmanaged, and Removed. +# If it is Removed, the web console is disabled and thus we cannot install OSSMC so abort immediately. +# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html +- name: Ensure OpenShift Console is installed and enabled + vars: + console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}" + fail: + msg: "The OpenShift Console is not installed and enabled. Cannot install OSSMC." + when: + - console_res | length == 0 or console_res[0].spec.managementState == "Removed" + - name: Get information about the cluster set_fact: api_groups: "{{ lookup(k8s_plugin, cluster_info='api_groups') }}" diff --git a/roles/default/ossmconsole-remove/tasks/main.yml b/roles/default/ossmconsole-remove/tasks/main.yml index 9fc3d6df..1f9cb977 100644 --- a/roles/default/ossmconsole-remove/tasks/main.yml +++ b/roles/default/ossmconsole-remove/tasks/main.yml @@ -34,7 +34,7 @@ - name: Disable plugin by ensuring the OSSM Console is removed from the Console list of plugins ignore_errors: yes vars: - existing_plugins: "{{ lookup('kubernetes.core.k8s', resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console').spec.plugins | default([]) }}" + existing_plugins: "{{ lookup(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console').spec.plugins | default([]) }}" k8s: state: patched api_version: operator.openshift.io/v1 diff --git a/roles/v1.73/kiali-deploy/tasks/openshift/os-main.yml b/roles/v1.73/kiali-deploy/tasks/openshift/os-main.yml index f36f207c..3ee5bfb5 100644 --- a/roles/v1.73/kiali-deploy/tasks/openshift/os-main.yml +++ b/roles/v1.73/kiali-deploy/tasks/openshift/os-main.yml @@ -4,6 +4,16 @@ when: - is_openshift == True +# If it is Removed, the web console is disabled. +# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html +- name: Determine if OpenShift Console is installed and enabled + vars: + console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}" + set_fact: + has_openshift_console: "{{ console_res | length > 0 and console_res[0].spec.managementState != 'Removed' }}" + when: + - is_openshift == True + - name: Create Kiali objects on OpenShift include_tasks: process-resource.yml vars: @@ -95,6 +105,8 @@ {% endfor %} when: - is_openshift == True + - has_openshift_console is defined + - has_openshift_console == True - no_longer_accessible_namespaces is defined - name: Process OpenShift Console Links diff --git a/roles/v1.73/kiali-remove/tasks/main.yml b/roles/v1.73/kiali-remove/tasks/main.yml index db9a36b8..b25bf9c4 100644 --- a/roles/v1.73/kiali-remove/tasks/main.yml +++ b/roles/v1.73/kiali-remove/tasks/main.yml @@ -239,6 +239,17 @@ when: - is_openshift == True +# If it is Removed, the web console is disabled. +# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html +- name: Determine if OpenShift Console is installed and enabled + ignore_errors: yes + vars: + console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}" + set_fact: + has_openshift_console: "{{ console_res | length > 0 and console_res[0].spec.managementState != 'Removed' }}" + when: + - is_openshift == True + - name: Delete OpenShift-specific Kiali ConsoleLinks ignore_errors: yes k8s: @@ -254,3 +265,5 @@ {% endfor %} when: - is_openshift == True + - has_openshift_console is defined + - has_openshift_console == True diff --git a/roles/v1.73/ossmconsole-deploy/tasks/main.yml b/roles/v1.73/ossmconsole-deploy/tasks/main.yml index 281f3cb0..2314e724 100644 --- a/roles/v1.73/ossmconsole-deploy/tasks/main.yml +++ b/roles/v1.73/ossmconsole-deploy/tasks/main.yml @@ -17,6 +17,17 @@ serviceNamespace: null servicePort: null +# There are three possible values for the console managementState: Managed, Unmanaged, and Removed. +# If it is Removed, the web console is disabled and thus we cannot install OSSMC so abort immediately. +# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html +- name: Ensure OpenShift Console is installed and enabled + vars: + console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}" + fail: + msg: "The OpenShift Console is not installed and enabled. Cannot install OSSMC." + when: + - console_res | length == 0 or console_res[0].spec.managementState == "Removed" + - name: Get information about the cluster set_fact: api_groups: "{{ lookup(k8s_plugin, cluster_info='api_groups') }}" diff --git a/roles/v1.73/ossmconsole-remove/tasks/main.yml b/roles/v1.73/ossmconsole-remove/tasks/main.yml index 9fc3d6df..1f9cb977 100644 --- a/roles/v1.73/ossmconsole-remove/tasks/main.yml +++ b/roles/v1.73/ossmconsole-remove/tasks/main.yml @@ -34,7 +34,7 @@ - name: Disable plugin by ensuring the OSSM Console is removed from the Console list of plugins ignore_errors: yes vars: - existing_plugins: "{{ lookup('kubernetes.core.k8s', resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console').spec.plugins | default([]) }}" + existing_plugins: "{{ lookup(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console').spec.plugins | default([]) }}" k8s: state: patched api_version: operator.openshift.io/v1