mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 11:53:12 +00:00
330e66a75d
Signed-off-by: gardar <gardar@users.noreply.github.com>
64 lines
2.1 KiB
Django/Jinja
64 lines
2.1 KiB
Django/Jinja
{{ ansible_managed | comment }}
|
|
|
|
[Unit]
|
|
Description=Prometheus MySQLd Exporter
|
|
After=network-online.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User={{ mysqld_exporter_system_user }}
|
|
Group={{ mysqld_exporter_system_group }}
|
|
ExecStart={{ mysqld_exporter_binary_install_dir }}/mysqld_exporter \
|
|
{% for collector in mysqld_exporter_enabled_collectors -%}
|
|
{% if not collector is mapping %}
|
|
--collect.{{ collector }} \
|
|
{% else -%}
|
|
{% set name, options = (collector.items()|list)[0] -%}
|
|
--collect.{{ name }} \
|
|
{% for k,v in options|dictsort %}
|
|
--collect.{{ name }}.{{ k }}={{ v | quote }} \
|
|
{% endfor -%}
|
|
{% endif -%}
|
|
{% endfor -%}
|
|
{% for collector in mysqld_exporter_disabled_collectors %}
|
|
--no-collect.{{ collector }} \
|
|
{% endfor %}
|
|
{% if mysqld_exporter_tls_server_config | length > 0 or mysqld_exporter_http_server_config | length > 0 or mysqld_exporter_basic_auth_users | length > 0 %}
|
|
--web.config.file={{ mysqld_exporter_config_dir }}/web_config.yml \
|
|
{% endif %}
|
|
{% if mysqld_exporter_version is version('0.15.0', '>=') and
|
|
mysqld_exporter_web_listen_address is iterable and
|
|
mysqld_exporter_web_listen_address is not mapping and
|
|
mysqld_exporter_web_listen_address is not string %}
|
|
{% for address in mysqld_exporter_web_listen_address %}
|
|
--web.listen-address={{ address }} \
|
|
{% endfor %}
|
|
{% else %}
|
|
--web.listen-address={{ mysqld_exporter_web_listen_address }} \
|
|
{% endif %}
|
|
--web.telemetry-path={{ mysqld_exporter_web_telemetry_path }} \
|
|
--config.my-cnf={{ mysqld_exporter_config_dir }}/{{ mysqld_exporter_config_file }}
|
|
|
|
SyslogIdentifier=mysqld_exporter
|
|
Restart=always
|
|
RestartSec=1
|
|
StartLimitInterval=0
|
|
|
|
{% set protect_home = 'yes' %}
|
|
{% for m in ansible_mounts if m.mount.startswith('/home') %}
|
|
{% set protect_home = 'read-only' %}
|
|
{% endfor %}
|
|
ProtectHome={{ 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
|