File tree Expand file tree Collapse file tree 3 files changed +45
-2
lines changed
Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -1648,7 +1648,7 @@ Default value: `$kafka::params::producer_log4j_opts`
16481648
16491649### <a name =" kafka--topic " ></a >` kafka::topic `
16501650
1651- This defined type handles the creation of Kafka topics.
1651+ altering broker configs (e.g. specify sasl and ssl configs)
16521652
16531653#### Examples
16541654
@@ -1674,6 +1674,7 @@ The following parameters are available in the `kafka::topic` defined type:
16741674* [ ` partitions ` ] ( #-kafka--topic--partitions )
16751675* [ ` bin_dir ` ] ( #-kafka--topic--bin_dir )
16761676* [ ` config ` ] ( #-kafka--topic--config )
1677+ * [ ` cmd_config ` ] ( #-kafka--topic--cmd_config )
16771678
16781679##### <a name =" -kafka--topic--ensure " ></a >` ensure `
16791680
@@ -1735,3 +1736,12 @@ See the Kafka documentation for full details on the topic configs.
17351736
17361737Default value: ` undef `
17371738
1739+ ##### <a name =" -kafka--topic--cmd_config " ></a >` cmd_config `
1740+
1741+ Data type: ` Optional[Stdlib::Absolutepath] `
1742+
1743+ Property file containing configs to be passed to Admin Client.
1744+ This is used only with --bootstrap-server option for describing and
1745+
1746+ Default value: ` undef `
1747+
Original file line number Diff line number Diff line change 3434# A topic configuration override for the topic being created or altered.
3535# See the Kafka documentation for full details on the topic configs.
3636#
37+ # @param cmd_config
38+ # Property file containing configs to be passed to Admin Client.
39+ # This is used only with --bootstrap-server option for describing and
40+ # altering broker configs (e.g. specify sasl and ssl configs)
41+ #
3742define kafka::topic (
3843 Optional[String[1]] $ensure = undef ,
3944 Optional[String[1]] $zookeeper = undef ,
4247 Integer $partitions = 1,
4348 String[1] $bin_dir = ' /opt/kafka/bin' ,
4449 Optional[Hash[String[1],String[1]]] $config = undef ,
50+ Optional[Stdlib::Absolutepath] $cmd_config = undef ,
4551) {
4652 $_zookeeper = " --zookeeper ${zookeeper} "
4753 $_bootstrap_server = " --bootstrap-server ${bootstrap_server} "
5258 fail(' Either zookeeper or bootstrap_server parameter must be defined!' )
5359 }
5460
61+ if $zookeeper and $cmd_config {
62+ warn(' cmd_config will be ignored: This is used only with bootstrap_server' )
63+ }
64+
5565 if $zookeeper {
5666 $_connection = $_zookeeper
5767 } else {
58- $_connection = $_bootstrap_server
68+ $_connection = if $cmd_config {
69+ " ${_bootstrap_server} --command-config ${cmd_config} "
70+ } else {
71+ $_bootstrap_server
72+ }
5973 }
6074
6175 if $config {
Original file line number Diff line number Diff line change 7878 )
7979 }
8080 end
81+
82+ context 'when create topic demo for kafka v3 and command-config' do
83+ let ( :title ) { 'demo' }
84+ let :params do
85+ {
86+ 'ensure' => 'present' ,
87+ 'bootstrap_server' => 'localhost:9092' ,
88+ 'replication_factor' => 1 ,
89+ 'partitions' => 1 ,
90+ 'cmd_config' => '/opt/kafka/config/admin.config' ,
91+ }
92+ end
93+
94+ it {
95+ is_expected . to contain_exec ( 'create topic demo' ) . with (
96+ command : 'kafka-topics.sh --create --bootstrap-server localhost:9092 --command-config /opt/kafka/config/admin.config --replication-factor 1 --partitions 1 --topic demo '
97+ )
98+ }
99+ end
81100 end
82101 end
83102end
You can’t perform that action at this time.
0 commit comments