fix(textfile): corrected the textfile collector installation

This commit is contained in:
Waldemar Tomme 2022-03-21 16:14:58 +01:00
parent ccbad10301
commit b1c9d22823
3 changed files with 15 additions and 14 deletions

View File

@ -5,14 +5,11 @@
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_config_users = tplroot ~ '.config.users' %}
include:
- {{ sls_config_users }}
{%- set states = [] %}
{%- set name = 'node_exporter' %}
{%- if name in p.wanted.component and 'service' in p.pkg.component[name] %}
{%- if 'collector' in p.pkg.component[name]['service']['args'] %}
{%- if 'collector.textfile.directory' in p.pkg.component[name]['service']['args'] %}
prometheus-exporters-{{ name }}-collector-textfile-dir:
file.directory:
- name: {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
@ -32,7 +29,7 @@ prometheus-exporters-{{ name }}-collector-textfile-dir:
{%- if v.get('remove', False) %}
{%- set state = ".{}.clean".format(k) %}
{%- else %}
{%- set state = ".{}".format(k) %}
{%- set state = ".{}.install".format(k) %}
{%- endif %}
{%- do states.append(state) %}
{%- endif %}
@ -44,12 +41,14 @@ prometheus-exporters-{{ name }}-textfile-dependencies:
- pkgs: {{ p.exporters[name]['textfile_collectors_dependencies'] }}
- require_in:
{%- for state in states %}
- sls: p.pkg.component[name]['config'][textfile_collectors{{ state }}
- sls: {{ tplroot }}.exporters.{{ name }}.textfile_collectors{{ state }}
{%- endfor %}
include:
{%- for state in states %}
- {{ state }}
{% endfor %}
{%- endif %}
{%- endif %}
include:
- {{ sls_config_users }}
{%- for state in states %}
- {{ state }}
{% endfor %}

View File

@ -6,7 +6,7 @@
{%- set name = 'node_exporter' %}
{%- set config = p.exporters[name]['textfile_collectors']['ipmitool'] %}
{%- set dir = {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
{%- set dir = p.pkg.component[name]['service']['args']['collector.textfile.directory'] %}
{%- set script = p.dir.archive ~ '/textfile_collectors/ipmitool' %}
{%- set cmd_prefix = 'awk -f ' if grains.os_family in ['FreeBSD'] else '' %}
@ -15,10 +15,11 @@ prometheus-exporters-install-{{ name }}-textfile_collectors-ipmitool:
- name: {{ config.pkg }}
file.managed:
- name: {{ script }}
- source: salt://prometheus/exporters-install/{{ name }}/textfile_collectors/files/ipmitool
- source: salt://prometheus/exporters/{{ name }}/textfile_collectors/files/ipmitool
{%- if grains.os != 'Windows' %}
- mode: 755
{%- endif %}
- makedirs: True
cron.present:
- identifier: prometheus-exporters-{{ name }}-textfile_collectors-ipmitool-cronjob
- name: cd {{ dir }} && LANG=C ipmitool sensor | {{ cmd_prefix }}{{ script }} > .ipmitool.prom$$; mv .ipmitool.prom$$ ipmitool.prom

View File

@ -2,11 +2,11 @@
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set name = 'node_exporter' %}
{%- set config = p.exporters[name]['textfile_collectors']['smartmon'] %}
{%- set dir = {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
{%- set dir = p.pkg.component[name]['service']['args']['collector.textfile.directory'] %}
{%- set script = p.dir.archive ~ '/textfile_collectors/smartmon.sh' %}
prometheus-exporters-install-{{ name }}-textfile_collectors-smartmon:
@ -23,6 +23,7 @@ prometheus-exporters-install-{{ name }}-textfile_collectors-smartmon:
{%- if grains.os != 'Windows' %}
- mode: 755
{%- endif %}
- makedirs: True
cron.present:
- identifier: prometheus-exporters-{{ name }}-textfile_collectors-smartmon-cronjob
- name: cd {{ dir }} && LANG=C {{ script }} > .smartmon.prom$$ && mv .smartmon.prom$$ smartmon.prom