AMQ Streams KRaft Role
This role orchestrates the initialization and configuration of Apache Kafka in KRaft (Kafka Raft Metadata) mode, removing the traditional dependency on ZooKeeper. It handles the mandatory bootstrapping process by generating a unique Cluster UUID (if not provided) and executing kafka-storage.sh to format the storage directories with the necessary metadata. Additionally, it prepares the critical configuration parameters required for a ZooKeeper-less environment, ensuring the correct setup of process roles, controller quorums, and the strict separation of broker and controller listeners.
Requirements
Role Dependencies:
amq_streams_common(must be run first to install the Kafka binaries).Kafka Version: Designed for Kafka 4.0.0+ or Kafka 3.x with KRaft enabled.
Role Variables
Variable |
Default Value |
Description |
|---|---|---|
|
|
The base directory where AMQ Streams/Kafka is installed. |
|
|
The absolute path to the Kafka installation home directory. |
|
|
The directory containing |
|
|
The directory where Kafka stores its KRaft metadata and log data. |
|
|
The UUID of the Kafka cluster. If left empty, the role will auto-generate a random UUID during the first run. |
|
|
The unique integer ID for this specific broker/controller node. Must be unique per host. |
|
|
Defines the role of this node. Options: |
|
|
The voter connection string in the format |
|
|
The port used for standard Client (broker) traffic. |
|
|
The port used for Controller-to-Controller Raft communication. |
|
(See defaults) |
A list of all listeners to bind. Must include both the Controller and Broker listeners (e.g., |
|
(See defaults) |
A list of listeners advertised to clients. Must ONLY include Broker listeners (e.g., |
|
|
The listener name used by the controller quorum (must match an entry in |
|
|
The listener name used for replication between brokers. |
|
|
The comma-separated list of directories for log data. Usually matches the data dir. |
|
|
The number of hours to keep log segments before deletion (Default: 7 days). |
|
|
Controls whether tasks (like creating directories and formatting storage) run with elevated privileges ( |
Example Playbook
---
- hosts: kafka_brokers
vars:
amq_streams_common_version: "3.7.0"
amq_streams_enable_kraft: true
roles:
# Install Java and Kafka Binaries
- role: amq_streams_common
# Configure and Format Storage for KRaft
- role: amq_streams_kraft
when: amq_streams_enable_kraft | bool
# Start the Kafka Service
- role: amq_streams_broker
License
Apache License v2.0 or later