Deploy Blackbox Exporter using Ansible on Ubuntu 22.04 LTS


Blackbox Exporter is a component of the Prometheus monitoring system that allows you to perform active monitoring of network endpoints. It is designed to probe targets and collect metrics related to their availability, responsiveness, and other network-level characteristics.


  • Up and running ubuntu 22.04 LTS machine.
  • Basic knowledge in linux commands.
  • Internet connectivity.
  • Ansible should be installed.

We can use the given link to install Ansible on Ubuntu 22.04 LTS Linux machine.

In this post, We will show you how to deploy Blackbox Exporter using Ansible-play on ubuntu 22.04 LTS Linux machine.

Step 1: Create an Ansible inventory file

To deploy Blackbox Exporter using Ansible on Ubuntu 22.04 LTS, you can create an Ansible playbook that installs and configures Blackbox Exporter. Blackbox Exporter is a tool for probing endpoints over HTTP, HTTPS, DNS, TCP, and ICMP to collect metrics.

To create ansible playbook

sudo nano deploy_blackbox_exporter.yml

Paste the following ansible tasks.

- name: Deploy Blackbox Exporter
  hosts: your_target_servers
  become: true

    - name: Create Blackbox Exporter user
        name: blackbox_exporter
        system: yes
        shell: /bin/false

    - name: Download and extract Blackbox Exporter
        url: ""
        dest: "/tmp/blackbox_exporter.tar.gz"

    - name: Extract Blackbox Exporter
        src: "/tmp/blackbox_exporter.tar.gz"
        dest: "/opt/"

    - name: Set permissions and ownership
        path: "/opt/blackbox_exporter-0.21.0.linux-amd64/blackbox_exporter"
        mode: "0755"
        owner: "blackbox_exporter"
        group: "blackbox_exporter"

    - name: Create Blackbox Exporter configuration directory
        path: "/etc/blackbox_exporter"
        state: directory
        mode: "0755"
        owner: "blackbox_exporter"
        group: "blackbox_exporter"

    - name: Copy Blackbox Exporter configuration file
        src: "blackbox.yml"
        dest: "/etc/blackbox_exporter/blackbox.yml"
        owner: "blackbox_exporter"
        group: "blackbox_exporter"
        mode: "0644"

    - name: Create Blackbox Exporter systemd service
        name: blackbox_exporter
        enabled: yes
        state: started
        daemon_reload: yes
        daemon_reexec: yes
        scope: user
        user: blackbox_exporter
        exec_start: "/opt/blackbox_exporter-0.21.0.linux-amd64/blackbox_exporter --config.file=/etc/blackbox_exporter/blackbox.yml"

This playbook does the following:

  • Creates a user named blackbox_exporter for running Blackbox Exporter.
  • Downloads the Blackbox Exporter binary from the official GitHub release page.
  • Extracts the Blackbox Exporter tarball to the /opt/ directory.
  • Sets the necessary permissions and ownership for the Blackbox Exporter binary.
  • Creates the Blackbox Exporter configuration directory and copies the configuration file (blackbox.yml) to the appropriate location
  • Creates a systemd service for Blackbox Exporter and starts it.

Make sure to replace your_target_servers with the target servers or server group where you want to install Blackbox Exporter.

Create an Ansible inventory file (e.g., inventory.ini) with the IP addresses or hostnames of your target servers.

Step 2: Run the Ansible playbook

We need to execute the following command to deploy the ansible playbook.

ansible-playbook -i inventory.ini deploy_blackbox_exporter.yml

Adjust the version number in the URL to the latest version available on the Blackbox Exporter GitHub releases page. Additionally, provide a valid blackbox.yml configuration file suitable for your environment.

You can use the end to end Prometheus Blackbox setup and configuration by using given link 🙂


We have successfully deployed Blackbox using Ansible Playbook on Ubuntu 22.04 LTS. If you are still having issues, please leave a comment below.


Deploy Blackbox Exporter using Ansible on Ubuntu 22.04 LTS

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top