From 9e994b5235c8def3be2c886cffc8164a846a9ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jadyn=20Emma=20J=C3=A4ger?= Date: Fri, 25 Aug 2023 20:42:47 +0200 Subject: [PATCH] feat(blackbox_exporter): add web_config option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jadyn Emma Jäger --- roles/blackbox_exporter/defaults/main.yml | 5 +++++ roles/blackbox_exporter/tasks/configure.yml | 10 ++++++++++ .../templates/blackbox_exporter.service.j2 | 1 + 3 files changed, 16 insertions(+) diff --git a/roles/blackbox_exporter/defaults/main.yml b/roles/blackbox_exporter/defaults/main.yml index b3727eb53..696da11ca 100644 --- a/roles/blackbox_exporter/defaults/main.yml +++ b/roles/blackbox_exporter/defaults/main.yml @@ -8,6 +8,11 @@ blackbox_exporter_checksums_url: "https://github.com/{{ _blackbox_exporter_repo blackbox_exporter_skip_install: false blackbox_exporter_web_listen_address: "0.0.0.0:9115" +blackbox_exporter_web_config: + tls_server_config: {} + http_server_config: {} + basic_auth_users: {} + blackbox_exporter_user: blackbox-exp blackbox_exporter_group: "{{ blackbox_exporter_user }}" diff --git a/roles/blackbox_exporter/tasks/configure.yml b/roles/blackbox_exporter/tasks/configure.yml index c4dd1aeea..75e88b985 100644 --- a/roles/blackbox_exporter/tasks/configure.yml +++ b/roles/blackbox_exporter/tasks/configure.yml @@ -18,3 +18,13 @@ mode: 0644 notify: - reload blackbox_exporter + +- name: Configure blackbox_exporter web + ansible.builtin.copy: + content: "{{ blackbox_exporter_web_config | to_nice_yaml(indent=2, sort_keys=False) }}" + dest: "{{ blackbox_exporter_config_dir }}/web.yml" + owner: root + group: "{{ blackbox_exporter_group }}" + mode: 0644 + notify: + - reload blackbox_exporter diff --git a/roles/blackbox_exporter/templates/blackbox_exporter.service.j2 b/roles/blackbox_exporter/templates/blackbox_exporter.service.j2 index 0a0ff42d4..f24f1906e 100644 --- a/roles/blackbox_exporter/templates/blackbox_exporter.service.j2 +++ b/roles/blackbox_exporter/templates/blackbox_exporter.service.j2 @@ -13,6 +13,7 @@ PermissionsStartOnly=true ExecReload=/bin/kill -HUP $MAINPID ExecStart=/usr/local/bin/blackbox_exporter \ --config.file={{ blackbox_exporter_config_dir }}/blackbox_exporter.yml \ + --web.config.file={{ blackbox_exporter_config_dir }}/web.yml \ {% for flag, flag_value in blackbox_exporter_cli_flags.items() -%} --{{ flag }}={{ flag_value }} \ {% endfor -%}