Puppet Class: confluent::kafka::common

Defined in:
modules/confluent/manifests/kafka/common.pp

Overview

Class confluent::kafka::common

Installs the confluent-kafka package and a handy kafka wrapper script.

Most likely you will not use this class directly, and instead just use confluent::kafka::broker to install and start a Kafka broker. You will only use confluent::kafka::common directly if you need to change the version of java, kafka, or scala that is being installed, or if you want to install the confluent-kafka package without puppet managing a Kafka broker.

Parameters

[java_home] Path to JAVA_HOME. This class does not manage installation of Java. You must do that elsewhere. Default: undef (will use system default).

[distrubution] The Confluent Kafka distribution version to use. Defaults to '77' (Kafka 3.7)

[super_user_client_credentials_path] If super.users are set and TLS is used, instruct the kafka client wrapper script to use their credentials when issuing commands. Defaults to false.

Parameters:

  • java_home (Optional[String]) (defaults to: undef)
  • distribution (Optional[Confluent::Distribution]) (defaults to: '77')
  • user_group_id (Any) (defaults to: undef)
  • super_user_client_credentials_path (Optional[Stdlib::Unixpath]) (defaults to: undef)


27
28
29
30
31
32
33
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'modules/confluent/manifests/kafka/common.pp', line 27

class confluent::kafka::common(
    Optional[String] $java_home = undef,
    Optional[Confluent::Distribution] $distribution = '77',
    $user_group_id = undef,
    Optional[Stdlib::Unixpath] $super_user_client_credentials_path = undef,
) {
    $package_7x = 'confluent-kafka'

    # Kafka 3.7 version is shipped with Confluent 7.7
    # We currently support only two versions available to install,
    if $distribution == '77' {
        $ensure_package_77 = true
        $package = $package_7x
        ensure_resource('package', 'confluent-kafka-2.11', {'ensure' => 'absent'})
    } else {
        fail('Kafka distribution not supported.')
    }

    apt::package_from_component { 'confluent-kafka-77':
        ensure    => $ensure_package_77.bool2str('present', 'absent'),
        component => 'thirdparty/confluent77',
        packages  => [$package_7x],
    }

    # Ensure that the confluent systemd units are disabled.  The confluent-kafka
    # package installs these, and we don't want to remove their .service files
    # in case it would cause package conflicts during future upgrades, so we just
    # ensure they are not running and masked in systemd.
    #
    # work around "Error: Could not set 'mask' on enable:undefined method `mask' for Service"
    # that occurs on Jessie hosts by forcing provider => 'systemd'
    service { ['confluent-kafka', 'confluent-kafka-connect', 'confluent-zookeeper']:
        ensure   => 'stopped',
        enable   => 'mask',
        provider => 'systemd',
        require  => Package[$package],
    }

    group { 'kafka':
        ensure  => 'present',
        gid     => $user_group_id,
        system  => true,
        require => Package[$package],
    }
    # Kafka system user
    user { 'kafka':
        gid        => 'kafka',
        uid        => $user_group_id,
        shell      => '/bin/false',
        home       => '/nonexistent',
        comment    => 'Apache Kafka',
        system     => true,
        managehome => false,
        require    => Group['kafka'],
    }

    file { '/var/log/kafka':
        ensure => 'directory',
        owner  => 'kafka',
        group  => 'kafka',
        mode   => '0755',
    }

    if $distribution == '77' {
        $kafka_script = 'kafka3.sh'
        $kafka_file_source  = undef
        $kafka_file_content = template("confluent/kafka/${kafka_script}.erb")
    } else {
        fail('Kafka distribution not supported.')
    }

    file { '/usr/local/bin/kafka':
        source  => $kafka_file_source,
        content => $kafka_file_content,
        owner   => 'root',
        group   => 'root',
        mode    => '0755',
        require => Package[$package],
    }
}