Skip to content

Commit

Permalink
Merge pull request #79 from caskolkm/support-server-base-path
Browse files Browse the repository at this point in the history
Added the new config since kibana 4.2.x, support for custom log file and server.basePath
  • Loading branch information
jlambert121 committed Mar 3, 2016
2 parents d3a7b58 + 3bf7b33 commit d6b07fd
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 7 deletions.
17 changes: 15 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# * Justin Lambert <mailto:[email protected]>
#
class kibana::config (
$version = $::kibana::version,
$install_path = $::kibana::install_path,
$port = $::kibana::port,
$bind = $::kibana::bind,
Expand All @@ -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"),
}

}
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down
43 changes: 40 additions & 3 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:https_proxy => false,
} }

let(:params) { {
default_params = {
:port => 5601,
:bind => '0.0.0.0',
:ca_cert => nil,
Expand All @@ -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
10 changes: 8 additions & 2 deletions templates/kibana.yml.erb → templates/kibana-4.0-4.1.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 %>
Expand Down
76 changes: 76 additions & 0 deletions templates/kibana-4.2-4.4.yml.erb
Original file line number Diff line number Diff line change
@@ -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 %>

0 comments on commit d6b07fd

Please sign in to comment.