From f3906cb4554188456128ac63cd181dbf4b3372c8 Mon Sep 17 00:00:00 2001 From: James Harmison Date: Wed, 17 Feb 2021 16:36:27 -0500 Subject: [PATCH] Added extra steps for LoadBalancer handling in templating of SSH configuration --- roles/gitea-ocp/tasks/main.yml | 17 +++++++++++------ roles/gitea-ocp/templates/config_map.yml.j2 | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/roles/gitea-ocp/tasks/main.yml b/roles/gitea-ocp/tasks/main.yml index 977fd5c..f1cbd41 100644 --- a/roles/gitea-ocp/tasks/main.yml +++ b/roles/gitea-ocp/tasks/main.yml @@ -53,12 +53,17 @@ _gitea_actual_route: "{{ r_route.resources[0].spec.host }}" - name: Get external hostname from Service if external SSH is needed - k8s_info: - api_version: v1 - kind: Service - name: "{{ _gitea_name }}" - namespace: "{{ _gitea_namespace }}" - register: gitea_service + block: + - name: Recover LB service details + k8s_info: + api_version: v1 + kind: Service + name: "{{ _gitea_name }}-ssh" + namespace: "{{ _gitea_namespace }}" + register: _gitea_lb_service + - name: Register LB service hostname + set_fact: + _gitea_lb_address: '{{ _gitea_lb_service.resources[0].status.loadBalancer.ingress[0].hostname }}' when: _gitea_load_balancer - name: Set Route dependant OpenShift Objects for Gitea to {{ _gitea_state }} diff --git a/roles/gitea-ocp/templates/config_map.yml.j2 b/roles/gitea-ocp/templates/config_map.yml.j2 index 39e9dad..a71b455 100644 --- a/roles/gitea-ocp/templates/config_map.yml.j2 +++ b/roles/gitea-ocp/templates/config_map.yml.j2 @@ -31,7 +31,7 @@ data: [server] ROOT_URL = {{ 'http' if not _gitea_ssl|bool else 'https' }}://{{ _gitea_actual_route|default(_gitea_expose_uri) }} - SSH_DOMAIN = {{ gitea_service.resources[0].status.loadBalancer.ingress[0].hostname | default(_gitea_expose_uri) }} + SSH_DOMAIN = {{ _gitea_lb_address|default(_gitea_actual_route|default(_gitea_expose_uri)) }} DOMAIN = {{ _gitea_actual_route|default(_gitea_expose_uri) }} HTTP_PORT = 3000 SSH_PORT = 2022