r/blackbox-exporter: Rework to run as container

Instead of downloading the `blackbox_exporter` binary from GitHub and
copying it to the managed node, the _blackbox-exporter_ role now
installs _podman_ and configures a systemd container unit (Quadlet) to
run it in a container.  This simplifies the deployment considerably, and
will make updating easier (just run the playbook with `-e
blackbox_exporter_pull_image=true`).
This commit is contained in:
2025-01-23 21:56:16 -06:00
parent 81663a654d
commit dcf1e5adfc
6 changed files with 65 additions and 79 deletions

View File

@@ -1,3 +1,26 @@
- name: ensure blackbox container is present
podman_image:
name: '{{ blackbox_container_image_name }}'
tag: '{{ blackbox_container_image_tag }}'
state: present
pull: '{{ blackbox_exporter_pull_image|d(false)|bool }}'
notify:
- reload systemd
- restart blackbox-exporter
tags:
- container
- name: ensure blackbox-exporter system container is configured
template:
src: blackbox-exporter.container.j2
dest: /etc/containers/systemd/blackbox-exporter.container
mode: u=rw,go=r
owner: root
group: root
notify:
- reload systemd
- restart blackbox-exporter
- name: ensure /etc/prometheus directory exists
file:
path: /etc/prometheus
@@ -6,7 +29,7 @@
group: root
state: directory
- name: ensure blackbox_exporter is configured
- name: ensure blackbox-exporter is configured
copy:
dest: /etc/prometheus/blackbox.yml
content: |
@@ -15,19 +38,22 @@
owner: root
group: root
notify:
- reload blackbox_exporter
- reload blackbox-exporter
- name: ensure blackbox_exporter starts at boot
- name: flush handlers
meta: flush_handlers
- name: ensure blackbox-exporter starts at boot
service:
name: blackbox_exporter
name: blackbox-exporter
enabled: true
tags:
- service
- name: flush_handlers
meta: flush_handlers
- name: ensure blackbox_exporter is running
- name: ensure blackbox-exporter is running
service:
name: blackbox_exporter
name: blackbox-exporter
state: started
tags:
- service