From a4a318e5884ec7d505fc13dbf488b6a423f93cc8 Mon Sep 17 00:00:00 2001 From: aknochow Date: Tue, 21 May 2024 18:50:28 -0400 Subject: [PATCH 1/2] fixing metrics-utility variables and conditionals --- .../templates/cronjobs/metrics-utility-gather.yaml.j2 | 4 ++-- .../templates/cronjobs/metrics-utility-report.yaml.j2 | 4 ++-- roles/installer/vars/main.yml | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2 b/roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2 index 25fbd30d5..3867ae942 100644 --- a/roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2 +++ b/roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2 @@ -47,9 +47,9 @@ spec: envFrom: - configMapRef: name: {{ _metrics_utility_configmap }} -{% if _metrics_utility_secret is defined %} +{% if metrics_utility_secret is defined %} - secretRef: - name: {{ _metrics_utility_secret }} + name: {{ metrics_utility_secret }} {% endif %} volumeMounts: - name: {{ ansible_operator_meta.name }}-metrics-utility diff --git a/roles/installer/templates/cronjobs/metrics-utility-report.yaml.j2 b/roles/installer/templates/cronjobs/metrics-utility-report.yaml.j2 index c373e10f1..abfd0f33e 100644 --- a/roles/installer/templates/cronjobs/metrics-utility-report.yaml.j2 +++ b/roles/installer/templates/cronjobs/metrics-utility-report.yaml.j2 @@ -44,9 +44,9 @@ spec: envFrom: - configMapRef: name: {{ _metrics_utility_configmap }} -{% if _metrics_utility_secret is defined %} +{% if metrics_utility_secret is defined %} - secretRef: - name: {{ _metrics_utility_secret }} + name: {{ metrics_utility_secret }} {% endif %} volumeMounts: - name: {{ ansible_operator_meta.name }}-metrics-utility diff --git a/roles/installer/vars/main.yml b/roles/installer/vars/main.yml index fc4cde3af..69b6b5c8e 100644 --- a/roles/installer/vars/main.yml +++ b/roles/installer/vars/main.yml @@ -11,7 +11,6 @@ _postgres_data_path: '/var/lib/pgsql/data/userdata' # metrics-utility (github.com/ansible/metrics-utility) _metrics_utility_enabled: "{{ metrics_utility_enabled | default(false) }}" _metrics_utility_configmap: "{{ metrics_utility_configmap | default(deployment_type + '-metrics-utility-configmap') }}" -_metrics_utility_secret: "{{ metrics_utility_secret | default('') }}" _metrics_utility_console_enabled: "{{ metrics_utility_console_enabled | default(false) }}" _metrics_utility_image: "{{ metrics_utility_image | default(_image) }}" _metrics_utility_image_version: "{{ metrics_utility_image_version | default(_image_version) }}" From c0e61b2886be74a85cd6547d5588b65476aafd3d Mon Sep 17 00:00:00 2001 From: aknochow Date: Mon, 24 Jun 2024 11:18:32 -0400 Subject: [PATCH 2/2] separating metrics-utility for console into separate tasks and conditionals --- roles/installer/tasks/enable_metrics_utility.yml | 12 ------------ .../tasks/enable_metrics_utility_console.yml | 11 +++++++++++ roles/installer/tasks/install.yml | 6 +++++- .../cronjobs/metrics-utility-gather.yaml.j2 | 4 ++++ 4 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 roles/installer/tasks/enable_metrics_utility_console.yml diff --git a/roles/installer/tasks/enable_metrics_utility.yml b/roles/installer/tasks/enable_metrics_utility.yml index ffbb98344..e5bcbf545 100644 --- a/roles/installer/tasks/enable_metrics_utility.yml +++ b/roles/installer/tasks/enable_metrics_utility.yml @@ -28,15 +28,3 @@ loop: - {name: 'metrics-utility-gather', template: 'cronjobs/metrics-utility-gather.yaml.j2'} - {name: 'metrics-utility-report', template: 'cronjobs/metrics-utility-report.yaml.j2'} - -- name: Create metrics-utility Kubernetes CronJob for Red Hat Hybrid Cloud Console - kubernetes.core.k8s: - definition: "{{ lookup('template', item.template) }}" - apply: true - wait: true - vars: - cronjob_name: "{{ item.name }}" - metrics_utility_ship_target: crc # TODO - Update to console when changed - loop: - - {name: 'metrics-utility-gather-console', template: 'cronjobs/metrics-utility-gather.yaml.j2'} - when: _metrics_utility_console_enabled diff --git a/roles/installer/tasks/enable_metrics_utility_console.yml b/roles/installer/tasks/enable_metrics_utility_console.yml new file mode 100644 index 000000000..2496c8c17 --- /dev/null +++ b/roles/installer/tasks/enable_metrics_utility_console.yml @@ -0,0 +1,11 @@ +--- +- name: Create metrics-utility Kubernetes CronJob for Red Hat Hybrid Cloud Console + kubernetes.core.k8s: + definition: "{{ lookup('template', item.template) }}" + apply: true + wait: true + vars: + cronjob_name: "{{ item.name }}" + metrics_utility_ship_target: crc # TODO - Update to console when changed + loop: + - {name: 'metrics-utility-gather-console', template: 'cronjobs/metrics-utility-gather.yaml.j2'} diff --git a/roles/installer/tasks/install.yml b/roles/installer/tasks/install.yml index 70495e433..ff71063d2 100644 --- a/roles/installer/tasks/install.yml +++ b/roles/installer/tasks/install.yml @@ -104,7 +104,11 @@ - name: Enable optional metrics-utility include_tasks: enable_metrics_utility.yml - when: metrics_utility_enabled | bool + when: _metrics_utility_enabled | bool + +- name: Enable optional metrics-utility for Redhat Console + include_tasks: enable_metrics_utility_console.yml + when: _metrics_utility_console_enabled | bool - name: Update status variables include_tasks: update_status.yml diff --git a/roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2 b/roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2 index b78770229..548ab8eb1 100644 --- a/roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2 +++ b/roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2 @@ -52,9 +52,11 @@ spec: name: {{ metrics_utility_secret }} {% endif %} volumeMounts: +{% if _metrics_utility_ship_target == "directory" %} - name: {{ ansible_operator_meta.name }}-metrics-utility mountPath: /metrics-utility readOnly: false +{% endif %} - name: "{{ ansible_operator_meta.name }}-application-credentials" mountPath: "/etc/tower/conf.d/credentials.py" subPath: credentials.py @@ -69,10 +71,12 @@ spec: readOnly: true {{ lookup("template", "common/volume_mounts/extra_settings_files.yaml.j2") | indent(width=12) | trim }} volumes: +{% if _metrics_utility_ship_target == "directory" %} - name: {{ ansible_operator_meta.name }}-metrics-utility persistentVolumeClaim: claimName: {{ _metrics_utility_pvc_claim }} readOnly: false +{% endif %} - name: "{{ ansible_operator_meta.name }}-application-credentials" secret: secretName: "{{ ansible_operator_meta.name }}-app-credentials"