diff --git a/collection/stages/roles/openstack_test/tasks/main.yml b/collection/stages/roles/openstack_test/tasks/main.yml index 0eaa57ce..bf9e11a6 100644 --- a/collection/stages/roles/openstack_test/tasks/main.yml +++ b/collection/stages/roles/openstack_test/tasks/main.yml @@ -12,10 +12,10 @@ - name: Run openstack-test block: - - name: Include vars from registered resources - ansible.builtin.include_vars: - file: "{{ resources_file }}" - name: resources + - name: Retrieve OpenShift API and Ingress IPs + ansible.builtin.include_role: + name: shiftstack.tools.tools_get_deploy_info + tasks_from: retrieve_openshift_ips.yml # DNS resolution management needed for RHOSO pods to be able to resolve # shift-on-stack cluster Apps endpoints (for telemetry tests the RHOSO diff --git a/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_api_ip.yml b/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_api_ip.yml new file mode 100644 index 00000000..a5b552d2 --- /dev/null +++ b/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_api_ip.yml @@ -0,0 +1,24 @@ +--- +# Retrieve OpenShift API IP + +- name: Get OpenShift API hostname (strip port) + ansible.builtin.shell: >- + set -o pipefail && + oc get infrastructure cluster -o jsonpath='{.status.apiServerURL}' | + sed -E 's|https?://||' | cut -d: -f1 + register: api_host + changed_when: false + environment: + KUBECONFIG: "{{ kubeconfig }}" + +- name: Resolve API IP + ansible.builtin.shell: >- + set -o pipefail && + getent ahosts {{ api_host.stdout }} | awk '{print $1}' | head -n1 + register: api_ip + changed_when: false + failed_when: api_ip.stdout == "" + +- name: Set API IP fact + ansible.builtin.set_fact: + api_accessible_ip: "{{ api_ip.stdout }}" diff --git a/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_ingress_ip.yml b/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_ingress_ip.yml new file mode 100644 index 00000000..9adfc09b --- /dev/null +++ b/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_ingress_ip.yml @@ -0,0 +1,53 @@ +--- +# Retrieve OpenShift Ingress IP + +- name: Get Ingress domain from default ingresscontroller + ansible.builtin.shell: >- + oc get -n openshift-ingress-operator ingresscontroller default -o jsonpath='{.status.domain}' + register: ingress_domain + changed_when: false + environment: + KUBECONFIG: "{{ kubeconfig }}" + +- name: Try to resolve Ingress IP from DNS + ansible.builtin.shell: >- + set -o pipefail && + getent ahosts {{ ingress_domain.stdout }} | awk '{print $1}' | head -n1 + register: ingress_ip_dns + changed_when: false + failed_when: false + +- name: Fallback - Get Ingress IP from router-default service + ansible.builtin.shell: >- + oc get -n openshift-ingress svc router-default -o jsonpath='{.status.loadBalancer.ingress[0].ip}' + register: ingress_ip_lb + when: ingress_ip_dns.stdout == "" + changed_when: false + failed_when: false + environment: + KUBECONFIG: "{{ kubeconfig }}" + +- name: Fallback - Get Ingress IP from install-config in ConfigMap + ansible.builtin.shell: | + set -o pipefail && + oc get cm cluster-config-v1 -n kube-system -o jsonpath="{.data['install-config']}" | \ + awk ' + /ingressVIPs:/ {getline; print $2; exit} + /ingressVIP:/ {print $2; exit} + /ingressFloatingIP:/ {print $2; exit} + ' | tr -d '"' + register: ingress_ip_cm + when: + - ingress_ip_dns.stdout == "" + - ingress_ip_lb.stdout == "" + changed_when: false + failed_when: ingress_ip_cm.stdout == "" + environment: + KUBECONFIG: "{{ kubeconfig }}" + +- name: Set Ingress IP fact + ansible.builtin.set_fact: + apps_accessible_ip: >- + {{ ingress_ip_dns.stdout if ingress_ip_dns.stdout else + ingress_ip_lb.stdout if ingress_ip_lb.stdout else + ingress_ip_cm.stdout }} diff --git a/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_openshift_ips.yml b/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_openshift_ips.yml new file mode 100644 index 00000000..99c57d01 --- /dev/null +++ b/collection/tools/roles/tools_get_deploy_info/tasks/retrieve_openshift_ips.yml @@ -0,0 +1,14 @@ +--- +# Main task: retrieve both API and Ingress IPs + +- name: Retrieve OpenShift API IP + ansible.builtin.include_tasks: retrieve_api_ip.yml + +- name: Retrieve OpenShift Ingress IP + ansible.builtin.include_tasks: retrieve_ingress_ip.yml + +- name: Show retrieved IPs + ansible.builtin.debug: + msg: + - "API IP: {{ api_accessible_ip }}" + - "Ingress IP: {{ apps_accessible_ip }}" diff --git a/jobs_definitions/hcp_testing.yaml b/jobs_definitions/hcp_testing.yaml new file mode 100644 index 00000000..0302211c --- /dev/null +++ b/jobs_definitions/hcp_testing.yaml @@ -0,0 +1,9 @@ +--- +user_cloud: "shiftstack-hosted_cluster" +ocp_cluster_name: "shiftstack-hcp" +ocp_base_domain: "hypershift.lab" +kubeconfig: "~/{{ ocp_cluster_name }}-kubeconfig" + +stages: + - verification + - cinder_csi_tests