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).

kafka_version

Ensure this version of a confluent-kafka package is installed. Default: undef

scala_version

Package confluent-kafka-$scala_version will be installed. Default: 2.11

Parameters:

  • java_home (Any) (defaults to: undef)
  • kafka_version (Any) (defaults to: undef)
  • scala_version (Any) (defaults to: '2.11')


26
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'modules/confluent/manifests/kafka/common.pp', line 26

class confluent::kafka::common(
    $java_home     = undef,
    $kafka_version = undef,
    $scala_version = '2.11'
) {
    $package = "confluent-kafka-${scala_version}"

    if os_version('debian >= stretch') {
        apt::repository { 'thirdparty-confluent':
            uri        => 'http://apt.wikimedia.org/wikimedia',
            dist       => "${::lsbdistcodename}-wikimedia",
            components => 'thirdparty/confluent',
        }

        # If $kafka_version was given,
        # make sure that a specific debian package version was installed.
        if !$kafka_version {
            package { $package:
                require => [ Apt::Repository['thirdparty-confluent'], Exec['apt-get update']],
            }
        }
        else {
            package { $package:
                ensure  => $kafka_version,
                require => [ Apt::Repository['thirdparty-confluent'], Exec['apt-get update']],
            }
        }
    } else {
        # Kafka Confluent packages in Debian Jessie do not have a special
        # component, but they are stored under thirdparty.
        # TODO: removed this conditional after the Kafka Analytics cluster
        # is decommed (last Jessie cluster).
        # T198092
        if !$kafka_version {
            package { $package:
                require => [ Exec['apt-get update']],
            }
        }
        else {
            package { $package:
                ensure  => $kafka_version,
                require => [ Exec['apt-get update']],
            }
        }
    }

    # TODO: Remove this conditional after Kafka has been upgraded everywhere in T167039.
    # Once we are on a confluent package with $scala_version == 2.11, we know that
    # we will be using a package that installs systemd units.
    if $scala_version == '2.11' {
        # 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',
        system  => true,
        require => Package[$package],
    }
    # Kafka system user
    user { 'kafka':
        gid        => 'kafka',
        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',
    }

    file { '/usr/local/bin/kafka':
        source  => 'puppet:///modules/confluent/kafka/kafka.sh',
        owner   => 'root',
        group   => 'root',
        mode    => '0755',
        require => Package[$package],
    }

    # Have puppet manage totally manage this directory.
    # Anything it doesn't know about will be removed.
    file { '/etc/kafka/mirror':
        ensure  => 'directory',
        owner   => 'kafka',
        group   => 'kafka',
        recurse => true,
        purge   => true,
        force   => true,
        require => Package[$package],
    }
}