Skip to content

Commit

Permalink
enhancement(node_exporter): use systemd to create node_exporter_textf…
Browse files Browse the repository at this point in the history
…ile_dir if it

doesn't exist

Signed-off-by: Siyuan Miao <[email protected]>
  • Loading branch information
ym committed Mar 24, 2024
1 parent c72059f commit 59516b5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions roles/node_exporter/templates/node_exporter.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ After=network-online.target
Type=simple
User={{ node_exporter_system_user }}
Group={{ node_exporter_system_group }}
{% if node_exporter_textfile_dir | length > 0 %}
{% if (ansible_facts.packages.systemd | first).version is version('235', '>=') %}
ExecStartPre=+/bin/mkdir -p {{ node_exporter_textfile_dir }}
ExecStartPre=+/bin/chown -R {{ node_exporter_system_user }}:{{ node_exporter_system_group }} {{ node_exporter_textfile_dir }}
{% else %}
ExecStartPre=/bin/mkdir -p {{ node_exporter_textfile_dir }}
ExecStartPre=/bin/chown -R {{ node_exporter_system_user }}:{{ node_exporter_system_group }} {{ node_exporter_textfile_dir }}
PermissionsStartOnly=true
{% endif %}
{% endif %}
ExecStart={{ node_exporter_binary_install_dir }}/node_exporter \
{% for collector in node_exporter_enabled_collectors -%}
{% if not collector is mapping %}
Expand Down

0 comments on commit 59516b5

Please sign in to comment.