Skip to content

Node Exporter Ansible Role

An Ansible role to install, configure and manage Prometheus node_exporter on systemd-enabled Debian-based systems.

Features

  • Install node_exporter from official GitHub releases (amd64 and arm64)
  • Manage systemd service (enable/disable, start/stop, restart)
  • Version pinning support
  • Optional bind address and extra binary options
  • Clean uninstall

Installation

Add the role to your requirements.yml:

roles:
  - name: node_exporter
    src: https://gitlab.com/niclas-zone/tools/ansible/roles/node_exporter.git
    scm: git

Install from the requirements file:

ansible-galaxy install -r requirements.yml --force

Role Variables

Variable Default Value Type Description
node_exporter_version 1.10.2 string Release tag of node_exporter to install
node_exporter_arch amd64 string Target architecture (amd64 or arm64)
node_exporter_bin_path /usr/local/bin/node_exporter string Full path where the binary will be placed
node_exporter_host `` string Bind address; set to localhost to restrict to loopback
node_exporter_port 9100 integer TCP port for the exporter
node_exporter_options `` string Extra command-line options passed to the binary
node_exporter_state started string Service state (started, stopped; use absent to remove files)
node_exporter_enabled true boolean Enable service at boot
node_exporter_restart on-failure string systemd Restart= policy
node_exporter_sv_user node_exporter string System user the service runs as
node_exporter_uid (unset) integer Optional UID for the node_exporter user
node_exporter_gid (unset) integer Optional GID for the node_exporter user

Role defaults are in defaults/main.yml — adjust variables there or pass via playbook vars.

Example Playbooks

Basic Installation

---
- hosts: servers
  become: true
  roles:
    - role: node_exporter

Install a specific version and bind to localhost

---
- hosts: servers
  become: true
  roles:
    - role: node_exporter
      vars:
        node_exporter_version: "1.9.0"
        node_exporter_host: "127.0.0.1"

Uninstall

---
- hosts: servers
  become: true
  roles:
    - role: node_exporter
      vars:
        node_exporter_state: absent

Service Management

The role installs a systemd unit at /etc/systemd/system/node_exporter.service.

Use standard systemd commands:

systemctl start node_exporter
systemctl enable node_exporter
systemctl status node_exporter
journalctl -u node_exporter -f

Requirements

  • Ansible 2.9+
  • Linux system with systemd

Supported Architectures

  • amd64 (x86_64)
  • arm64 (aarch64)

License

See LICENSE file in the role repository.