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.
        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  | 
      
        # File 'manifests/zookeeper.pp', line 41
class confluent::zookeeper (
  Integer $zookeeper_id,
  Hash $config                               = {},
  Hash $environment_settings                 = {},
  Stdlib::Unixpath $config_path              = $::confluent::params::zookeeper_config_path,
  Stdlib::Unixpath $logging_config_path      = $::confluent::params::zookeeper_logging_config_path,
  Stdlib::Unixpath $environment_path         = $::confluent::params::zookeeper_environment_path,
  Stdlib::Unixpath $data_path                = $::confluent::params::zookeeper_data_path,
  Stdlib::Unixpath $log_path                 = $::confluent::params::zookeeper_log_path,
  String $user                               = $::confluent::params::zookeeper_user,
  String $service_name                       = $::confluent::params::zookeeper_service,
  Boolean $manage_service                    = $::confluent::params::zookeeper_manage_service,
  Enum['running', 'stopped'] $service_ensure = $::confluent::params::zookeeper_service_ensure,
  Boolean $service_enable                    = $::confluent::params::zookeeper_service_enable,
  Integer $file_limit                        = $::confluent::params::zookeeper_file_limit,
  Boolean $manage_repository                 = $::confluent::params::manage_repository,
  Integer $stop_timeout_secs                 = $::confluent::params::zookeeper_stop_timeout_secs,
  String $heap_size                          = $::confluent::params::zookeeper_heap_size,
  Boolean $restart_on_logging_change         = true,
  Boolean $restart_on_change                 = true
) inherits confluent::params {
  include ::confluent::kafka
  if($manage_repository) {
    include ::confluent::repository
  }
  $default_config = {
    'dataDir'                   => $data_path,
    'clientPort'                => 2181,
    'maxClientCnxns'            => 0,
    'initLimit'                 => 5,
    'syncLimit'                 => 2,
    'autopurge.snapRetainCount' => 10,
    'autopurge.purgeInterval'   => 1,
  }
  $actual_config = merge($default_config, $config)
  confluent::properties { $service_name:
    ensure => present,
    path   => $config_path,
    config => $actual_config
  }
  $default_environment_settings = {
    'KAFKA_HEAP_OPTS'  => "-Xmx${heap_size}",
    'KAFKA_OPTS'       => '-Djava.net.preferIPv4Stack=true',
    'GC_LOG_ENABLED'   => true,
    'LOG_DIR'          => $log_path,
    'KAFKA_LOG4J_OPTS' => "-Dlog4j.configuration=file:${logging_config_path}"
  }
  $actual_environment_settings = merge($default_environment_settings, $environment_settings)
  confluent::environment { $service_name:
    ensure => present,
    path   => $environment_path,
    config => $actual_environment_settings
  }
  confluent::logging { $service_name:
    path => $logging_config_path
  }
  $myid_file = "${data_path}/myid"
  user { $user:
    ensure => present
  } ->
  file { [$data_path, $log_path]:
    ensure  => directory,
    owner   => $user,
    group   => $user,
    recurse => true,
    recurselimit => 1,
    tag     => '__confluent__'
  } ->
  file { $myid_file:
    ensure  => present,
    content => inline_template("<%=@zookeeper_id%>"),
    mode    => '0644',
    group   => $user,
    owner   => $user,
    tag     => '__confluent__'
  }
  confluent::systemd::unit { $service_name:
    config => {
      'Unit'    => {
        'Description' => 'Apache Zookeeper by Confluent'
      },
      'Service' => {
        'User'            => $user,
        'EnvironmentFile' => $environment_path,
        'ExecStart'       => "/usr/bin/zookeeper-server-start ${config_path}",
        'ExecStop'        => '/usr/bin/zookeeper-server-stop',
        'LimitNOFILE'     => $file_limit,
      }
    },
  }
  if($manage_service) {
    service { $service_name:
      ensure => $service_ensure,
      enable => $service_enable,
      tag    => '__confluent__'
    }
    if($restart_on_change) {
      Confluent::Systemd::Unit[$service_name] ~> Service[$service_name]
      Confluent::Environment[$service_name] ~> Service[$service_name]
      Confluent::Properties[$service_name] ~> Service[$service_name]
      if($restart_on_logging_change) {
        Confluent::Logging[$service_name] ~> Service[$service_name]
      }
    }
  }
}
       |