From d79e2f2880f07f51f8c8fa6b8a3deb1b8c368fac Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Mon, 25 Apr 2016 01:59:04 +1000 Subject: [PATCH 1/5] Add missing chown for the PID file. --- templates/kibana.init.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/kibana.init.erb b/templates/kibana.init.erb index fdca210..f8441e7 100644 --- a/templates/kibana.init.erb +++ b/templates/kibana.init.erb @@ -40,10 +40,13 @@ pidfile=<%= scope['kibana4::config']['pid.file'] -%> pidfile=/var/run/kibana.pid <% end -%> - [ -r /etc/default/$name ] && . /etc/default/$name [ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name +rundir=$(dirname $pidfile) +[ ! -d $rundir ] && mkdir -p $rundir +chown $user:$group $rundir + trace() { logger -t "/etc/init.d/kibana" "$@" } @@ -76,6 +79,7 @@ start() { # generate it there will be a race condition between the pidfile writing # and a process possibly asking for status. echo $! > $pidfile + chown $user:$group $pidfile emit "$name started" return 0 From 99080f6e88a3aa527eafc3bb31399491d193a3bb Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Mon, 25 Apr 2016 15:04:55 +1000 Subject: [PATCH 2/5] Add content tests. --- spec/classes/init_spec.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 9bc56f6..d76b089 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -321,7 +321,16 @@ it { should_not contain_file('/opt/kibana') } it { should contain_file('kibana-config-file').with_path('/usr/share/kibana4/config/kibana.yml') } it { should contain_service('kibana4').with_ensure('true').with_enable('true') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/usr\/share\/kibana4\/bin\/kibana/) } + it { should contain_file('/etc/init.d/kibana') } + it { + verify_contents(catalogue, '/etc/init.d/kibana', [ + 'rundir=$(dirname $pidfile)', + '[ ! -d $rundir ] && mkdir -p $rundir', + 'chown $user:$group $rundir', + ' echo $! > $pidfile', + ' chown $user:$group $pidfile', + ]) + } end context 'installs via package and set config file' do From d83d00b2573767797669f8477d4c0b81478a7f78 Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Mon, 25 Apr 2016 15:14:03 +1000 Subject: [PATCH 3/5] Add a comment. --- spec/classes/init_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index d76b089..cd70110 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -323,6 +323,7 @@ it { should contain_service('kibana4').with_ensure('true').with_enable('true') } it { should contain_file('/etc/init.d/kibana') } it { + # verify_contents comes from puppetlabs_spec_helper/module_spec_helper.rb verify_contents(catalogue, '/etc/init.d/kibana', [ 'rundir=$(dirname $pidfile)', '[ ! -d $rundir ] && mkdir -p $rundir', @@ -331,6 +332,11 @@ ' chown $user:$group $pidfile', ]) } + it { + verify_contents(catalogue, '/etc/init.d/kibana', [ + 'program=/usr/share/kibana4/bin/kibana', + ]) + } end context 'installs via package and set config file' do From 94079542f72896f44f523be114927fbc2561af7e Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Mon, 25 Apr 2016 15:24:13 +1000 Subject: [PATCH 4/5] Resolve Rspec deprecation warnings. --- spec/classes/init_spec.rb | 168 +++++++++++++++++++------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index cd70110..da01b81 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' + describe 'kibana4' do context 'with defaults for all parameters' do @@ -7,7 +8,7 @@ :osfamily => 'RedHat' } end - it { should contain_class('kibana4') } + it { is_expected.to contain_class('kibana4') } end context 'installs via archive and no symlink and no user' do @@ -20,11 +21,11 @@ :service_enable => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('false').with_enable('false') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('false').with_enable('false') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } end context 'installs via archive and no symlink and service ensure and no user' do @@ -37,11 +38,11 @@ :service_enable => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('true').with_enable('false') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('false') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } end context 'installs via archive and no init file' do @@ -54,10 +55,10 @@ :manage_init_file => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('false').with_enable('false') } - it { should_not contain_file('/etc/init.d/kibana') } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('false').with_enable('false') } + it { is_expected.to_not contain_file('/etc/init.d/kibana') } end context 'installs via archive and no symlink and service ensure/enable and no user' do @@ -70,11 +71,11 @@ :service_enable => true, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('true').with_enable('true') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('true') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } end context 'installs via archive and symlink and no user' do @@ -87,11 +88,11 @@ :service_enable => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('false').with_enable('false') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('false').with_enable('false') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } end context 'installs via archive and symlink and service ensure and no user' do @@ -104,11 +105,11 @@ :service_enable => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('true').with_enable('false') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('false') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } end context 'installs via archive and symlink and service ensure/enable and no user' do @@ -121,11 +122,11 @@ :service_enable => true, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('true').with_enable('true') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('true') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kibana4:kibana4 \/ sh -c "/) } end context 'installs via archive and no symlink and user' do @@ -143,11 +144,11 @@ :service_ensure => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('false').with_enable('false') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('false').with_enable('false') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } end context 'installs via archive and no symlink and service ensure and user' do @@ -165,11 +166,11 @@ :service_enable => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('true').with_enable('false') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('false') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } end context 'installs via archive and no symlink and service ensure/enable and no user' do @@ -187,11 +188,11 @@ :kibana4_gid => '200', } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('true').with_enable('true') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to_not contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('true') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\-4.0.0\-linux\-x64\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } end context 'installs via archive and symlink and user' do @@ -209,11 +210,11 @@ :service_enable => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('false').with_enable('false') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('false').with_enable('false') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } end context 'installs via archive and symlink and service ensure and user' do @@ -231,11 +232,11 @@ :service_enable => false, } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('true').with_enable('false') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('false') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } end context 'installs via archive and symlink and service ensure/enable and user' do @@ -253,11 +254,11 @@ :kibana4_gid => '200', } end - it { should contain_archive('kibana-4.0.0-linux-x64')} - it { should contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } - it { should contain_service('kibana4').with_ensure('true').with_enable('true') } - it { should contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } - #it { should contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } + it { is_expected.to contain_archive('kibana-4.0.0-linux-x64')} + it { is_expected.to contain_file('/opt/kibana').with_ensure('link').with_target('/opt/kibana-4.0.0-linux-x64') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('true') } + it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^program=\/opt\/kibana\/bin\/kibana/) } + #it { is_expected.to contain_file('/etc/init.d/kibana').with_content(/^ chroot --userspec kib4:kib4 \/ sh -c "/) } end context 'installs via package and package_install_dir and no init file and service ensure/enable and user' do @@ -285,11 +286,11 @@ } } end - it { should contain_package('kibana4').with_ensure('4.4.1') } - it { should_not contain_file('/opt/kibana') } - it { should contain_file('kibana-config-file').with_path('/usr/share/kibana4/config/kibana.yml') } - it { should contain_service('kibana4').with_ensure('true').with_enable('true') } - it { should_not contain_file('/etc/init.d/kibana') } + it { is_expected.to contain_package('kibana4').with_ensure('4.4.1') } + it { is_expected.to_not contain_file('/opt/kibana') } + it { is_expected.to contain_file('kibana-config-file').with_path('/usr/share/kibana4/config/kibana.yml') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('true') } + it { is_expected.to_not contain_file('/etc/init.d/kibana') } end context 'installs via package and package_install_dir and init file and service ensure/enable and user' do @@ -317,13 +318,12 @@ } } end - it { should contain_package('kibana4').with_ensure('4.4.1') } - it { should_not contain_file('/opt/kibana') } - it { should contain_file('kibana-config-file').with_path('/usr/share/kibana4/config/kibana.yml') } - it { should contain_service('kibana4').with_ensure('true').with_enable('true') } - it { should contain_file('/etc/init.d/kibana') } + it { is_expected.to contain_package('kibana4').with_ensure('4.4.1') } + it { is_expected.to_not contain_file('/opt/kibana') } + it { is_expected.to contain_file('kibana-config-file').with_path('/usr/share/kibana4/config/kibana.yml') } + it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('true') } + it { is_expected.to contain_file('/etc/init.d/kibana') } it { - # verify_contents comes from puppetlabs_spec_helper/module_spec_helper.rb verify_contents(catalogue, '/etc/init.d/kibana', [ 'rundir=$(dirname $pidfile)', '[ ! -d $rundir ] && mkdir -p $rundir', @@ -356,7 +356,7 @@ } } end - it { should contain_file('kibana-config-file').with_path('/etc/kibana4/kibana.yml') } + it { is_expected.to contain_file('kibana-config-file').with_path('/etc/kibana4/kibana.yml') } end context 'installs via package provider' do @@ -372,7 +372,7 @@ :install_method => 'package', } end - it { should contain_package('kibana4') } + it { is_expected.to contain_package('kibana4') } end context 'using the official repos on CentOS' do @@ -390,9 +390,9 @@ :package_repo_version => '4.1' } end - it { should contain_package('kibana4').with_name('kibana')} - it { should contain_service('kibana4').with_ensure('true').with_name('kibana') } - it { should contain_yumrepo('kibana-4.1') } + it { is_expected.to contain_package('kibana4').with_name('kibana')} + it { is_expected.to contain_service('kibana4').with_ensure('true').with_name('kibana') } + it { is_expected.to contain_yumrepo('kibana-4.1') } end context 'using the official repos on Ubuntu' do @@ -411,9 +411,9 @@ :package_repo_version => '4.1' } end - it { should contain_package('kibana4').with_name('kibana')} - it { should contain_service('kibana4').with_ensure('true').with_name('kibana') } - it { should contain_apt__source('kibana-4.1') } + it { is_expected.to contain_package('kibana4').with_name('kibana')} + it { is_expected.to contain_service('kibana4').with_ensure('true').with_name('kibana') } + it { is_expected.to contain_apt__source('kibana-4.1') } end end From 98745f86262679b44054fae9cb97a9db81c59adb Mon Sep 17 00:00:00 2001 From: Alex Harvey Date: Mon, 25 Apr 2016 15:47:13 +1000 Subject: [PATCH 5/5] Clean up README. --- README.md | 303 ++++++++++++++++++++++++------------------------------ 1 file changed, 136 insertions(+), 167 deletions(-) diff --git a/README.md b/README.md index 265099b..5a5b5b3 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,7 @@ Install and configure Kibana4. Should work on any linux OS. ## Module Description -This module assumes you have a working Elasticsearch installation and indices (usually an "ELK" stack). -Kibana4 only works with recent versions of Elasticsearch (1.4.4 and later). I recommend using the "elasticsearch" output with `protocol => "http"` in Logstash (supported since 1.4.0) as the default `protocol => "node"` uses ES version 1.1.1 and will prevent Kibana4 from connecting. +This module assumes you have a working Elasticsearch installation and indices (usually an 'ELK' stack). Kibana4 only works with recent versions of Elasticsearch (1.4.4 and later). I recommend using the 'elasticsearch' output with `protocol => 'http'` in Logstash (supported since 1.4.0) as the default `protocol => 'node'` uses ES version 1.1.1 and will prevent Kibana4 from connecting. ## Setup @@ -38,250 +37,220 @@ Kibana4 only works with recent versions of Elasticsearch (1.4.4 and later). I re ### Beginning with kibana4 +```puppet include kibana4 +``` ## Usage ### Example to install from apt or yum repo -The elastic.co packages create a kibana user and group (999:999) and they provide an init file /etc/init.d/kibana -This is now the preferred installation method for kibana4. +The elastic.co packages create a kibana user and group (999:999) and they provide an init file `/etc/init.d/kibana`. This is now the preferred installation method for kibana4. ```puppet -class { '::kibana4': } +include kibana4 ``` ### Example to install from archive -If you decided to have the module create a user, you will need to specify -user name, group name, uid and gid. +If you decide to have the module create a user, you will need to specify user name, group name, uid and gid. ```puppet - class { '::kibana4': - version => '4.4.1-linux-x64', - install_method => 'archive', - archive_symlink => true, - manage_user => true, - kibana4_user => kibana4, - kibana4_group => kibana4, - kibana4_gid => 200, - kibana4_uid => 200, - config => { - 'server.port' => 5601, - 'server.host' => '0.0.0.0', - 'elasticsearch.url' => 'http://localhost:9200', - } + class { 'kibana4': + version => '4.4.1-linux-x64', + install_method => 'archive', + archive_symlink => true, + manage_user => true, + kibana4_user => 'kibana4', + kibana4_group => 'kibana4', + kibana4_gid => 3000, + kibana4_uid => 3000, + config => { + 'server.port' => 5601, + 'server.host' => '0.0.0.0', + 'elasticsearch.url' => 'http://localhost:9200', + }, } ``` -If you prefer to use "nanliu/archive" or "puppet/archive" as the archive -downloader instead of the default "camptocamp/archive" then set the class -parameter `archive_provider`. Make sure to have either "nanliu/archive" or -"puppet/archive" installed since dependency on one of multiple different -modules with the same name cannot be recorded in metadata.json (by default this -module uses and depends on "camptocamp/archive"). +If you prefer to use [nanliu/archive](https://forge.puppet.com/nanliu/archive) or [puppet/archive](https://forge.puppet.com/puppet/archive) as the archive downloader instead of the default [camptocamp/archive](https://forge.puppet.com/camptocamp/archive) then set the class parameter `archive_provider`. Make sure to have either nanliu/archive or puppet/archive installed since dependency on one of multiple different modules with the same name cannot be recorded in `metadata.json` (by default this module uses and depends on camptocamp/archive). ```puppet - class { '::kibana4': - version => '4.4.1-linux-x64', - install_method => 'archive', - archive_provider => 'nanliu', # or 'puppet' - archive_symlink => false, - manage_user => true, - kibana4_user => kibana4, - kibana4_group => kibana4, - kibana4_gid => 200, - kibana4_uid => 200, - config => { - 'server.port' => 5601, - 'server.host' => '0.0.0.0', - 'elasticsearch.url' => 'http://localhost:9200', - } + class { 'kibana4': + version => '4.4.1-linux-x64', + install_method => 'archive', + archive_provider => 'nanliu', # or 'puppet' + archive_symlink => false, + manage_user => true, + kibana4_user => 'kibana4', + kibana4_group => 'kibana4', + kibana4_gid => 200, + kibana4_uid => 200, + config => { + 'server.port' => 5601, + 'server.host' => '0.0.0.0', + 'elasticsearch.url' => 'http://localhost:9200', + }, } ``` ## Parameters -Check all parameters in init.pp file +Check all parameters in the `manifests/init.pp` file. ### Installation Parameters -[*version*] +#### `version` -Version of Kibana4 that gets installed. Defaults to the latest 4.1.1 version -available at the time of module release. +Version of Kibana4 that gets installed. Defaults to the latest 4.1.1 version available at the time of module release. -[*package_name*] +#### `package_name` The name of the Kibana4 package that gets installed. Defaults to 'kibana'. -[*install_method*] +#### `install_method` -Set to 'archive' to download Kibana from the Elasticsearch download site (see -also `archive_download_url` below). Set to 'package' to use the default package -manager for installation. Defaults to 'package'. +Set to 'archive' to download Kibana from the Elasticsearch download site (see also `archive_download_url` below). Set to 'package' to use the default package manager for installation. Defaults to 'package'. -[*archive_provider*] +#### `archive_provider` -Select which `archive` type should be used to download Kibana from the -Elasticsearch download site. There exist at least two modules that provide an -`archive` type: "camptocamp/archive" and "nanliu/archive" (or "puppet/archive" -since the module is now in the care of puppet-community). Defaults to -'camptocamp'. If you set this to 'nanliu' (or 'puppet') make sure you have that -module installed since both cannot be recorded as a dependency in metadata.json -at the same time. +Select which `archive` type should be used to download Kibana from the Elasticsearch download site. There exist at least two modules that provide an `archive` type: 'camptocamp/archive' and 'nanliu/archive' (or 'puppet/archive' since the module is now in the care of puppet-community). Defaults to 'camptocamp'. If you set this to 'nanliu' (or 'puppet') make sure you have that module installed since both cannot be recorded as a dependency in metadata.json at the same time. -[*archive_download_url*] +#### `archive_download_url` -Alternative URL from which to download Kibana if `install_method` is -'archive'. Defaults to `undef`, because by default the URL is constructed -from the usual Elasticsearch download site URL, the `package_name` and -`version`. +Alternative URL from which to download Kibana if `install_method` is 'archive'. Defaults to `undef`, because by default the URL is constructed from the usual Elasticsearch download site URL, the `package_name` and `version`. -[*archive_proxy_server*] +#### `archive_proxy_server` Specify a proxy server if you need to use one. Defaults to `undef`. -[*package_use_official_repo*] +#### `package_use_official_repo` + Use official apt or yum repository. Only used if install_method is set to 'package'. -[*package_repo_version*] -Apt or yum repository version. Only used if 'package_use_official_repo' is set to 'true'. -defaults to '4.1'. +#### `package_repo_version` + +Apt or yum repository version. Only used if 'package_use_official_repo' is set to 'true'. Defaults to '4.1'. -[*service_ensure*] +#### `service_ensure` -Specifies the service state. Valid values are stopped (false) and running -(true). Defaults to 'running'. +Specifies the service state. Valid values are stopped (false) and running (true). Defaults to 'running'. -[*service_enable*] +#### `service_enable` -Should the service be enabled on boot. Valid values are true, false, and -manual. Defaults to 'true'. +Should the service be enabled on boot. Valid values are 'true', 'false', and 'manual'. Defaults to 'true'. -[*service_name*] +#### `service_name` Name of the Kibana4 service. Defaults to 'kibana'. -[*manage_init_file*] +#### `manage_init_file` -Install init file. If the init script is provided by a package, -set it to `false`. Defaults to 'true' +Install init file. If the init script is provided by a package, set it to `false`. Defaults to 'true'. -[*init_template*] +#### `init_template` Service file as a template. Defaults to 'kibana4/kibana.init'. -[*archive_install_dir*] +#### `archive_install_dir` -Installation directory used if install_method is 'archive' -Defaults to '/opt'. +Installation directory used if install_method is 'archive'. Defaults to '/opt'. + +#### `config_file` -[*config_file*] The location, as a path, of the Kibana configuration file. -[*archive_symlink*] +#### `archive_symlink` -Determines if a symlink should be created in the installation directory for -the extracted archive. Only used if install_method is 'archive'. -Defaults to 'true'. +Determines if a symlink should be created in the installation directory for the extracted archive. Only used if install_method is 'archive'. Defaults to 'true'. -[*archive_symlink_name*] +#### `archive_symlink_name` -Sets the name to be used for the symlink. The default is '$archive_install_dir/kibana'. -Only used if `install_method` is 'archive'. +Sets the name to be used for the symlink. The default is '$archive_install_dir/kibana'. Only used if `install_method` is 'archive'. -[*manage_user*] +#### `manage_user` -Should the user and group that will run the Kibana service be created and managed by -Puppet? Defaults to 'true'. +Specifies whether the user and group that will run the Kibana service is to be created and managed by Puppet. Defaults to 'true'. -[*kibana4_user*] +#### `kibana4_user` -The user that will run the service. Defaults to kibana. +The user that will run the service. Defaults to 'kibana'. -[*kibana4_uid*] +#### `kibana4_uid` The user ID assigned to the user specified in `kibana4_user`. Defaults to `undef`. -[*kibana4_group*] +#### `kibana4_group` -The primary group of the kibana user. Defaults to kibana. +The primary group of the kibana user. Defaults to 'kibana'. -[*kibana4_gid*] +#### `kibana4_gid` The group ID assigned to the group specified in `kibana4_group`. Defaults to `undef`. -[*plugins*] +#### `plugins` -Simple plugin support has been added, but updating existing plugins is not yet supported. -A hash of plugins and their installation parameters +Simple plugin support has been added, but updating existing plugins is not yet supported. A hash of plugins and their installation parameters is expected: -example: ```puppet -class { '::kibana4': - plugins => { - 'elasticsearch/marvel' => { - kibana4_plugin_dir => '/opt/kibana/installedPlugins', #optional - this is the default - plugin_dest_dir => 'marvel', #mandatory - plugin will be installed in ${kibana4_plugin_dir}/${plugin_dest_dir} - url => http://your_custom_url, #necessary if using arbitrary URL - ensure => present, #mandatory - either 'present' or 'absent' - }, - 'elastic/sense' => { - ensure => present, - plugin_dest_dir => 'sense', - } - } - - } +class { 'kibana4': + ... + plugins => { + 'elasticsearch/marvel' => { + kibana4_plugin_dir => '/opt/kibana/installedPlugins', # optional - this is the default + plugin_dest_dir => 'marvel', # mandatory - plugin will be installed in ${kibana4_plugin_dir}/${plugin_dest_dir} + url => 'http://your_custom_url', # necessary if using arbitrary URL + ensure => present, # mandatory - either 'present' or 'absent' + }, + 'elastic/sense' => { + ensure => present, + plugin_dest_dir => 'sense', + }, + } +} ``` - ### Configuration Parameters - See Kibana4 documentation for a list of kibana server properties: - https://www.elastic.co/guide/en/kibana/current/kibana-server-properties.html - If you do not specify a hash of configuration parameters, then the default kibana.yml provided - by the archive or package will be left intact. - Notice how the config hash is different in version 4.1 than it is in version 4.3. +* See the [Kibana4 documentation](https://www.elastic.co/guide/en/kibana/current/kibana-server-properties.html) for a full list of kibana server properties. +* Note: If you do not specify a hash of configuration parameters, then the default `kibana.yml` provided by the archive or package will be left intact. +* Note: The config hash is different in version 4.1 than it is in version 4.3. -[*config*] +#### `config` -A hash of key/value server properties. A value for the pid file is defaulted to '/var/run/kibana.pid' if you don't define it. +A hash of key/value server properties. Note that the default value for `pid.file` in the Kibana 4 application is `/var/run/kibana.pid`. -for version 4.3 an extensive config could look like: -``` -config => { - 'server.port' => 5601, - 'server.host' => '0.0.0.0', - 'elasticsearch.url' => 'http://localhost:9200', - 'elasticsearch.preserveHost' => true, - 'elasticsearch.ssl.cert' => '/path/to/your/cert', - 'elasticsearch.ssl.key' => '/path/to/your/key', - 'elasticsearch.password' => 'password', - 'elasticsearch.username' => 'username', - 'elasticsearch.pingTimeout' => 1500, - 'elasticsearch.startupTimeout' => 5000, - 'kibana.index' => '.kibana', - 'kibana.defaultAppId' => 'discover', - 'logging.silent' => false, - 'logging.quiet' => false, - 'logging.verbose' => false, - 'logging.events' => "{ log: ['info', 'warning', 'error', 'fatal'], response: '*', error: '*' }", - 'elasticsearch.requestTimeout' => 500000, - 'elasticsearch.shardTimeout' => 0, - 'elasticsearch.ssl.verify' => true, - 'elasticsearch.ssl.ca' => '[/path/to/a/CA,path/to/anotherCA/]', - 'server.ssl.key' => '/path/to/your/ssl/key', - 'server.ssl.cert' => '/path/to/your/ssl/cert', - 'pid.file' => '/var/run/kibana.pid', - 'logging.dest' => '/var/log/kibana/kibana.log', -} -``` +For version 4.3 an extensive config could look like: -## Reference - -This module uses camptocamp/archives to download and extract the Kibana4 archive. +```puppet + ... + config => { + 'server.port' => 5601, + 'server.host' => '0.0.0.0', + 'elasticsearch.url' => 'http://localhost:9200', + 'elasticsearch.preserveHost' => true, + 'elasticsearch.ssl.cert' => '/path/to/your/cert', + 'elasticsearch.ssl.key' => '/path/to/your/key', + 'elasticsearch.password' => 'password', + 'elasticsearch.username' => 'username', + 'elasticsearch.pingTimeout' => 1500, + 'elasticsearch.startupTimeout' => 5000, + 'kibana.index' => '.kibana', + 'kibana.defaultAppId' => 'discover', + 'logging.silent' => false, + 'logging.quiet' => false, + 'logging.verbose' => false, + 'logging.events' => "{ log: ['info', 'warning', 'error', 'fatal'], response: '*', error: '*' }", + 'elasticsearch.requestTimeout' => 500000, + 'elasticsearch.shardTimeout' => 0, + 'elasticsearch.ssl.verify' => true, + 'elasticsearch.ssl.ca' => '[/path/to/a/CA,path/to/anotherCA/]', + 'server.ssl.key' => '/path/to/your/ssl/key', + 'server.ssl.cert' => '/path/to/your/ssl/cert', + 'pid.file' => '/var/run/kibana.pid', + 'logging.dest' => '/var/log/kibana/kibana.log', + }, +``` ## Testing @@ -289,22 +258,22 @@ This module uses camptocamp/archives to download and extract the Kibana4 archive You can install gem dependencies with ``` -bundle install +$ bundle install ``` and run tests with ``` -bundle exec rake spec +$ bundle exec rake spec ``` ### Beaker-rspec -You can run beaker-spec tests which will start two vagrant boxes, one to do basic test of the `archive` installation method, and the other -to test the `package` installation method. Each vagrant box also runs elasticsearch. -At this time these tests are fairly basic. We use a basic manifest in each case and ensure that the puppet return code is 2 (the run succeeded, -and some resources were changed) on the first run, and ensure that the return code is 0 (the run succeeded with no changes or failures; -the system was already in the desired state) on the second run. +You can run beaker-spec tests which will start two vagrant boxes, one to do basic test of the `archive` installation method, and the other to test the `package` installation method. Each vagrant box also runs elasticsearch. + +At this time these tests are fairly basic. We use a basic manifest in each case and ensure that the puppet return code is 2 (the run succeeded, and some resources were changed) on the first run, and ensure that the return code is 0 (the run succeeded with no changes or failures; the system was already in the desired state) on the second run. + Available node sets are centos-66-x64, centos-70-x64, ubuntu-1204-x64, ubuntu-1404-x64, debian-78-x64. + Run with: ``` -BEAKER_set=centos-66-x64 bundle exec rspec spec/acceptance +$ BEAKER_set=centos-66-x64 bundle exec rspec spec/acceptance ```