diff --git a/REFERENCE.md b/REFERENCE.md
index f99d9cd7..1f0885b7 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -1648,7 +1648,7 @@ Default value: `$kafka::params::producer_log4j_opts`
### `kafka::topic`
-This defined type handles the creation of Kafka topics.
+ altering broker configs (e.g. specify sasl and ssl configs)
#### Examples
@@ -1674,6 +1674,7 @@ The following parameters are available in the `kafka::topic` defined type:
* [`partitions`](#-kafka--topic--partitions)
* [`bin_dir`](#-kafka--topic--bin_dir)
* [`config`](#-kafka--topic--config)
+* [`cmd_config`](#-kafka--topic--cmd_config)
##### `ensure`
@@ -1735,3 +1736,12 @@ See the Kafka documentation for full details on the topic configs.
Default value: `undef`
+##### `cmd_config`
+
+Data type: `Optional[Stdlib::Absolutepath]`
+
+Property file containing configs to be passed to Admin Client.
+This is used only with --bootstrap-server option for describing and
+
+Default value: `undef`
+
diff --git a/manifests/topic.pp b/manifests/topic.pp
index 627b1cdf..df9a5405 100644
--- a/manifests/topic.pp
+++ b/manifests/topic.pp
@@ -34,6 +34,11 @@
# A topic configuration override for the topic being created or altered.
# See the Kafka documentation for full details on the topic configs.
#
+# @param cmd_config
+# Property file containing configs to be passed to Admin Client.
+# This is used only with --bootstrap-server option for describing and
+# altering broker configs (e.g. specify sasl and ssl configs)
+#
define kafka::topic (
Optional[String[1]] $ensure = undef,
Optional[String[1]] $zookeeper = undef,
@@ -42,6 +47,7 @@
Integer $partitions = 1,
String[1] $bin_dir = '/opt/kafka/bin',
Optional[Hash[String[1],String[1]]] $config = undef,
+ Optional[Stdlib::Absolutepath] $cmd_config = undef,
) {
$_zookeeper = "--zookeeper ${zookeeper}"
$_bootstrap_server = "--bootstrap-server ${bootstrap_server}"
@@ -52,10 +58,18 @@
fail('Either zookeeper or bootstrap_server parameter must be defined!')
}
+ if $zookeeper and $cmd_config {
+ warn('cmd_config will be ignored: This is used only with bootstrap_server')
+ }
+
if $zookeeper {
$_connection = $_zookeeper
} else {
- $_connection = $_bootstrap_server
+ if $cmd_config {
+ $_connection = "${_bootstrap_server} --command-config ${cmd_config}"
+ } else {
+ $_connection = $_bootstrap_server
+ }
}
if $config {
diff --git a/spec/defines/topic_spec.rb b/spec/defines/topic_spec.rb
index 3a2637d2..db781b5f 100644
--- a/spec/defines/topic_spec.rb
+++ b/spec/defines/topic_spec.rb
@@ -78,6 +78,25 @@
)
}
end
+
+ context 'when create topic demo for kafka v3 and command-config' do
+ let(:title) { 'demo' }
+ let :params do
+ {
+ 'ensure' => 'present',
+ 'bootstrap_server' => 'localhost:9092',
+ 'replication_factor' => 1,
+ 'partitions' => 1,
+ 'cmd_config' => '/opt/kafka/config/admin.config',
+ }
+ end
+
+ it {
+ is_expected.to contain_exec('create topic demo').with(
+ command: 'kafka-topics.sh --create --bootstrap-server localhost:9092 --command-config /opt/kafka/config/admin.config --replication-factor 1 --partitions 1 --topic demo '
+ )
+ }
+ end
end
end
end