fix ansible-lint errors

This commit is contained in:
Sergey Malyuk
2025-12-16 11:56:52 +03:00
parent 48652534ce
commit f4b945d1ed
7 changed files with 45 additions and 45 deletions

View File

@@ -1,14 +1,14 @@
--- ---
smartctl_exp_web_listen_address: "localhost:9633" smartctl_exporter_web_listen_address: "localhost:9633"
smartctl_exp_args: "" smartctl_exporter_args: ""
smartctl_exp_version: "0.14.0" smartctl_exporter_version: "0.14.0"
smartctl_exp_dir: "/etc/exporters" smartctl_exporter_dir: "/etc/exporters"
smartctl_exp_web_config_dir: "/etc/exporters/config" smartctl_exporter_web_config_dir: "/etc/exporters/config"
smartctl_exp_interval: "60s" smartctl_exporter_interval: "60s"
smartctl_exp_rescan: "10m" smartctl_exporter_rescan: "10m"
smartctl_exp_devices: [] smartctl_exporter_devices: []
smartctl_exp_device_exclude: "" smartctl_exporter_device_exclude: ""
smartctl_exp_device_include: "" smartctl_exporter_device_include: ""
smartctl_exp_web_telemetry_path: "/metrics" smartctl_exporter_web_telemetry_path: "/metrics"
smartctl_exp_log_level: "info" smartctl_exporter_log_level: "info"
smartctl_exp_log_format: "logfmt" smartctl_exporter_log_format: "logfmt"

View File

@@ -2,6 +2,6 @@
- name: Converge - name: Converge
hosts: all hosts: all
roles: roles:
- role: genlab.smartctl_exporter - role: genlab.common.smartctl_exporter
smartctl_exp_dir: "/etc/exporters" smartctl_exporter_dir: "/etc/exporters"
smartctl_exp_config_dir: "/etc/exporters/config" smartctl_exp_config_dir: "/etc/exporters/config"

View File

@@ -17,21 +17,21 @@
- name: "Check smartctl_exporter version" - name: "Check smartctl_exporter version"
ansible.builtin.assert: ansible.builtin.assert:
that: "smartctl_exporter_installed_version.stderr is regex('{{ smartctl_exp_version }}')" that: "smartctl_exporter_installed_version.stderr is regex('{{ smartctl_exporter_version }}')"
success_msg: "smartctl_exporter version {{ smartctl_exp_version }} is installed and working" success_msg: "smartctl_exporter version {{ smartctl_exporter_version }} is installed and working"
fail_msg: "smartctl_exporter version {{ smartctl_exp_version }} is not installed or not working correctly" fail_msg: "smartctl_exporter version {{ smartctl_exporter_version }} is not installed or not working correctly"
# kics-scan ignore-block # kics-scan ignore-block
- name: "Check if /metrics endpoint is reachable" - name: "Check if /metrics endpoint is reachable"
ansible.builtin.uri: ansible.builtin.uri:
url: "http://{{ smartctl_exp_web_listen_address }}/metrics" url: "http://{{ smartctl_exporter_web_listen_address }}/metrics"
return_content: true return_content: true
status_code: 200 status_code: 200
timeout: 5 timeout: 5
register: metrics_check register: smartctl_exporter_metrics_check
- name: "Fail if /metrics doesn't contain smartctl_exporter_build_info line" - name: "Fail if /metrics doesn't contain smartctl_exporter_build_info line"
ansible.builtin.assert: ansible.builtin.assert:
that: "'smartctl_exporter_build_info' in metrics_check.content" that: "'smartctl_exporter_build_info' in smartctl_exporter_metrics_check.content"
fail_msg: "smartctl_exporter /metrics endpoint doesn't contain smartctl_exporter_build_info line!" 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!" success_msg: "smartctl_exporter /metrics endpoint contains smartctl_exporter_build_info line!"

View File

@@ -4,7 +4,7 @@
when: smartctl_exp_source_web_config_dir is defined and smartctl_exp_source_web_config_dir | length > 0 when: smartctl_exp_source_web_config_dir is defined and smartctl_exp_source_web_config_dir | length > 0
ansible.builtin.template: ansible.builtin.template:
src: "{{ smartctl_exp_source_web_config_dir }}/web_smartctl.conf" src: "{{ smartctl_exp_source_web_config_dir }}/web_smartctl.conf"
dest: "{{ smartctl_exp_web_config_dir }}/web_smartctl.conf" dest: "{{ smartctl_exporter_web_config_dir }}/web_smartctl.conf"
owner: root owner: root
group: root group: root
mode: '0640' mode: '0640'

View File

@@ -9,9 +9,9 @@
- name: "Assert version correctness" - name: "Assert version correctness"
ansible.builtin.assert: ansible.builtin.assert:
that: "smartctl_exporter_ver.stderr is regex('{{ smartctl_exp_version }}')" that: "smartctl_exporter_ver.stderr is regex('{{ smartctl_exporter_version }}')"
success_msg: "smartctl_exporter version {{ smartctl_exp_version }} is installed and working" success_msg: "smartctl_exporter version {{ smartctl_exporter_version }} is installed and working"
fail_msg: "smartctl_exporter version {{ smartctl_exp_version }} is not installed or not working correctly" fail_msg: "smartctl_exporter version {{ smartctl_exporter_version }} is not installed or not working correctly"
rescue: rescue:
- name: "Create smartctl_exporter directories" - name: "Create smartctl_exporter directories"
@@ -22,20 +22,20 @@
group: root group: root
mode: "0755" mode: "0755"
with_items: with_items:
- "{{ smartctl_exp_dir }}" - "{{ smartctl_exporter_dir }}"
- "{{ smartctl_exp_config_dir }}" - "{{ smartctl_exp_config_dir }}"
- name: "Unarchive smartctl_exporter tar file" - name: "Unarchive smartctl_exporter tar file"
notify: "(Re)start and enable smartctl_exporter" notify: "(Re)start and enable smartctl_exporter"
ansible.builtin.unarchive: ansible.builtin.unarchive:
src: "https://github.com/prometheus-community/smartctl_exporter/releases/\ src: "https://github.com/prometheus-community/smartctl_exporter/releases/\
download/v{{ smartctl_exp_version }}/smartctl_exporter-{{ smartctl_exp_version }}.linux-amd64.tar.gz" download/v{{ smartctl_exporter_version }}/smartctl_exporter-{{ smartctl_exporter_version }}.linux-amd64.tar.gz"
dest: "{{ smartctl_exp_dir }}" dest: "{{ smartctl_exporter_dir }}"
remote_src: true remote_src: true
- name: "Move smartctl_exporter binary" - name: "Move smartctl_exporter binary"
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ smartctl_exp_dir }}/smartctl_exporter-{{ smartctl_exp_version }}.linux-amd64/smartctl_exporter" src: "{{ smartctl_exporter_dir }}/smartctl_exporter-{{ smartctl_exporter_version }}.linux-amd64/smartctl_exporter"
dest: "/usr/local/bin/smartctl_exporter" dest: "/usr/local/bin/smartctl_exporter"
mode: "0755" mode: "0755"
owner: root owner: root

View File

@@ -10,24 +10,24 @@ Type=simple
User=root User=root
Group=root Group=root
ExecStart=/usr/local/bin/smartctl_exporter \ ExecStart=/usr/local/bin/smartctl_exporter \
--web.listen-address={{ smartctl_exp_web_listen_address }} \ --web.listen-address={{ smartctl_exporter_web_listen_address }} \
--smartctl.interval={{ smartctl_exp_interval }} \ --smartctl.interval={{ smartctl_exporter_interval }} \
--smartctl.rescan={{ smartctl_exp_rescan }} \ --smartctl.rescan={{ smartctl_exporter_rescan }} \
{% if smartctl_exp_devices is defined and smartctl_exp_devices | length > 0 %} {% if smartctl_exporter_devices is defined and smartctl_exporter_devices | length > 0 %}
{% for device in smartctl_exp_devices %} {% for device in smartctl_exporter_devices %}
--smartctl.device={{ device }} \ --smartctl.device={{ device }} \
{% endfor %} {% endfor %}
{% endif %} {% endif %}
--smartctl.device-exclude={{ smartctl_exp_device_exclude }} \ --smartctl.device-exclude={{ smartctl_exporter_device_exclude }} \
--smartctl.device-include={{ smartctl_exp_device_include }} \ --smartctl.device-include={{ smartctl_exporter_device_include }} \
--web.telemetry-path={{ smartctl_exp_web_telemetry_path }} \ --web.telemetry-path={{ smartctl_exporter_web_telemetry_path }} \
--log.level={{ smartctl_exp_log_level }} \ --log.level={{ smartctl_exporter_log_level }} \
--log.format={{ smartctl_exp_log_format }} \ --log.format={{ smartctl_exporter_log_format }} \
{% if smartctl_exp_args is defined and smartctl_exp_args | length > 0 %} {% if smartctl_exporter_args is defined and smartctl_exporter_args | length > 0 %}
{{ smartctl_exp_args }} \ {{ smartctl_exporter_args }} \
{% endif %} {% endif %}
{% if smartctl_exp_source_web_config_dir is defined and smartctl_exp_source_web_config_dir | length > 0 %} \ {% if smartctl_exp_source_web_config_dir is defined and smartctl_exp_source_web_config_dir | length > 0 %} \
--web.config.file={{ smartctl_exp_web_config_dir }}/web_smartctl.conf --web.config.file={{ smartctl_exporter_web_config_dir }}/web_smartctl.conf
{% endif %} {% endif %}
SyslogIdentifier=smartctl_exporter SyslogIdentifier=smartctl_exporter