From 59de53b4ae43fee9255fb9c7c743c890ef5122c8 Mon Sep 17 00:00:00 2001 From: aknochow Date: Thu, 24 Oct 2024 10:12:21 -0400 Subject: [PATCH] adding redirect page --- config/crd/bases/awx.ansible.com_awxs.yaml | 4 + .../awx-operator.clusterserviceversion.yaml | 6 ++ roles/installer/tasks/install.yml | 5 ++ .../templates/configmaps/config.yaml.j2 | 2 +- .../redirect-page.configmap.html.j2 | 77 +++++++++++++++++++ .../templates/deployments/web.yaml.j2 | 13 ++++ roles/installer/vars/main.yml | 1 + 7 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 roles/installer/templates/configmaps/redirect-page.configmap.html.j2 diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index ebe61b84c..eb7b4f6a4 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -2009,6 +2009,10 @@ spec: description: Enable metrics utility shipping to Red Hat Hybrid Cloud Console type: boolean default: false + public_base_url: + description: Public base URL + type: string + default: '' type: object status: properties: diff --git a/config/manifests/bases/awx-operator.clusterserviceversion.yaml b/config/manifests/bases/awx-operator.clusterserviceversion.yaml index 337d18842..c7f8cc7d4 100644 --- a/config/manifests/bases/awx-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/awx-operator.clusterserviceversion.yaml @@ -173,6 +173,12 @@ spec: path: db_management_pod_node_selector x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced + - displayName: Public Base URL + path: public_base_url + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:hidden statusDescriptors: - description: Persistent volume claim name used during backup displayName: Backup Claim diff --git a/roles/installer/tasks/install.yml b/roles/installer/tasks/install.yml index e1c44eff6..60b94577a 100644 --- a/roles/installer/tasks/install.yml +++ b/roles/installer/tasks/install.yml @@ -44,6 +44,11 @@ - name: Include secret key configuration tasks include_tasks: secret_key_configuration.yml +- name: Apply Redirect Page Configmap + k8s: + definition: "{{ lookup('template', 'configmaps/redirect-page.configmap.html.j2') }}" + when: public_base_url is defined + - name: Load LDAP CAcert certificate (Deprecated) include_tasks: load_ldap_cacert_secret.yml when: diff --git a/roles/installer/templates/configmaps/config.yaml.j2 b/roles/installer/templates/configmaps/config.yaml.j2 index 99acf723e..7283101e9 100644 --- a/roles/installer/templates/configmaps/config.yaml.j2 +++ b/roles/installer/templates/configmaps/config.yaml.j2 @@ -26,7 +26,7 @@ data: return open('/etc/tower/SECRET_KEY', 'rb').read().strip() ADMINS = () - STATIC_ROOT = '/var/lib/awx/public/static' + STATIC_ROOT = '{{ _static_root }}' STATIC_URL = '{{ (ingress_path + '/static/').replace('//', '/') }}' PROJECTS_ROOT = '/var/lib/awx/projects' JOBOUTPUT_ROOT = '/var/lib/awx/job_status' diff --git a/roles/installer/templates/configmaps/redirect-page.configmap.html.j2 b/roles/installer/templates/configmaps/redirect-page.configmap.html.j2 new file mode 100644 index 000000000..bc893b372 --- /dev/null +++ b/roles/installer/templates/configmaps/redirect-page.configmap.html.j2 @@ -0,0 +1,77 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ ansible_operator_meta.name }}-redirect-page + namespace: {{ ansible_operator_meta.namespace }} +data: + redirect-page.html: | + + + + + + + Redirecting to Ansible Automation Platform + + + + + + + + + + + + + + +

Redirecting to Ansible Automation Platform...

+

If you are not redirected automatically, click here to go to AAP.

+

+ The API endpoints for this platform service will temporarily remain available at the URL for this service. + Please use the Ansible Automation Platform API endpoints corresponding to this component in the future. + These can be found at {{ public_base_url }}/awx/api/. +

+ + + + + + \ No newline at end of file diff --git a/roles/installer/templates/deployments/web.yaml.j2 b/roles/installer/templates/deployments/web.yaml.j2 index f32020f1b..a123e7e6f 100644 --- a/roles/installer/templates/deployments/web.yaml.j2 +++ b/roles/installer/templates/deployments/web.yaml.j2 @@ -303,6 +303,11 @@ spec: {% endif %} imagePullPolicy: '{{ image_pull_policy }}' volumeMounts: +{% if public_base_url is defined %} + - name: redirect-page + mountPath: '{{ _static_root }}/awx/index.html' + subPath: redirect-page.html +{% endif %} - name: "{{ ansible_operator_meta.name }}-application-credentials" mountPath: "/etc/tower/conf.d/credentials.py" subPath: credentials.py @@ -375,6 +380,14 @@ spec: {{ security_context_settings | to_nice_yaml | indent(8) }} {% endif %} volumes: +{% if public_base_url is defined %} + - name: redirect-page + configMap: + name: '{{ ansible_operator_meta.name }}-redirect-page' + items: + - key: redirect-page.html + path: redirect-page.html +{% endif %} - name: "{{ ansible_operator_meta.name }}-receptor-ca" secret: secretName: "{{ ansible_operator_meta.name }}-receptor-ca" diff --git a/roles/installer/vars/main.yml b/roles/installer/vars/main.yml index 391e5eda6..255270337 100644 --- a/roles/installer/vars/main.yml +++ b/roles/installer/vars/main.yml @@ -1,4 +1,5 @@ --- +_static_root: /var/lib/awx/public/static postgres_initdb_args: '--auth-host=scram-sha-256' postgres_host_auth_method: 'scram-sha-256' # LDAP is deprecated