Commit 4968df3 1 parent bf54af5 commit 4968df3 Copy full SHA for 4968df3
File tree 3 files changed +45
-2
lines changed
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`
1648
1648
1649
1649
### <a name =" kafka--topic " ></a >` kafka::topic `
1650
1650
1651
- This defined type handles the creation of Kafka topics.
1651
+ altering broker configs (e.g. specify sasl and ssl configs)
1652
1652
1653
1653
#### Examples
1654
1654
@@ -1674,6 +1674,7 @@ The following parameters are available in the `kafka::topic` defined type:
1674
1674
* [ ` partitions ` ] ( #-kafka--topic--partitions )
1675
1675
* [ ` bin_dir ` ] ( #-kafka--topic--bin_dir )
1676
1676
* [ ` config ` ] ( #-kafka--topic--config )
1677
+ * [ ` cmd_config ` ] ( #-kafka--topic--cmd_config )
1677
1678
1678
1679
##### <a name =" -kafka--topic--ensure " ></a >` ensure `
1679
1680
@@ -1735,3 +1736,12 @@ See the Kafka documentation for full details on the topic configs.
1735
1736
1736
1737
Default value: ` undef `
1737
1738
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 34
34
# A topic configuration override for the topic being created or altered.
35
35
# See the Kafka documentation for full details on the topic configs.
36
36
#
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
+ #
37
42
define kafka::topic (
38
43
Optional[String[1]] $ensure = undef ,
39
44
Optional[String[1]] $zookeeper = undef ,
42
47
Integer $partitions = 1,
43
48
String[1] $bin_dir = ' /opt/kafka/bin' ,
44
49
Optional[Hash[String[1],String[1]]] $config = undef ,
50
+ Optional[Stdlib::Absolutepath] $cmd_config = undef ,
45
51
) {
46
52
$_zookeeper = " --zookeeper ${zookeeper} "
47
53
$_bootstrap_server = " --bootstrap-server ${bootstrap_server} "
52
58
fail(' Either zookeeper or bootstrap_server parameter must be defined!' )
53
59
}
54
60
61
+ if $zookeeper and $cmd_config {
62
+ warn(' cmd_config will be ignored: This is used only with bootstrap_server' )
63
+ }
64
+
55
65
if $zookeeper {
56
66
$_connection = $_zookeeper
57
67
} else {
58
- $_connection = $_bootstrap_server
68
+ if $cmd_config {
69
+ $_connection = " ${_bootstrap_server} --command-config ${cmd_config} "
70
+ } else {
71
+ $_connection = $_bootstrap_server
72
+ }
59
73
}
60
74
61
75
if $config {
Original file line number Diff line number Diff line change 78
78
)
79
79
}
80
80
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 #{ title } " ) . with (
96
+ command : "kafka-topics.sh --create --bootstrap-server #{ params [ :bootstrap_server ] } --command-config #{ params [ :cmd_config ] } --replication-factor #{ params [ :replication_factor ] } --partitions #{ params [ :partitions ] } --topic #{ title } "
97
+ )
98
+ }
99
+ end
81
100
end
82
101
end
83
102
end
You can’t perform that action at this time.
0 commit comments