Puppet Class: confluent::schema::registry

Inherits:
confluent::params
Defined in:
manifests/schema/registry.pp

Overview

Class is used to install

Examples:

Installation through class.

class {'confluent::schema::registry':
  config => {
    'kafkastore.connection.url' => {
      'value' => 'zookeeper-01.example.com:2181,zookeeper-02.example.com:2181,zookeeper-03.example.com:2181'
    },
  },
  environment_settings => {
    'SCHEMA_REGISTRY_HEAP_OPTS' => {
      'value' => '-Xmx1024M'
    }
  }
}

Hiera based installation

include ::confluent::schema::registry

confluent::schema::registry::config:
  kafkastore.connection.url:
    value: 'zookeeper-01.example.com:2181,zookeeper-02.example.com:2181,zookeeper-03.example.com:2181'
confluent::schema::registry::environment_settings:
  SCHEMA_REGISTRY_HEAP_OPTS:
    value: -Xmx1024M

Parameters:

  • 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::schema_registry_config_path)

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

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

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

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

    Location to write the log files to.

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

    User to run the kafka service as.

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

    Name of the kafka service.

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

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

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

    Ensure setting to pass to service resource.

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

    Enable setting to pass to service resource.

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

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

  • kafkastore_connection_url (Any)
  • manage_repository (Any) (defaults to: $::confluent::params::manage_repository)
  • stop_timeout_secs (Any) (defaults to: $::confluent::params::schema_registry_stop_timeout_secs)
  • heap_size (Any) (defaults to: $::confluent::params::schema_registry_heap_size)


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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'manifests/schema/registry.pp', line 38

class confluent::schema::registry (
  $kafkastore_connection_url,
  $config               = {},
  $environment_settings = {},
  $config_path          = $::confluent::params::schema_registry_config_path,
  $environment_file     = $::confluent::params::schema_registry_environment_path,
  $log_path             = $::confluent::params::schema_registry_log_path,
  $user                 = $::confluent::params::schema_registry_user,
  $service_name         = $::confluent::params::schema_registry_service,
  $manage_service       = $::confluent::params::schema_registry_manage_service,
  $service_ensure       = $::confluent::params::schema_registry_service_ensure,
  $service_enable       = $::confluent::params::schema_registry_service_enable,
  $file_limit           = $::confluent::params::schema_registry_file_limit,
  $manage_repository    = $::confluent::params::manage_repository,
  $stop_timeout_secs    = $::confluent::params::schema_registry_stop_timeout_secs,
  $heap_size            = $::confluent::params::schema_registry_heap_size,
) inherits confluent::params {
  include ::confluent

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

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

  $application_name = 'schema-registry'

  $schemaregistry_default_settings = {
    'kafkastore.connection.url' => {
      'value' => join(any2array($kafkastore_connection_url), ',')
    }
  }

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


  $actual_schemaregistry_settings = merge($schemaregistry_default_settings, $config)
  $actual_java_settings = merge($java_default_settings, $environment_settings)

  $log4j_log_dir = $actual_java_settings['LOG_DIR']['value']
  validate_absolute_path($log4j_log_dir)

  user { $user:
    ensure => present
  } ->
  file { [$log_path]:
    ensure  => directory,
    owner   => $user,
    group   => $user,
    recurse => true
  }

  package { 'confluent-schema-registry':
    ensure => latest,
    tag    => 'confluent',
  }

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

  ensure_resources('confluent::java_property', $actual_schemaregistry_settings, $ensure_schemaregistry_settings_defaults
  )

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

  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' => 'Schema Registry 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/schema-registry-start ${config_path}", },
    "${service_name}/Service/ExecStop"        => { 'value' => '/usr/bin/schema-registry-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
    }
  }

}