diff --git a/manifests/config.pp b/manifests/config.pp index 7c06936..45e3f36 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -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, diff --git a/manifests/init.pp b/manifests/init.pp index 92203ed..0d9ebc9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 { diff --git a/manifests/params.pp b/manifests/params.pp index 926a4cf..cdce011 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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 = [] } diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index ab9dd15..6a7ea4b 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -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": diff --git a/templates/conf/zoo.cfg.erb b/templates/conf/zoo.cfg.erb index d9e1917..bd9a9da 100644 --- a/templates/conf/zoo.cfg.erb +++ b/templates/conf/zoo.cfg.erb @@ -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