Influxdb
This role installs and configures InfluxDB 1.x time-series database on RedHat-based systems.
Overview
This role installs and configures InfluxDB 1.x time-series database on RedHat-based systems. It adds the official InfluxData repository, installs InfluxDB, configures HTTP/UDP/logging settings, creates databases with users and grants privileges, sets up retention policies for data lifecycle management, and ensures the service is enabled and started. The role is fully idempotent and checks for existing resources before creating them.
What This Role Does
-
Adds InfluxData repository
- URL: https://repos.influxdata.com/rhel/
- Enables GPG verification
-
Installs InfluxDB package via dnf/yum
- Version 1.x from official repository
-
Configures HTTP API in
/etc/influxdb/influxdb.conf:- Bind address
- Access logging
- Enables/disables HTTP endpoint
-
Configures logging:
- Format (logfmt or json)
- Level (error, warn, info, debug)
- Logo suppression
-
Configures UDP input (if enabled):
- Bind address
- Default database for UDP writes
-
Starts and enables service:
- Starts InfluxDB
- Ensures InfluxDB starts on boot
-
Waits for InfluxDB to be ready (port 8086)
-
Checks existing users (idempotent):
- Queries:
SHOW USERS - Parses JSON response
- Queries:
-
Creates users:
- Only creates if not exists
- Uses passwords from vault
-
Checks existing databases (idempotent):
- Queries:
SHOW DATABASES - Parses JSON response
- Queries:
-
Creates databases:
- Only creates if not exists
-
Grants privileges:
GRANT ALL ON database TO user
-
Checks existing retention policies:
- Queries:
SHOW RETENTION POLICIES ON database
- Queries:
-
Creates retention policies:
- Only creates if not exists
- Sets as default if specified
Role Variables
| Variable | Description |
|---|---|
influxdb_databases | List of databases to create; each entry supports an optional user (with password) and an optional retention_policy |
influxdb_service_enabled | Enable InfluxDB service to start on boot |
influxdb_service_state | Desired service state after role execution |
influxdb_http_enabled | Enable HTTP API |
influxdb_http_bind_address | HTTP API bind address |
influxdb_http_log_enabled | Enable HTTP request logging |
influxdb_http_access_log_path | Path to HTTP access log file |
influxdb_udp_enabled | Enable UDP input listener |
influxdb_udp_bind_address | UDP listener bind address |
influxdb_udp_database | Default database for UDP writes |
influxdb_logging_level | Log level |
influxdb_logging_format | Log output format (logfmt or json) |
influxdb_logging_suppress_logo | Suppress InfluxDB startup logo in logs |
Database definition structure:
influxdb_databases:
- name: homelab
user: telegraf
password: "{{ vault_influxdb_telegraf_password }}"
retention_policy:
name: thirty_days
duration: 30d
replication: 1
default: true
- name: opnsense
retention_policy:
name: ninety_days
duration: 90d
replication: 1
default: true
Notes
- Supports InfluxDB 1.x only (InfluxQL query language)
- Typically used as the backend for the Telegraf → InfluxDB → Grafana monitoring stack