From 5075dd13f28f88ab0230d48a6a28c08980795443 Mon Sep 17 00:00:00 2001 From: jlarriba Date: Wed, 8 Jan 2025 15:37:09 +0100 Subject: [PATCH] [OSPRH-12795] Remove tls cert and key from molecule tests in telemetry-operator --- .../molecule/default/prepare.yml | 69 ++++-------------- .../molecule/default/collections.yml | 3 + .../molecule/default/prepare.yml | 70 ++++--------------- 3 files changed, 32 insertions(+), 110 deletions(-) diff --git a/roles/edpm_telemetry/molecule/default/prepare.yml b/roles/edpm_telemetry/molecule/default/prepare.yml index ba5277fc6..71eb5abfc 100644 --- a/roles/edpm_telemetry/molecule/default/prepare.yml +++ b/roles/edpm_telemetry/molecule/default/prepare.yml @@ -118,67 +118,26 @@ - volume.* - hardware.* + - name: Install crypto dependency + become: true + ansible.builtin.dnf: + name: python3-cryptography + state: present + - name: Create certs directory ansible.builtin.file: path: "{{ edpm_telemetry_certs }}" state: directory mode: "0775" - - name: Create tls.crt - ansible.builtin.copy: - dest: "{{ edpm_telemetry_certs }}/tls.crt" - mode: "0600" - owner: root - group: root - content: | - -----BEGIN CERTIFICATE----- - MIICdTCCAhugAwIBAgIRANbtgxUt6z0Lgu63tMkJi/owCgYIKoZIzj0EAwIwGjEY - MBYGA1UEAxMPcm9vdGNhLWludGVybmFsMB4XDTI0MDIyMDEwMjQwN1oXDTI1MDIx - OTEwMjQwN1owADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMMIngiZ - KKDAYL7pwP3ti5XD8cNHaYfjHXmpeXWCinDjsnbVbxbIg8tbk/S37J7bVKXzkynZ - fqy5zm0OAMcUQpzVpAm8a4BNgBpyOkEmvI3wuk2+eV9UTvdxfnZH49w1PP1y6YMp - eTe4L/N73f+85S4T4t0z0LzuaUnBmDzrMHti1dhKEa4dHeUXgm0X4bIUYy7LDzJS - RXZWLrTlNudqNGTJjqysLF+tG0/42m+aCrDyobnGnDhipqKiDAymm/8imea4z9RN - TJB7YamWsKME1TWMXKTGdpvukzD5hMqSR9nb8GLhnSp2+affjONEA2qTFb2EjQsy - UN3H8TlxDTg4nU8CAwEAAaOBkDCBjTAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAww - CgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADAfBgNVHSMEGDAWgBRw5+MeAyVauyYD - qxHKihlwOahznTA3BgNVHREBAf8ELTArgiNlZHBtLWNvbXB1dGUtMC5jdGxwbGFu - ZS5leGFtcGxlLmNvbYcEwKh6ZDAKBggqhkjOPQQDAgNIADBFAiEA/pS5XYr/Kcux - YAcw+uSB/iTMy5v/rXhGNyIIRuzhei0CIAr/jg2QBtOJGSr0DVUF+0qdi1o1GAxN - Ldhr3K2EKWFY - -----END CERTIFICATE----- - - - name: Create tls.key - ansible.builtin.copy: - dest: "{{ edpm_telemetry_certs }}/tls.key" + - name: Generate an OpenSSL private key with the default values (4096 bits, RSA) + community.crypto.openssl_privatekey: + path: "{{ edpm_telemetry_certs }}/tls.key" mode: "0600" owner: root group: root - content: | - -----BEGIN RSA PRIVATE KEY----- - MIIEogIBAAKCAQEAwwieCJkooMBgvunA/e2LlcPxw0dph+Mdeal5dYKKcOOydtVv - FsiDy1uT9LfsnttUpfOTKdl+rLnObQ4AxxRCnNWkCbxrgE2AGnI6QSa8jfC6Tb55 - X1RO93F+dkfj3DU8/XLpgyl5N7gv83vd/7zlLhPi3TPQvO5pScGYPOswe2LV2EoR - rh0d5ReCbRfhshRjLssPMlJFdlYutOU252o0ZMmOrKwsX60bT/jab5oKsPKhucac - OGKmoqIMDKab/yKZ5rjP1E1MkHthqZawowTVNYxcpMZ2m+6TMPmEypJH2dvwYuGd - Knb5p9+M40QDapMVvYSNCzJQ3cfxOXENODidTwIDAQABAoIBADtnD4M86vPzRERB - vCdbR62I7cT1pj3ePecFaFoTNYlmwL+TCG/fCM1SikD6GBbWZPTauFMBzKRdP3NV - 1YTNNfDA3WKdwfxlHoRvkDCx1LJCxOvS/PK9IgQZzFPIV62FhZsIefkaE7KV5fz6 - GEbBSO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ro3IaVqMs= - -----END RSA PRIVATE KEY----- + + - name: Generate an OpenSSL public key in PEM format + community.crypto.openssl_publickey: + path: "{{ edpm_telemetry_certs }}/tls.crt" + privatekey_path: "{{ edpm_telemetry_certs }}/tls.key" \ No newline at end of file diff --git a/roles/edpm_telemetry_power_monitoring/molecule/default/collections.yml b/roles/edpm_telemetry_power_monitoring/molecule/default/collections.yml index 7e96bda06..ca45853b6 100644 --- a/roles/edpm_telemetry_power_monitoring/molecule/default/collections.yml +++ b/roles/edpm_telemetry_power_monitoring/molecule/default/collections.yml @@ -16,3 +16,6 @@ collections: - name: community.general + + - name: community.crypto + type: galaxy diff --git a/roles/edpm_telemetry_power_monitoring/molecule/default/prepare.yml b/roles/edpm_telemetry_power_monitoring/molecule/default/prepare.yml index a04d7592b..68cff6636 100644 --- a/roles/edpm_telemetry_power_monitoring/molecule/default/prepare.yml +++ b/roles/edpm_telemetry_power_monitoring/molecule/default/prepare.yml @@ -147,6 +147,12 @@ - volume.* - hardware.* + - name: Install crypto dependency + become: true + ansible.builtin.dnf: + name: python3-cryptography + state: present + - name: Create certs directory become: true ansible.builtin.file: @@ -154,63 +160,17 @@ state: directory mode: "0775" - - name: Create tls.crt - become: true - ansible.builtin.copy: - dest: "{{ edpm_telemetry_certs }}/tls.crt" + - name: Generate an OpenSSL private key with the default values (4096 bits, RSA) + community.crypto.openssl_privatekey: + path: "{{ edpm_telemetry_certs }}/tls.key" mode: "0600" owner: root group: root - content: | - -----BEGIN CERTIFICATE----- - MIICdTCCAhugAwIBAgIRANbtgxUt6z0Lgu63tMkJi/owCgYIKoZIzj0EAwIwGjEY - MBYGA1UEAxMPcm9vdGNhLWludGVybmFsMB4XDTI0MDIyMDEwMjQwN1oXDTI1MDIx - OTEwMjQwN1owADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMMIngiZ - KKDAYL7pwP3ti5XD8cNHaYfjHXmpeXWCinDjsnbVbxbIg8tbk/S37J7bVKXzkynZ - fqy5zm0OAMcUQpzVpAm8a4BNgBpyOkEmvI3wuk2+eV9UTvdxfnZH49w1PP1y6YMp - eTe4L/N73f+85S4T4t0z0LzuaUnBmDzrMHti1dhKEa4dHeUXgm0X4bIUYy7LDzJS - RXZWLrTlNudqNGTJjqysLF+tG0/42m+aCrDyobnGnDhipqKiDAymm/8imea4z9RN - TJB7YamWsKME1TWMXKTGdpvukzD5hMqSR9nb8GLhnSp2+affjONEA2qTFb2EjQsy - UN3H8TlxDTg4nU8CAwEAAaOBkDCBjTAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAww - CgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADAfBgNVHSMEGDAWgBRw5+MeAyVauyYD - qxHKihlwOahznTA3BgNVHREBAf8ELTArgiNlZHBtLWNvbXB1dGUtMC5jdGxwbGFu - ZS5leGFtcGxlLmNvbYcEwKh6ZDAKBggqhkjOPQQDAgNIADBFAiEA/pS5XYr/Kcux - YAcw+uSB/iTMy5v/rXhGNyIIRuzhei0CIAr/jg2QBtOJGSr0DVUF+0qdi1o1GAxN - Ldhr3K2EKWFY - -----END CERTIFICATE----- - - - name: Create tls.key - become: true - ansible.builtin.copy: - dest: "{{ edpm_telemetry_certs }}/tls.key" + + - name: Generate an OpenSSL public key in PEM format + community.crypto.openssl_publickey: + path: "{{ edpm_telemetry_certs }}/tls.crt" + privatekey_path: "{{ edpm_telemetry_certs }}/tls.key" mode: "0600" owner: root - group: root - content: | - -----BEGIN RSA PRIVATE KEY----- - MIIEogIBAAKCAQEAwwieCJkooMBgvunA/e2LlcPxw0dph+Mdeal5dYKKcOOydtVv - FsiDy1uT9LfsnttUpfOTKdl+rLnObQ4AxxRCnNWkCbxrgE2AGnI6QSa8jfC6Tb55 - X1RO93F+dkfj3DU8/XLpgyl5N7gv83vd/7zlLhPi3TPQvO5pScGYPOswe2LV2EoR - rh0d5ReCbRfhshRjLssPMlJFdlYutOU252o0ZMmOrKwsX60bT/jab5oKsPKhucac - OGKmoqIMDKab/yK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7cB38C5SQJM - f8lGRkCtYmE5f+lak/YDLsm7orNTkLHZzg1E92+qYk3vtSil2QtJWcBcZFUdY44s - CNJNAoGAGmsvAw2tOqXU0hn/8oH2tjfD9sfYnKMe19vdJLPSQjJZv31QZPzl2g4j - yCCnUxqB0fmzNM/1TuPBzBcdtLWhV7k10jxrovkAHSDXsGBb/+8BbWH04tOhoOO7 - snX6BmT+G0RSby8naSiNl/8DM96Nj2Oh0WOwIa4oNdro3IaVqMs= - -----END RSA PRIVATE KEY----- + group: root \ No newline at end of file