Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add admin server options from ZK 3.5.5 #136

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
}

if $::zookeeper::service_provider != 'exhibitor' {
$enable_admin_server = versioncmp($::zookeeper::archive_version, '3.5.5') >= 0
file { "${::zookeeper::cfg_dir}/zoo.cfg":
owner => $::zookeeper::user,
group => $::zookeeper::group,
Expand Down
26 changes: 16 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,22 @@
String $tracefile_threshold = $::zookeeper::params::tracefile_threshold,
String $console_threshold = $::zookeeper::params::console_threshold,
# sasl options
Hash[String, String] $sasl_users = $::zookeeper::params::sasl_users,
String $keytab_path = $::zookeeper::params::keytab_path,
String $principal = $::zookeeper::params::principal,
String $realm = $::zookeeper::params::realm,
Boolean $sasl_krb5 = $::zookeeper::params::sasl_krb5,
Boolean $store_key = $::zookeeper::params::store_key,
Boolean $use_keytab = $::zookeeper::params::use_keytab,
Boolean $use_ticket_cache = $::zookeeper::params::use_ticket_cache,
Boolean $remove_host_principal = $::zookeeper::params::remove_host_principal,
Boolean $remove_realm_principal = $::zookeeper::params::remove_realm_principal,
Hash[String, String] $sasl_users = $::zookeeper::params::sasl_users,
String $keytab_path = $::zookeeper::params::keytab_path,
String $principal = $::zookeeper::params::principal,
String $realm = $::zookeeper::params::realm,
Boolean $sasl_krb5 = $::zookeeper::params::sasl_krb5,
Boolean $store_key = $::zookeeper::params::store_key,
Boolean $use_keytab = $::zookeeper::params::use_keytab,
Boolean $use_ticket_cache = $::zookeeper::params::use_ticket_cache,
Boolean $remove_host_principal = $::zookeeper::params::remove_host_principal,
Boolean $remove_realm_principal = $::zookeeper::params::remove_realm_principal,
# admin server options
Boolean $admin_enable_server = $::zookeeper::params::admin_enable_server,
String $admin_server_address = $::zookeeper::params::admin_server_address,
Integer $admin_server_port = $::zookeeper::params::admin_server_port,
Integer $admin_idle_timeout = $::zookeeper::params::admin_idle_timeout,
String $admin_command_url = $::zookeeper::params::admin_command_url,
# four letter words whitelist
Array[String] $whitelist_4lw = $::zookeeper::params::whitelist_4lw,
) inherits ::zookeeper::params {
Expand Down
8 changes: 8 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@
$use_ticket_cache = false
$remove_host_principal = false
$remove_realm_principal = false

# admin server options
$admin_enable_server = true
$admin_server_address = '0.0.0.0'
$admin_server_port = 8080
$admin_idle_timeout = 30000
$admin_command_url = '/commands'

# whitelist of Four Letter Words commands, see https://zookeeper.apache.org/doc/r3.4.12/zookeeperAdmin.html#sc_zkCommands
$whitelist_4lw = []
}
56 changes: 56 additions & 0 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,62 @@
end
end

context 'admin server options' do
enable = false
port = '3000'
url = '/alternative'
let :pre_condition do
"class {'zookeeper':
archive_version => '3.5.5',
admin_enable_server => #{enable},
admin_server_port => #{port},
admin_command_url => '#{url}'
}"
end

it do
is_expected.to contain_file(
'/etc/zookeeper/conf/zoo.cfg'
).with_content(/admin.enableServer=#{enable}/)

is_expected.to contain_file(
'/etc/zookeeper/conf/zoo.cfg'
).with_content(/admin.serverPort=#{port}/)

is_expected.to contain_file(
'/etc/zookeeper/conf/zoo.cfg'
).with_content(/admin.commandURL=#{url}/)
end
end

context 'admin server disables if version < 3.5.5' do
enable = false
port = '3000'
url = '/alternative'
let :pre_condition do
"class {'zookeeper':
archive_version => '3.5.4',
admin_enable_server => #{enable},
admin_server_port => #{port},
admin_command_url => '#{url}'
}"
end

it do
is_expected.to contain_file(
'/etc/zookeeper/conf/zoo.cfg'
).without_content(/admin.enableServer=#{enable}/)

is_expected.to contain_file(
'/etc/zookeeper/conf/zoo.cfg'
).without_content(/admin.serverPort=#{port}/)

is_expected.to contain_file(
'/etc/zookeeper/conf/zoo.cfg'
).without_content(/admin.commandURL=#{url}/)
end
end

context 'install from archive' do
let :pre_condition do
'class {"zookeeper":
Expand Down
13 changes: 13 additions & 0 deletions templates/conf/zoo.cfg.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ clientPortAddress=<%= scope.lookupvar("zookeeper::client_ip") %>
#clientPortAddress=
<% end -%>

<% if @enable_admin_server -%>
# Set to "false" to disable the AdminServer. By default the AdminServer is enabled.
admin.enableServer=<%= scope.lookupvar('zookeeper::admin_enable_server') %>
# The address the embedded Jetty server listens on. Defaults to 0.0.0.0.
admin.serverAddress=<%= scope.lookupvar('zookeeper::admin_server_address') %>
# The port the embedded Jetty server listens on. Defaults to 8080.
admin.serverPort=<%= scope.lookupvar('zookeeper::admin_server_port') %>
# Set the maximum idle time in milliseconds that a connection can wait before sending or receiving data. Defaults to 30000 ms.
admin.idleTimeout=<%= scope.lookupvar('zookeeper::admin_idle_timeout') %>
# The URL for listing and issuing commands relative to the root URL. Defaults to "/commands".
admin.commandURL=<%= scope.lookupvar('zookeeper::admin_command_url') %>
<% end -%>

# specify all zookeeper servers
# The first port is used by followers to connect to the leader
# The second one is used for leader election
Expand Down