ansible-collection-prometheus/roles/nginx_exporter/templates/nginx_exporter.service.j2
gardar c9df5e56b4
refactor(nginx_exporter): delegate common tasks to _common role
Signed-off-by: gardar <gardar@users.noreply.github.com>
2024-10-15 17:08:17 +00:00

42 lines
1.2 KiB
Django/Jinja

{{ ansible_managed | comment }}
[Unit]
Description=Prometheus nginx_exporter
After=network-online.target
[Service]
Type=simple
User={{ nginx_exporter_system_user }}
Group={{ nginx_exporter_system_group }}
ExecStart={{ nginx_exporter_binary_install_dir }}/nginx-prometheus-exporter \
'--nginx.scrape-uri={{ nginx_exporter_scrape_uri }}' \
'--web.listen-address={{ nginx_exporter_web_listen_address }}' \
'--web.telemetry-path={{ nginx_exporter_web_telemetry_path }}' \
{% if nginx_exporter_tls_server_config | length > 0 or nginx_exporter_http_server_config | length > 0 or nginx_exporter_basic_auth_users | length > 0 %}
'--web.config.file={{ nginx_exporter_config_dir }}/web_config.yml' \
{% endif %}
{% if nginx_exporter_plus %}
'--nginx.plus' \
{% endif %}
'--log.level={{ nginx_exporter_log_level }}' \
'--log.format={{ nginx_exporter_log_format }}'
SyslogIdentifier=nginx_exporter
Restart=always
RestartSec=1
StartLimitInterval=0
ProtectHome=yes
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