add smartctl_exporter role
This commit is contained in:
7
roles/smartctl_exporter/molecule/default/converge.yml
Normal file
7
roles/smartctl_exporter/molecule/default/converge.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: genlab.smartctl_exporter
|
||||
smartctl_exp_dir: "/etc/exporters"
|
||||
smartctl_exp_config_dir: "/etc/exporters/config"
|
||||
27
roles/smartctl_exporter/molecule/default/molecule.yml
Normal file
27
roles/smartctl_exporter/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
|
||||
driver:
|
||||
name: docker
|
||||
|
||||
platforms:
|
||||
- name: ubuntu
|
||||
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2404}-ansible:latest
|
||||
pre_build_image: true
|
||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
cgroupns_mode: host
|
||||
privileged: true
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
|
||||
verifier:
|
||||
name: ansible
|
||||
|
||||
lint: |
|
||||
set -e
|
||||
yamllint .
|
||||
ansible-lint .
|
||||
37
roles/smartctl_exporter/molecule/default/verify.yml
Normal file
37
roles/smartctl_exporter/molecule/default/verify.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
any_errors_fatal: true
|
||||
|
||||
tasks:
|
||||
- name: "Include default vars"
|
||||
ansible.builtin.include_vars:
|
||||
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
|
||||
extensions: [ 'yml' ]
|
||||
|
||||
- name: "Check if smartctl_exporter is installed"
|
||||
changed_when: false
|
||||
ansible.builtin.command: "smartctl_exporter --version"
|
||||
register: smartctl_exporter_installed_version
|
||||
|
||||
- name: "Check smartctl_exporter version"
|
||||
ansible.builtin.assert:
|
||||
that: "smartctl_exporter_installed_version.stderr is regex('{{ smartctl_exp_version }}')"
|
||||
success_msg: "smartctl_exporter version {{ smartctl_exp_version }} is installed and working"
|
||||
fail_msg: "smartctl_exporter version {{ smartctl_exp_version }} is not installed or not working correctly"
|
||||
|
||||
# kics-scan ignore-block
|
||||
- name: "Check if /metrics endpoint is reachable"
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ smartctl_exp_web_listen_address }}/metrics"
|
||||
return_content: true
|
||||
status_code: 200
|
||||
timeout: 5
|
||||
register: metrics_check
|
||||
|
||||
- name: "Fail if /metrics doesn't contain smartctl_exporter_build_info line"
|
||||
ansible.builtin.assert:
|
||||
that: "'smartctl_exporter_build_info' in metrics_check.content"
|
||||
fail_msg: "smartctl_exporter /metrics endpoint doesn't contain smartctl_exporter_build_info line!"
|
||||
success_msg: "smartctl_exporter /metrics endpoint contains smartctl_exporter_build_info line!"
|
||||
Reference in New Issue
Block a user