Skip to content

Commit

Permalink
fix: node_exporter - Add test for ProtectHome
Browse files Browse the repository at this point in the history
Add a tmpfs mount to the node_exporter testing to make sure ProtectHome
is changed.

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ committed Oct 27, 2023
1 parent 9503b96 commit 23ed1f9
Showing 1 changed file with 15 additions and 56 deletions.
71 changes: 15 additions & 56 deletions roles/node_exporter/molecule/alternative/prepare.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 23ed1f9

Please sign in to comment.