Puppet Class: confluent::zookeeper

Inherits:
confluent::params
Defined in:
manifests/zookeeper.pp

Overview

Class is used to install and configure Apache Zookeeper using the Confluent installation packages.

Examples:

Installation through class.

class{'confluent::zookeeper':
  zookeeper_id => '1',
  environment_settings => {
    'KAFKA_HEAP_OPTS' => {
      'value' => '-Xmx4000M'
    }
  }
}

Hiera based installation

include ::confluent::zookeeper

confluent::zookeeper::zookeeper_id: '1'
confluent::zookeeper::config:
  server.1:
    value: 'zookeeper-01.example.com:2888:3888'
  server.2:
    value: 'zookeeper-02.example.com:2888:3888'
  server.3:
    value: 'zookeeper-03.example.com:2888:3888'
confluent::zookeeper::environment_settings:
  KAFKA_HEAP_OPTS:
    value: '-Xmx4000M'

Parameters:

  • zookeeper_id (Any)

    ID of the current zookeeper node.

  • config (Any) (defaults to: {})

    Hash of configuration values.

  • environment_settings (Any) (defaults to: {})

    Hash of environment variables to set for the Kafka scripts.

  • config_path (Any) (defaults to: $::confluent::params::zookeeper_config_path)

    Location of the server.properties file for the Kafka broker.

  • environment_file (Any) (defaults to: $::confluent::params::zookeeper_environment_path)

    Location of the environment file used to pass environment variables to the Kafka broker.

  • data_path (Any) (defaults to: $::confluent::params::zookeeper_data_path)

    Location to store the data on disk.

  • log_path (Any) (defaults to: $::confluent::params::zookeeper_log_path)

    Location to write the log files to.

  • user (Any) (defaults to: $::confluent::params::zookeeper_user)

    User to run the kafka service as.

  • service_name (Any) (defaults to: $::confluent::params::zookeeper_service)

    Name of the kafka service.

  • manage_service (Any) (defaults to: $::confluent::params::zookeeper_manage_service)

    Flag to determine if the service should be managed by puppet.

  • service_ensure (Any) (defaults to: $::confluent::params::zookeeper_service_ensure)

    Ensure setting to pass to service resource.

  • service_enable (Any) (defaults to: $::confluent::params::zookeeper_service_enable)

    Enable setting to pass to service resource.

  • file_limit (Any) (defaults to: $::confluent::params::zookeeper_file_limit)

    File limit to set for the Kafka service (SystemD) only.

  • manage_repository (Any) (defaults to: $::confluent::params::manage_repository)
  • stop_timeout_secs (Any) (defaults to: $::confluent::params::zookeeper_stop_timeout_secs)
  • heap_size (Any) (defaults to: $::confluent::params::zookeeper_heap_size)


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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'manifests/zookeeper.pp', line 41

class confluent::zookeeper (
  $zookeeper_id,
  $config               = {},
  $environment_settings = {},
  $config_path          = $::confluent::params::zookeeper_config_path,
  $environment_file     = $::confluent::params::zookeeper_environment_path,
  $data_path            = $::confluent::params::zookeeper_data_path,
  $log_path             = $::confluent::params::zookeeper_log_path,
  $user                 = $::confluent::params::zookeeper_user,
  $service_name         = $::confluent::params::zookeeper_service,
  $manage_service       = $::confluent::params::zookeeper_manage_service,
  $service_ensure       = $::confluent::params::zookeeper_service_ensure,
  $service_enable       = $::confluent::params::zookeeper_service_enable,
  $file_limit           = $::confluent::params::zookeeper_file_limit,
  $manage_repository    = $::confluent::params::manage_repository,
  $stop_timeout_secs    = $::confluent::params::zookeeper_stop_timeout_secs,
  $heap_size            = $::confluent::params::zookeeper_heap_size,
) inherits confluent::params {
  include ::confluent::kafka

  if($manage_repository) {
    include ::confluent::repository
  }

  validate_hash($config)
  validate_hash($environment_settings)
  validate_absolute_path($config_path)
  validate_absolute_path($log_path)
  validate_absolute_path($config_path)

  $application_name = 'zookeeper'

  $zookeeper_default_settings = {
    'dataDir'        => {
      'value' => $data_path
    },
    'clientPort'     => {
      'value' => 2181
    },
    'maxClientCnxns' => {
      'value' => 0
    },
    'initLimit'      => {
      'value' => 5
    },
    'syncLimit'      => {
      'value' => 2
    },
    'autopurge.snapRetainCount' => {
      'value' => 10
    },
    'autopurge.purgeInterval' => {
      'value' => 1
    },
  }

  $java_default_settings = {
    'KAFKA_HEAP_OPTS' => {
      'value' => "-Xmx${heap_size}"
    },
    'KAFKA_OPTS'      => {
      'value' => '-Djava.net.preferIPv4Stack=true'
    },
    'GC_LOG_ENABLED'  => {
      'value' => true
    },
    'LOG_DIR'         => {
      'value' => $log_path
    }
  }

  $actual_zookeeper_settings = merge($zookeeper_default_settings, $config)
  $actual_java_settings = merge($java_default_settings, $environment_settings)

  $myid_file = "${data_path}/myid"

  user { $user:
    ensure => present
  } ->
  file { [$data_path, $log_path]:
    ensure  => directory,
    owner   => $user,
    group   => $user,
    recurse => true
  } ->
  file { $myid_file:
    ensure  => present,
    content => $zookeeper_id,
    mode    => '0644',
    group   => $user,
    owner   => $user
  }

  $ensure_zookeeper_settings_defaults = {
    'ensure'      => 'present',
    'path'        => $config_path,
    'application' => $application_name
  }

  ensure_resources('confluent::java_property', $actual_zookeeper_settings, $ensure_zookeeper_settings_defaults)

  $ensure_java_settings_defaults = {
    'path'        => $environment_file,
    'application' => 'zookeeper'
  }

  ensure_resources('confluent::kafka_environment_variable', $actual_java_settings, $ensure_java_settings_defaults)

  $unit_ini_setting_defaults = {
    'ensure' => 'present'
  }

  $unit_ini_settings = {
    "${service_name}/Unit/Description"        => { 'value' => 'Apache Zookeeper by Confluent', },
    "${service_name}/Unit/Wants"              => { 'value' => 'basic.target', },
    "${service_name}/Unit/After"              => { 'value' => 'basic.target network.target', },
    "${service_name}/Service/User"            => { 'value' => $user, },
    "${service_name}/Service/EnvironmentFile" => { 'value' => $environment_file, },
    "${service_name}/Service/ExecStart"       => { 'value' =>
    "/usr/bin/zookeeper-server-start ${config_path}", },
    "${service_name}/Service/ExecStop"        => { 'value' => '/usr/bin/zookeeper-server-stop', },
    "${service_name}/Service/LimitNOFILE"     => { 'value' => $file_limit, },
    "${service_name}/Service/KillMode"        => { 'value' => 'process', },
    "${service_name}/Service/RestartSec"      => { 'value' => 5, },
    "${service_name}/Service/TimeoutStopSec"  => { 'value' => $stop_timeout_secs, },
    "${service_name}/Service/Type"            => { 'value' => 'simple', },
    "${service_name}/Install/WantedBy"        => { 'value' => 'multi-user.target', },
  }

  ensure_resources('confluent::systemd::unit_ini_setting', $unit_ini_settings, $unit_ini_setting_defaults)

  if($manage_service) {
    service { $service_name:
      ensure => $service_ensure,
      enable => $service_enable
    }
  }
}