Defined Type: kafka::topic
- Defined in:
-
manifests/topic.pp
Summary
This defined type handles the creation of Kafka topics.
Overview
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'manifests/topic.pp', line 34
define kafka::topic (
String[1] $ensure = '',
String[1] $zookeeper = '',
Integer $replication_factor = 1,
Integer $partitions = 1,
String[1] $bin_dir = '/opt/kafka/bin',
Optional[Hash[String[1],String[1]]] $config = undef,
) {
$_zookeeper = "--zookeeper ${zookeeper}"
$_replication_factor = "--replication-factor ${replication_factor}"
$_partitions = "--partitions ${partitions}"
if $config {
$_config_array = $config.map |$key, $value| { "--config ${key}=${value}" }
$_config = join($_config_array, ' ')
} else {
$_config = ''
}
if $ensure == 'present' {
exec { "create topic ${name}":
path => "/usr/bin:/usr/sbin/:/bin:/sbin:${bin_dir}",
command => "kafka-topics.sh --create ${_zookeeper} ${_replication_factor} ${_partitions} --topic ${name} ${_config}",
unless => "kafka-topics.sh --list ${_zookeeper} | grep -x ${name}",
}
}
}
|