From 23ed1f92531b8ff8c96841dd7067d75d1a094a4d Mon Sep 17 00:00:00 2001 From: SuperQ Date: Wed, 10 May 2023 10:16:50 +0200 Subject: [PATCH] fix: node_exporter - Add test for ProtectHome Add a tmpfs mount to the node_exporter testing to make sure ProtectHome is changed. Signed-off-by: SuperQ --- .../molecule/alternative/prepare.yml | 71 ++++--------------- 1 file changed, 15 insertions(+), 56 deletions(-) diff --git a/roles/node_exporter/molecule/alternative/prepare.yml b/roles/node_exporter/molecule/alternative/prepare.yml index f99a2ec6c..67c6e8288 100644 --- a/roles/node_exporter/molecule/alternative/prepare.yml +++ b/roles/node_exporter/molecule/alternative/prepare.yml @@ -1,59 +1,3 @@ ---- -- name: Run local preparation - hosts: localhost - gather_facts: false - tasks: - - name: Download node_exporter binary to local folder - become: false - ansible.builtin.get_url: - url: "https://github.com/prometheus/node_exporter/releases/download/v{{\ - \ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{\ - \ go_arch }}.tar.gz" - dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz" - mode: 0644 - register: _download_binary - until: _download_binary is succeeded - retries: 5 - delay: 2 - check_mode: false - - - name: Unpack node_exporter binary - become: false - ansible.builtin.unarchive: - src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz" - dest: "/tmp" - creates: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch\ - \ }}/node_exporter" - check_mode: false - - - name: Link to node_exporter binaries directory - become: false - ansible.builtin.file: - src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-amd64" - dest: "/tmp/node_exporter-linux-amd64" - state: link - check_mode: false - - - name: Install pyOpenSSL for certificate generation - ansible.builtin.pip: - name: "pyOpenSSL" - - - name: Create private key - community.crypto.openssl_privatekey: - path: "/tmp/tls.key" - - - name: Create CSR - community.crypto.openssl_csr: - path: "/tmp/tls.csr" - privatekey_path: "/tmp/tls.key" - - - name: Create certificate - community.crypto.x509_certificate: - path: "/tmp/tls.cert" - csr_path: "/tmp/tls.csr" - privatekey_path: "/tmp/tls.key" - provider: selfsigned - - name: Run target preparation hosts: all any_errors_fatal: true @@ -76,3 +20,18 @@ dest: "{{ node_exporter_tls_server_config.cert_file }}" - src: "/tmp/tls.key" dest: "{{ node_exporter_tls_server_config.key_file }}" + + - name: Create test mount directory + ansible.builtin.file: + path: /home/test + state: directory + owner: root + group: root + mode: 0755 + + - name: Mount test filesystem + ansible.posix.mount: + path: /home/test + src: tmpfs + fstype: tmpfs + state: mounted