diff options
Diffstat (limited to 'roles/monitoring/prometheus/exporter/bind')
4 files changed, 93 insertions, 0 deletions
diff --git a/roles/monitoring/prometheus/exporter/bind/defaults/main.yml b/roles/monitoring/prometheus/exporter/bind/defaults/main.yml new file mode 100644 index 00000000..66a6fcc9 --- /dev/null +++ b/roles/monitoring/prometheus/exporter/bind/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# prometheus_exporter_bind_version: + +prometheus_exporter_bind_stats_version: auto + +prometheus_exporter_bind_stats_groups: + - server + - view + - tasks diff --git a/roles/monitoring/prometheus/exporter/bind/handlers/main.yml b/roles/monitoring/prometheus/exporter/bind/handlers/main.yml new file mode 100644 index 00000000..5fa1f04d --- /dev/null +++ b/roles/monitoring/prometheus/exporter/bind/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: restart prometheus-bind-exporter + service: + name: prometheus-bind-exporter + state: restarted + +- name: reload nginx + service: + name: nginx + state: reloaded diff --git a/roles/monitoring/prometheus/exporter/bind/tasks/main.yml b/roles/monitoring/prometheus/exporter/bind/tasks/main.yml new file mode 100644 index 00000000..1ac4b8d7 --- /dev/null +++ b/roles/monitoring/prometheus/exporter/bind/tasks/main.yml @@ -0,0 +1,44 @@ +--- +- name: generate apt pin file for exporter-bind package + when: prometheus_exporter_bind_version is defined + copy: + dest: "/etc/apt/preferences.d/prom-exporter-bind.pref" + content: | + Package: prom-exporter-bind + Pin: version {{ prometheus_exporter_bind_version }}-1 + Pin-Priority: 1001 + +- name: remove apt pin file for exporter-bind package + when: prometheus_exporter_bind_version is not defined + file: + path: "/etc/apt/preferences.d/prom-exporter-bind.pref" + state: absent + +- name: install apt packages + apt: + name: "prom-exporter-bind{% if prometheus_exporter_bind_version is defined %}={{ prometheus_exporter_bind_version }}-1{% endif %}" + state: present + allow_downgrade: yes + notify: restart prometheus-bind-exporter + +- name: generate systemd service unit + template: + src: service.j2 + dest: /etc/systemd/system/prometheus-bind-exporter.service + notify: restart prometheus-bind-exporter + +- name: make sure prometheus-bind-exporter is enabled and started + systemd: + name: prometheus-bind-exporter.service + daemon_reload: yes + state: started + enabled: yes + +- name: register exporter + copy: + content: | + location = /bind { + proxy_pass http://127.0.0.1:9119/metrics; + } + dest: /etc/prometheus/exporter/bind.locations + notify: reload nginx diff --git a/roles/monitoring/prometheus/exporter/bind/templates/service.j2 b/roles/monitoring/prometheus/exporter/bind/templates/service.j2 new file mode 100644 index 00000000..853fee18 --- /dev/null +++ b/roles/monitoring/prometheus/exporter/bind/templates/service.j2 @@ -0,0 +1,30 @@ +[Unit] +Description=Prometheus bind exporter + +[Service] +Restart=always +User=prometheus-exporter +ExecStart=/usr/bin/prometheus-bind-exporter --web.listen-address="127.0.0.1:9119" --bind.stats-version="{{ prometheus_exporter_bind_stats_version }}" --bind.stats-groups="{{ prometheus_exporter_bind_stats_groups | join(',') }}" + +# systemd hardening-options +AmbientCapabilities= +CapabilityBoundingSet= +DeviceAllow=/dev/null rw +DevicePolicy=strict +LockPersonality=true +MemoryDenyWriteExecute=true +NoNewPrivileges=true +PrivateDevices=true +PrivateTmp=true +ProtectControlGroups=true +ProtectHome=true +ProtectKernelModules=true +ProtectKernelTunables=true +ProtectSystem=strict +RemoveIPC=true +RestrictNamespaces=true +RestrictRealtime=true +SystemCallArchitectures=native + +[Install] +WantedBy=multi-user.target |