From 4ef6a56691faa74711be774b3703447a98374a8d Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Fri, 5 Jan 2024 09:38:59 -0500 Subject: [PATCH] Default ingress_type to route when on OpenShift also rename route.yml.j2 to ingress.yml.j2 since we cover more than just route now --- roles/mesh_ingress/tasks/creation.yml | 15 ++++++++++----- roles/mesh_ingress/tasks/main.yml | 4 ++++ .../templates/{route.yml.j2 => ingress.yml.j2} | 0 3 files changed, 14 insertions(+), 5 deletions(-) rename roles/mesh_ingress/templates/{route.yml.j2 => ingress.yml.j2} (100%) diff --git a/roles/mesh_ingress/tasks/creation.yml b/roles/mesh_ingress/tasks/creation.yml index 66cbd0fe7..b9d1d9293 100644 --- a/roles/mesh_ingress/tasks/creation.yml +++ b/roles/mesh_ingress/tasks/creation.yml @@ -58,21 +58,26 @@ set_fact: _image_pull_policy: "{{ awx_spec.image_pull_policy | default(_image_pull_policy, true) }}" -- name: Apply Route resource +- name: Default ingress_type to Route if OpenShift + set_fact: + ingress_type: route + when: is_openshift | bool and ingress_type == 'none' + +- name: Apply Ingress resource k8s: apply: yes - definition: "{{ lookup('template', 'route.yml.j2') }}" + definition: "{{ lookup('template', 'ingress.yml.j2') }}" wait: yes wait_timeout: "120" - register: route + register: ingress # TODO: need to wait until the route is ready before we can get the hostname # right now this will rereconcile until the route is ready - name: Set external_hostname set_fact: - external_hostname: "{{ route.result.status.ingress[0].host }}" - when: is_openshift | bool + external_hostname: "{{ ingress.result.status.ingress[0].host }}" + when: ingress_type == 'route' - name: Create other resources k8s: diff --git a/roles/mesh_ingress/tasks/main.yml b/roles/mesh_ingress/tasks/main.yml index 77e7e69ca..733ea64bb 100644 --- a/roles/mesh_ingress/tasks/main.yml +++ b/roles/mesh_ingress/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Lowercase the ingress_type + set_fact: + ingress_type: "{{ ingress_type | lower }}" + - name: Run creation tasks include_tasks: creation.yml when: not finalizer_run diff --git a/roles/mesh_ingress/templates/route.yml.j2 b/roles/mesh_ingress/templates/ingress.yml.j2 similarity index 100% rename from roles/mesh_ingress/templates/route.yml.j2 rename to roles/mesh_ingress/templates/ingress.yml.j2