3 Star 0 Fork 0

mirrors_prometheus-community/ansible

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
node_exporter.service.j2 2.69 KB
一键复制 编辑 原始数据 按行查看 历史
SuperQ 提交于 2026-03-14 15:24 +08:00 . enhancement: Improve systemd dependencies
{{ ansible_managed | comment }}
[Unit]
Description=Prometheus Node Exporter
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User={{ node_exporter_system_user }}
Group={{ node_exporter_system_group }}
ExecStart={{ node_exporter_binary_install_dir }}/node_exporter \
{% for collector in node_exporter_enabled_collectors -%}
{% if not collector is mapping %}
'--collector.{{ collector }}' \
{% else -%}
{% set name, options = (collector.items()|list)[0] -%}
'--collector.{{ name }}' \
{% for k,v in options|dictsort %}
'--collector.{{ name }}.{{ k }}={{ v }}' \
{% endfor -%}
{% endif -%}
{% endfor -%}
{% for collector in node_exporter_disabled_collectors %}
'--no-collector.{{ collector }}' \
{% endfor %}
{% if node_exporter_tls_server_config | length > 0 or node_exporter_http_server_config | length > 0 or node_exporter_basic_auth_users | length > 0 %}
{% if node_exporter_version is version('1.5.0', '>=') %}
'--web.config.file={{ node_exporter_config_dir }}/web_config.yml' \
{% else %}
'--web.config={{ node_exporter_config_dir }}/web_config.yml' \
{% endif %}
{% endif %}
{% if node_exporter_web_disable_exporter_metrics %}
'--web.disable-exporter-metrics' \
{% endif %}
{% if node_exporter_log_level and node_exporter_log_level in ['debug', 'info', 'warn', 'error'] %}
'--log.level={{ node_exporter_log_level }}' \
{% endif %}
{% if node_exporter_log_format and node_exporter_log_format in ['logfmt', 'json'] %}
'--log.format={{ node_exporter_log_format }}' \
{% endif %}
{% if node_exporter_version is version('1.5.0', '>=') and
node_exporter_web_listen_address is iterable and
node_exporter_web_listen_address is not mapping and
node_exporter_web_listen_address is not string %}
{% for address in node_exporter_web_listen_address %}
'--web.listen-address={{ address }}' \
{% endfor %}
{% else %}
'--web.listen-address={{ node_exporter_web_listen_address }}' \
{% endif %}
'--web.telemetry-path={{ node_exporter_web_telemetry_path }}'
SyslogIdentifier=node_exporter
Restart=always
RestartSec=1
StartLimitInterval=0
{% set ns = namespace(protect_home = 'yes') %}
{% for m in ansible_facts['mounts'] if m.mount.startswith('/home') %}
{% set ns.protect_home = 'read-only' %}
{% endfor %}
{% if node_exporter_textfile_dir.startswith('/home') %}
{% set ns.protect_home = 'read-only' %}
{% endif %}
ProtectHome={{ ns.protect_home }}
NoNewPrivileges=yes
{% if (ansible_facts.packages.systemd | first).version is version('232', '>=') %}
ProtectSystem=strict
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=yes
{% else %}
ProtectSystem=full
{% endif %}
[Install]
WantedBy=multi-user.target
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_prometheus-community/ansible.git
git@gitee.com:mirrors_prometheus-community/ansible.git
mirrors_prometheus-community
ansible
ansible
main

搜索帮助