Merge pull request #59 from corvus-migratorius/fix-ipmi-exporter

Fix the ipmi_exporter role
This commit is contained in:
Alexander Gorelyshev
2025-12-19 17:31:37 +04:00
committed by GitHub
7 changed files with 44 additions and 43 deletions

View File

@@ -14,7 +14,7 @@ Target node:
Role Variables
--------------
Configuration files must have names `web_conf.yaml` and `ipmi_local.conf`. If ipmi_exp_source_dir is specified, the role searches for `web_conf.yaml` and `ipmi_local.conf` in that directory and copy to target host in `ipmi_exp_config_dir`. If the source directory is not specified, the role skips this step. In ipmi_local.conf user can describe what modules to use for metric collection.
Configuration files must have names `web_conf.yaml` and `ipmi_local.conf`. If `ipmi_exporter_local_conf` is specified, the role searches for `web_conf.yaml` and `ipmi_local.conf` in that directory and copy to target host in `ipmi_exporter_config_dir`. If the source directory is not specified, the role skips this step. In ipmi_local.conf user can describe what modules to use for metric collection.
ipmi_up{collector="<NAME>"} is 1 if the data for this collector could successfully be retrieved from the remote host, 0 otherwise.
@@ -28,17 +28,18 @@ The following collectors are available and can be enabled or disabled in the con
- sel-events: collects metrics for user-defined events in system event log (SEL). If it fails, SEL entries metrics (see below) will not be available
- sm-lan-mode: collects the "LAN mode" setting in the current BMC config. If it fails, the LAN mode metric (see below) will not be available
```yaml
ipmi_exp_version: 1.10.1
ipmi_exp_dir: "/etc/exporters"
ipmi_exp_config_dir: "/etc/exporters/config"
ipmi_exp_args: "" # --[no-]native-ipmi Use native IPMI implementation instead of FreeIPMI (EXPERIMENTAL)
# --[no-]web.systemd-socket Use systemd socket activation listeners instead of port listeners (Linux only).
ipmi_exp_log_level: "info" # Only log messages with the given severity or above. One of: [debug, info, warn, error]
ipmi_exp_log_format: "logfmt" # Output format of log messages. One of: [logfmt, json]
ipmi_exp_web_listen_address: "localhost:9290" # Addresses on which to expose metrics and web interface. Repeatable for multiple addresses. Examples: `:9100` or `[::1]:9100` for http, vsock://:9100` for vsock
ipmi_exp_source_dir: ipmi_local.conf # Path to configuration file. See: https://github.com/prometheus-community/ipmi_exporter/blob/master/docs/configuration.md
ipmi_exp_web_source_dir: web_conf.yaml # Path to configuration file that can enable TLS or authentication. See: https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md
- `ipmi_exporter_version`: release version of the exporter
- `ipmi_exporter_config_dir`: where to put configuration files
- `ipmi_exporter_args`:
- `--[no-]native-ipmi`: Use native IPMI implementation instead of FreeIPMI (EXPERIMENTAL)
- `--[no-]web.systemd-socket`: Use systemd socket activation listeners instead of port listeners (Linux only).
- `ipmi_exporter_log_level`: "info" # Only log messages with the given severity or above. One of: [debug, info, warn, error]
- `ipmi_exporter_log_format`: "logfmt" # Output format of log messages. One of: [logfmt, json]
- `ipmi_exporter_web_listen_address`: Addresses on which to expose metrics and web interface. Repeatable for multiple addresses.
- `:9100` or `[::1]:9100` for HTTP
- `vsock://:9100` for vsock
- `ipmi_exporter_local_conf`: (optional) Path to local configuration file. See: https://github.com/prometheus-community/ipmi_exporter/blob/master/docs/configuration.md
- `ipmi_exporter_web_conf`: (optional) Path to web configuration file that can enable TLS or authentication. See: https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md
```
Dependencies

View File

@@ -1,8 +1,7 @@
---
ipmi_exporter_version: 1.10.1
ipmi_exporter_dir: "/etc/exporters"
ipmi_exporter_config_dir: "/etc/exporters/config"
ipmi_exporter_config_dir: "/etc/ipmi_exporter"
ipmi_exporter_log_level: "info"
ipmi_exporter_log_format: "logfmt"
ipmi_exporter_web_listen_address: "localhost:9290"
ipmi_exporter_web_listen_address: "0.0.0.0:9290"
ipmi_exporter_args: ""

View File

@@ -3,4 +3,4 @@
hosts: all
roles:
- role: genlab.common.ipmi_exporter
ipmi_exp_source_dir: "molecule/default/"
ipmi_exporter_local_conf: "configs/local.conf"

View File

@@ -1,20 +1,20 @@
---
- name: "Upload ipmi_exporter local configure file"
- name: "Configure | Upload local configuration file"
notify: "(Re)start and enable ipmi_exporter"
when: ipmi_exp_source_dir is defined and ipmi_exp_source_dir | length > 0
when: ipmi_exporter_local_conf is defined
ansible.builtin.template:
src: "{{ ipmi_exp_source_dir }}/ipmi_local.conf"
dest: "{{ ipmi_exporter_config_dir }}/ipmi_local.conf"
src: "{{ ipmi_exporter_local_conf }}"
dest: "{{ ipmi_exporter_config_dir }}/local.conf"
owner: root
group: root
mode: '0640'
- name: "Upload ipmi_exporter web configure file"
- name: "Configure | Upload web configuration file"
notify: "(Re)start and enable ipmi_exporter"
when: ipmi_exp_web_source_dir is defined and ipmi_exp_web_source_dir | length > 0
when: ipmi_exporter_web_conf is defined
ansible.builtin.template:
src: "{{ ipmi_exp_web_source_dir }}/web_conf.yaml"
dest: "{{ ipmi_exporter_config_dir }}/web_conf.yaml"
src: "{{ ipmi_exporter_web_conf }}"
dest: "{{ ipmi_exporter_config_dir }}/web.yaml"
owner: root
group: root
mode: '0640'

View File

@@ -1,48 +1,49 @@
---
- name: "Install ipmi_exporter from binary"
- name: "Install | Install ipmi_exporter binary"
block:
- name: "Check ipmi_exporter version"
- name: "Install | Check ipmi_exporter availability"
changed_when: false
register: ipmi_exporter_ver
ansible.builtin.command:
cmd: "ipmi_exporter --version"
register: ipmi_exporter_ver
- name: "Assert version correctness"
- name: "Install | Assert version correctness"
ansible.builtin.assert:
that: "ipmi_exporter_ver.stdout is regex('{{ ipmi_exporter_version }}')"
success_msg: "ipmi_exporter version {{ ipmi_exporter_version }} is installed and working"
fail_msg: "ipmi_exporter version {{ ipmi_exporter_version }} is not installed or not working correctly"
rescue:
- name: "Create ipmi_exporter directories"
- name: "Install | Create directories"
loop:
- "{{ ipmi_exporter_config_dir }}"
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: "0755"
with_items:
- "{{ ipmi_exporter_dir }}"
- "{{ ipmi_exporter_config_dir }}"
- name: "Unarchive ipmi_exporter tar file"
- name: "Install | Fetch and unarchive the release tarball"
notify: "(Re)start and enable ipmi_exporter"
delay: 3
retries: 3
ansible.builtin.unarchive:
src: "https://github.com/prometheus-community/ipmi_exporter/releases/\
download/v{{ ipmi_exporter_version }}/ipmi_exporter-{{ ipmi_exporter_version }}.linux-amd64.tar.gz"
dest: "{{ ipmi_exporter_dir }}"
dest: "/tmp/"
remote_src: true
- name: "Move ipmi_exporter binary"
- name: "Install | Rename and move the binary under PATH"
ansible.builtin.copy:
src: "{{ ipmi_exporter_dir }}/ipmi_exporter-{{ ipmi_exporter_version }}.linux-amd64/ipmi_exporter"
dest: "/usr/local/bin/ipmi_exporter"
src: "/tmp/ipmi_exporter-{{ ipmi_exporter_version }}.linux-amd64/ipmi_exporter"
dest: "/usr/sbin/ipmi_exporter"
mode: "0755"
owner: root
group: root
remote_src: true
- name: Create systemd service file
- name: "Install | Create a systemd service file"
ansible.builtin.template:
src: ipmi_exporter.service.j2
dest: /etc/systemd/system/ipmi_exporter.service

View File

@@ -7,18 +7,18 @@ StartLimitBurst=5
[Service]
Type=simple
ExecStart=/usr/local/bin/ipmi_exporter \
ExecStart=/usr/sbin/ipmi_exporter \
--web.listen-address={{ ipmi_exporter_web_listen_address }} \
--log.level={{ ipmi_exporter_log_level }} \
--log.format={{ ipmi_exporter_log_format }} \
{% if ipmi_exporter_args is defined and ipmi_exporter_args | length > 0 %}
{{ ipmi_exporter_args }} \
{% endif %}
{% if ipmi_exporter_source_dir is defined and ipmi_exporter_source_dir | length > 0 %}
--config.file={{ ipmi_exporter_config_dir }}/ipmi_local.conf \
{% if ipmi_exporter_local_conf is defined %}
--config.file={{ ipmi_exporter_config_dir }}/local.conf \
{% endif %}
{% if ipmi_exporter_web_source_dir is defined and ipmi_exporter_web_source_dir | length > 0 %}
--web.config.file={{ ipmi_exporter_config_dir }}/web_conf.yaml
{% if ipmi_exporter_web_conf is defined %}
--web.config.file={{ ipmi_exporter_config_dir }}/web.yaml
{% endif %}
SyslogIdentifier=ipmi_exporter