From 93197b7422355e91b606a49c485638e2c9ec07ea Mon Sep 17 00:00:00 2001 From: Casper Kolkman Date: Fri, 26 Feb 2016 22:08:03 +0100 Subject: [PATCH 1/2] Added the new config since kibana 4.2.x Support for custom log file and server.basePath --- manifests/config.pp | 17 ++++- manifests/init.pp | 4 + manifests/params.pp | 4 + ...{kibana.yml.erb => kibana-4.0-4.1.yml.erb} | 10 ++- templates/kibana-4.2-4.4.yml.erb | 76 +++++++++++++++++++ 5 files changed, 107 insertions(+), 4 deletions(-) rename templates/{kibana.yml.erb => kibana-4.0-4.1.yml.erb} (89%) create mode 100644 templates/kibana-4.2-4.4.yml.erb diff --git a/manifests/config.pp b/manifests/config.pp index 32451d1..30e85c0 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -8,6 +8,7 @@ # * Justin Lambert # class kibana::config ( + $version = $::kibana::version, $install_path = $::kibana::install_path, $port = $::kibana::port, $bind = $::kibana::bind, @@ -21,17 +22,29 @@ $pid_file = $::kibana::pid_file, $request_timeout = $::kibana::request_timeout, $shard_timeout = $::kibana::shard_timeout, + $ping_timeout = $::kibana::ping_timeout, + $startup_timeout = $::kibana::startup_timeout, $ssl_cert_file = $::kibana::ssl_cert_file, $ssl_key_file = $::kibana::ssl_key_file, $verify_ssl = $::kibana::verify_ssl, + $base_path = $::kibana::base_path, + $log_file = $::kibana::log_file, ){ + if versioncmp($version, '4.2.0') < 0 { + if $base_path { + fail('Kibana config: server.basePath is not supported for kibana 4.1 and lower') + } + $template = 'kibana-4.0-4.1.yml' + } else { + $template = 'kibana-4.2-4.4.yml' + } + file { "${install_path}/kibana/config/kibana.yml": ensure => 'file', owner => 'kibana', group => 'kibana', mode => '0440', - content => template('kibana/kibana.yml.erb'), + content => template("kibana/${template}.erb"), } - } diff --git a/manifests/init.pp b/manifests/init.pp index ed8c7a7..3596b5f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -112,9 +112,13 @@ $plugins = $::kibana::params::plugins, $request_timeout = $::kibana::params::request_timeout, $shard_timeout = $::kibana::params::shard_timeout, + $ping_timeout = $::kibana::params::ping_timeout, + $startup_timeout = $::kibana::params::startup_timeout, $ssl_cert_file = $::kibana::params::ssl_cert_file, $ssl_key_file = $::kibana::params::ssl_key_file, $verify_ssl = $::kibana::params::verify_ssl, + $base_path = $::kibana::params::base_path, + $log_file = $::kibana::params::log_file, ) inherits kibana::params { if !is_integer($port) { diff --git a/manifests/params.pp b/manifests/params.pp index 0fc5755..e697380 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -23,11 +23,15 @@ $default_app_id = 'discover' $request_timeout = 300000 $shard_timeout = 0 + $ping_timeout = 1500 + $startup_timeout = 5000 $ssl_cert_file = undef $ssl_key_file = undef $verify_ssl = true $group = 'kibana' $user = 'kibana' + $base_path = undef + $log_file = '/var/log/kibana/kibana.log' case $::operatingsystem { 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'OracleLinux', 'SLC': { diff --git a/templates/kibana.yml.erb b/templates/kibana-4.0-4.1.yml.erb similarity index 89% rename from templates/kibana.yml.erb rename to templates/kibana-4.0-4.1.yml.erb index af56d35..ecf758c 100644 --- a/templates/kibana.yml.erb +++ b/templates/kibana-4.0-4.1.yml.erb @@ -26,12 +26,15 @@ kibana_elasticsearch_username: <%= @elasticsearch_username %> kibana_elasticsearch_password: <%= @elasticsearch_password %> <%- end -%> - # The default application to load. default_app_id: "<%= @default_app_id %>" # Logs -log_file: /var/log/kibana/kibana.log +log_file: <%= @log_file %> + +# Time in milliseconds to wait for elasticsearch to respond to pings, defaults to +# request_timeout setting +ping_timeout: <%= @ping_timeout %> # Time in milliseconds to wait for responses from the back end or elasticsearch. # This must be > 0 @@ -41,6 +44,9 @@ request_timeout: <%= @request_timeout %> # Set to 0 to disable. shard_timeout: <%= @shard_timeout %> +# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying +startup_timeout: <%= @startup_timeout %> + # Set to false to have a complete disregard for the validity of the SSL # certificate. verify_ssl: <%= @verify_ssl %> diff --git a/templates/kibana-4.2-4.4.yml.erb b/templates/kibana-4.2-4.4.yml.erb new file mode 100644 index 0000000..47e0659 --- /dev/null +++ b/templates/kibana-4.2-4.4.yml.erb @@ -0,0 +1,76 @@ +# Kibana is served by a back end server. This controls which port to use. +server.port: <%= @port %> + +# The host to bind the server to. +server.host: "<%= @bind %>" + +# If you are running kibana behind a proxy, and want to mount it at a path, +# specify that path here. The basePath can't end in a slash. +<%- if @base_path -%> +server.basePath: "<%= @base_path %>" +<%- end -%> + +# The Elasticsearch instance to use for all your queries. +elasticsearch.url: "<%= @es_url %>" + +# preserve_elasticsearch_host true will send the hostname specified in `elasticsearch`. If you set it to false, +# then the host you use to connect to *this* Kibana instance will be sent. +elasticsearch.preserveHost: <%= @es_preserve_host %> + +# Kibana uses an index in Elasticsearch to store saved searches, visualizations +# and dashboards. It will create a new index if it doesn't already exist. +kibana.index: "<%= @kibana_index %>" + +# The default application to load. +kibana.defaultAppId: "<%= @default_app_id %>" + +# If your Elasticsearch is protected with basic auth, these are the user credentials +# used by the Kibana server to perform maintenance on the kibana_index at startup. Your Kibana +# users will still need to authenticate with Elasticsearch (which is proxied through +# the Kibana server) +<%- if @elasticsearch_username -%> +elasticsearch.username: <%= @elasticsearch_username %> +<%- end -%> +<%- if @elasticsearch_password -%> +elasticsearch.password: <%= @elasticsearch_password %> +<%- end -%> + +# SSL for outgoing requests from the Kibana Server to the browser (PEM formatted) +<%- if @ssl_key_file -%> +server.ssl.key: <%= @ssl_key_file %> +<%- end -%> + +<%- if @ssl_cert_file -%> +server.ssl.cert: <%= @ssl_cert_file %> +<%- end -%> + +# If you need to provide a CA certificate for your Elasticsearch instance, put +# the path of the pem file here. +<%- if @ca_cert -%> +elasticsearch.ssl.ca: <%= @ca_cert %> +<%- end -%> + +# Set to false to have a complete disregard for the validity of the SSL +# certificate. +elasticsearch.ssl.verify: <%= @verify_ssl %> + +# Time in milliseconds to wait for elasticsearch to respond to pings, defaults to +# request_timeout setting +elasticsearch.pingTimeout: <%= @ping_timeout %> + +# Time in milliseconds to wait for responses from the back end or elasticsearch. +# This must be > 0 +elasticsearch.requestTimeout: <%= @request_timeout %> + +# Time in milliseconds for Elasticsearch to wait for responses from shards. +# Set to 0 to disable. +elasticsearch.shardTimeout: <%= @shard_timeout %> + +# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying +elasticsearch.startupTimeout: <%= @startup_timeout %> + +# Set the path to where you would like the process id file to be created. +pid.file: <%= @pid_file %> + +# If you would like to send the log output to a file you can set the path below. +logging.dest: <%= @log_file %> From 3bf7b33b8b139ba5cd5126cead6c33d9c5cdda04 Mon Sep 17 00:00:00 2001 From: Casper Kolkman Date: Wed, 2 Mar 2016 09:28:21 +0100 Subject: [PATCH 2/2] Added tests for version selection in kibana::config --- spec/classes/config_spec.rb | 43 ++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 240e7b8..24b49fb 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -8,7 +8,7 @@ :https_proxy => false, } } - let(:params) { { + default_params = { :port => 5601, :bind => '0.0.0.0', :ca_cert => nil, @@ -25,8 +25,45 @@ :ssl_key_file => nil, :verify_ssl => true, :install_path => '/opt' - } } + } + + context 'with version 4.1 or lower' do + + let(:params) { + default_params.merge({ + :version => '4.1.5' + }) + } + + it { should contain_file('/opt/kibana/config/kibana.yml').with_content(/^port:/) } + + end + + context 'with version 4.2' do + + let(:params) { + default_params.merge({ + :version => '4.2.0' + }) + } + + it { should contain_file('/opt/kibana/config/kibana.yml').with_content(/^server\.port:/) } + it { should contain_file('/opt/kibana/config/kibana.yml').without_content(/^port:/)} + + end + + context 'with version 4.1 and a basePath which is supported since 4.2' do + + let(:params) { + default_params.merge({ + :version => '4.1.5', + :base_path => '/kibana' + }) + } + + it { should compile.and_raise_error(/Kibana config: server.basePath is not supported for kibana 4.1 and lower/) } + + end - it { should contain_file('/opt/kibana/config/kibana.yml') } end